ptok->tk_val = 0;
return ptok->tk_symb = INTEGER;
}
- ptok->tk_str = Malloc(idfsize + 1);
+ ptok->tk_str = Malloc(tg - buf);
strcpy(ptok->tk_str, buf);
return ptok->tk_symb = IDENTIFIER;
}
char *nm;
{
register int c;
- register int str_size;
+ register unsigned int str_size;
register char *str = Malloc(str_size = ISTRSIZE);
register int pos = 0;
}
str[pos++] = c;
if (pos == str_size)
- str = Srealloc(str, str_size += RSTRSIZE);
+ str = Srealloc(str, str_size <<= 1);
LoadChar(c);
}
str[pos++] = '\0'; /* for filenames etc. */
!File: strsize.h
-#define ISTRSIZE 32 /* minimum number of bytes allocated for
+#define ISTRSIZE 16 /* minimum number of bytes allocated for
storing a string */
-#define RSTRSIZE 32 /* step size in enlarging the memory for
- the storage of a string */
!File: botch_free.h
!File: textsize.h
-#define ITEXTSIZE 64 /* 1st piece of memory for repl. text */
-#define RTEXTSIZE 64 /* stepsize for enlarging repl.text */
+#define ITEXTSIZE 16 /* 1st piece of memory for repl. text */
!File: inputtype.h
parameter. Other tokens will not be seen as such.
*/
register int c;
- register int text_size;
+ register unsigned int text_size;
char *text = Malloc(text_size = ITEXTSIZE);
- register int pos = 0;
+ register unsigned int pos = 0;
LoadChar(c);
else
text[pos++] = '\\';
if (pos == text_size)
- text = Srealloc(text, text_size += RTEXTSIZE);
+ text = Srealloc(text, text_size <<= 1);
}
else
if ( c == '/') {
else
text[pos++] = '/';
if (pos == text_size)
- text = Srealloc(text, text_size += RTEXTSIZE);
+ text = Srealloc(text, text_size <<= 1);
}
else
if (formals && class(c) == STIDF) {
char id_buf[IDFSIZE + 1];
- register id_size = 0;
- register n;
+ register char *idp = id_buf;
+ int n;
/* read identifier: it may be a formal parameter */
- id_buf[id_size++] = c;
+ *idp++ = c;
do {
LoadChar(c);
- if (id_size <= IDFSIZE)
- id_buf[id_size++] = c;
+ if (idp <= &id_buf[IDFSIZE])
+ *idp++ = c;
} while (in_idf(c));
- id_buf[--id_size] = '\0';
+ *--idp = '\0';
if (n = find_name(id_buf, formals)) {
/* construct the formal parameter mark */
text[pos++] = FORMALP | (char) n;
if (pos == text_size)
text = Srealloc(text,
- text_size += RTEXTSIZE);
+ text_size <<= 1);
}
else {
- register char *ptr = &id_buf[0];
+ int sz = idp - id_buf;
- while (pos + id_size >= text_size)
+ idp = id_buf;
+
+ while (pos + sz >= text_size)
text = Srealloc(text,
- text_size += RTEXTSIZE);
- while (text[pos++] = *ptr++) ;
+ text_size <<= 1);
+ while (text[pos++] = *idp++) ;
pos--;
}
}
else {
text[pos++] = c;
if (pos == text_size)
- text = Srealloc(text, text_size += RTEXTSIZE);
+ text = Srealloc(text, text_size <<= 1);
LoadChar(c);
}
}
If there are no parameters, this function behaves
the same as strcpy().
*/
- register int size = idef->id_macro->mc_length + ITEXTSIZE;
+ register unsigned int size = idef->id_macro->mc_length + ITEXTSIZE;
register char *text = Malloc(size);
register int pos = 0;
register char *ptr = idef->id_macro->mc_text;
for (p = actpars[n - 1]; *p; p++) {
text[pos++] = *p;
if (pos == size)
- text = Srealloc(text, size += RTEXTSIZE);
+ text = Srealloc(text, size <<= 1);
}
}
else {
text[pos++] = *ptr++;
if (pos == size)
- text = Srealloc(text, size += RTEXTSIZE);
+ text = Srealloc(text, size <<= 1);
}
}
text[pos] = '\0';