/* stash arguments */
register int i;
- *args->a_rawptr++ = '(';
for (i = 0; ap->a_rawvec[i] != (char *)0; i++) {
+ if (i == 0) stash(repl, '(', -1);
+ else stash(repl, ',', -1);
for (p = ap->a_rawvec[i]; *p != '\0'; p++)
stash(repl, *p, -1);
- stash(repl, ',', -1);
}
- *(args->a_rawptr-1) = ')'; /* delete last ',' */
+ stash(repl, ')', -1);
}
}
}
}
UnGetChar();
- } else if (ch == '(' || ch == '[' || ch == '{') {
- /* a comma may occur within these constructions ???
- */
+ } else if (ch == '(') {
+ /* a comma may occur between parentheses */
level++;
stash(repl, ch, !nostashraw);
- } else if (ch == ')' || ch == ']' || ch == '}') {
+ } else if (ch == ')') {
level--;
- /* clossing parenthesis of macro call */
- if (ch == ')' && level < 0)
- return ')';
+ /* closing parenthesis of macro call */
+ if (level < 0) return ')';
stash(repl, ch, !nostashraw);
} else if (ch == ',') {
if (level <= 0) { /* comma separator for next argument */
interpreted as such.
*/
- ch = GetChar();
+a_new_line: ch = GetChar();
while (class(ch) == STSKIP || ch == '/') {
if (ch == '/') {
if ((ch = GetChar()) == '*' && !InputLevel) {
break;
} else ch = GetChar();
}
- if (ch == '#')
+
+ if (ch == '#') {
domacro();
- else if (ch == EOI) {
+ goto a_new_line;
+ } else if (ch == EOI) {
lexerror("unterminated macro call");
return ')';
}
{
register int index = repl->r_ptr - repl->r_text;
- if (index + 1 >= repl->r_size) {
+ ASSERT(index < repl->r_size);
+ if (index + 2 >= repl->r_size) {
repl->r_text = Realloc(repl->r_text, repl->r_size <<= 1);
repl->r_ptr = repl->r_text + index;
}
register int index = args->a_expptr - args->a_expbuf;
if (stashraw >= 0) {
+ ASSERT(index < args->a_expsize);
if (index + 1 >= args->a_expsize) {
args->a_expbuf = Realloc(args->a_expbuf,
args->a_expsize <<= 1);
if (stashraw) {
index = args->a_rawptr - args->a_rawbuf;
+ ASSERT(index < args->a_rawsize);
if (index + 1 >= args->a_rawsize) {
args->a_rawbuf = Realloc(args->a_rawbuf,
args->a_rawsize <<= 1);