correct the 15 digit placeholder

This commit is contained in:
dwarning 2010-02-22 21:00:16 +00:00
parent ff53d7218f
commit 25ebb25269
4 changed files with 66 additions and 14 deletions

View File

@ -62,6 +62,7 @@ unsigned char scopy_up( char * a, char * b);
unsigned char ccopy( char * a, char c);
unsigned char sadd( char * s, char * t);
unsigned char nadd( char * s, long n);
unsigned char naddll( char * s, long long n);
unsigned char cadd( char * s, char c);
unsigned char sins( char * s, char * t);
unsigned char cins( char * s, char c);

View File

@ -574,6 +574,60 @@ nadd (char *s, long n)
return ok;
}
unsigned char
naddll (char *s, long long n)
/* append a decimal integer to a string */
{
int d[25];
int j, k, ls, len;
char sg; /* the sign */
unsigned char ok;
k = 0;
len = maxlen (s);
if (n < 0)
{
n = -n;
sg = '-';
}
else
sg = '+';
while (n > 0)
{
d[k] = n % 10;
k++;
n = n / 10;
}
if (k == 0)
ok = cadd (s, '0');
else
{
ls = length (s);
ok = (len - ls) > k;
if (ok)
{
if (sg == '-')
{
s[ls] = sg;
ls++;
}
for (j = k - 1; j >= 0; j--)
{
s[ls] = d[j] + '0';
ls++;
}
sfix (s, ls, len);
}
}
if (!ok)
stringbug ("naddll", s, NULL, sg);
return ok;
}
void
stri (long n, char *s)
/* convert integer to string */

View File

@ -61,12 +61,12 @@ unsigned int dynLlen; /* inpcom.c:1531 */
overwrite any line pointers, or we start a new set after each sig=0 ?
Anyway, we neutralize all & and .param lines (category[] array!)
and we substitute all {} &() and &id placeholders by dummy numbers.
The placeholders are long integers 1000000000+n (10 digits, n small).
The placeholders are long long integers 100000000000000+n (15 digits, n small).
*/
/********** string handling ***********/
#define PlaceHold 1000000000L
#define PlaceHold 100000000000000LL
static long placeholder = 0;
@ -123,11 +123,8 @@ stripbraces (char *s)
if (t[i - 1] > ' ')
cadd (t, ' ');
cadd (t, ' '); /* add extra character to increase number significant digits for evaluated numbers */
cadd (t, ' ');
cadd (t, ' ');
cadd (t, ' ');
nadd (t, PlaceHold + placeholder);
naddll (t, PlaceHold + placeholder); /* placeholder has 15 digits */
cadd (t, ' ');
if (s[j] >= ' ')

View File

@ -32,7 +32,7 @@ extern unsigned int dynLlen;
#define MAX_STRING_INSERT 17 /* max. string length to be inserted and replaced */
#define ACT_CHARACTS 15 /* actual string length to be inserted and replaced */
/* was 10, needs to be less or equal to MAX_STRING_INSERT - 2 */
/* was 10, needs to be less or equal to MAX_STRING_INSERT - 2 */
static double
ternary_fcn (int conditional, double if_value, double else_value)
@ -1577,7 +1577,7 @@ scanline (tdico * dico, char *s, char *r, unsigned char err)
static void
compactfloatnb (char *v)
/* try to squeeze a floating pt format to MAXCHARACTS characters */
/* try to squeeze a floating pt format to ACT_CHARACTS characters */
/* erase superfluous 000 digit streams before E */
/* bug: truncating, no rounding */
{
@ -1647,7 +1647,7 @@ insertnumber (tdico * dico, int i, char *s, char *u)
Str (80, msg);
unsigned char found;
int ls, k;
long accu;
long long accu;
ls = length (s);
scopy (v, u);
@ -1671,8 +1671,8 @@ insertnumber (tdico * dico, int i, char *s, char *u)
k = 0;
accu = 0;
while (found && (k < 10))
{ /* parse a 10-digit number */
while (found && (k < 15))
{ /* parse a 15-digit number */
found = num (s[i + k]);
if (found)
@ -1683,15 +1683,15 @@ insertnumber (tdico * dico, int i, char *s, char *u)
if (found)
{
accu = accu - 1000000000L; /* plausibility test */
accu = accu - 100000000000000LL; /* plausibility test */
found = (accu > 0) && (accu < dynsubst + 1); /* dynsubst numbers have been allocated */
}
i++;
}
if (found)
{ /* substitute at i-1-ACT_CHARACTS+11 */
for (k = 0; k < ACT_CHARACTS - 10; k++) i--;
{ /* substitute at i-1 ongoing */
i--;
for (k = 0; k < ACT_CHARACTS; k++)
s[i + k] = v[k];