return REGEXP;
}
-static int c0;
+isarrayindex()
+{
+ int c, c2;
+
+next:
+ while ((c = Getc()) == ' ' || c == '\t')
+ ;
+ if (c == '\\') {
+ if ((c2 = Getc()) == '\n') {
+ lineno++;
+ goto next;
+ }
+ Ungetc(c2);
+ }
+ if (c != '[') Ungetc(c);
+
+ return (c == '[');
+}
+
+#define UNGET_DEPTH 2
+static int unget[UNGET_DEPTH], unget_depth;
Ungetc(c)
{
- c0 = c;
+ if (unget_depth == UNGET_DEPTH) error("unget buffer overflow");
+ unget[unget_depth++] = c;
if (linep > line) {
if (--linep < line)
register int c;
char *s, *t;
- if (c0) {
- c = c0; c0 = 0;
- }
+ if (unget_depth > 0)
+ c = unget[--unget_depth];
else if (srcprg)
c = *srcprg ? *srcprg++ : EOF;
else
case DELETE:
lex();
u = getvar(text, hashtab, ARR);
- if (Getc() != '[')
+ if (!isarrayindex())
synerr("'[' expected");
p = doarray(u);
p->n_type = DELETE;
lex();
break;
case IDENT: case ARG:
- if ((c = Getc()) == '[') { /* array */
+ if (isarrayindex()) { /* array */
/* 940403 */
if (sym == ARG) {
u = (CELL *)emalloc(sizeof(CELL));
}
}
else {
- Ungetc(c);
if (sym == ARG) {
u = mkcell(POS, NULL, (double)sym1);
p = node1(ARG, u);