version 1.26, 2000/01/12 17:49:53 |
version 1.27, 2000/01/13 17:35:09 |
|
|
extern int optind; |
extern int optind; |
extern char *optarg; |
extern char *optarg; |
|
|
|
#define MAXRECORD 50 |
|
static struct position { |
|
char *name; |
|
unsigned long line; |
|
} quotes[MAXRECORD], paren[MAXRECORD]; |
|
|
|
static void record __P((struct position *, int)); |
|
static void dump_stack __P((struct position *, int)); |
|
|
static void macro __P((void)); |
static void macro __P((void)); |
static void initkwds __P((void)); |
static void initkwds __P((void)); |
static ndptr inspect __P((char, char *)); |
static ndptr inspect __P((char, char *)); |
|
|
} |
} |
} |
} |
else if (t == EOF) { |
else if (t == EOF) { |
if (sp > -1) |
if (sp > -1) { |
errx(1, "unexpected end of input"); |
warnx( "unexpected end of input, unclosed parenthesis:"); |
|
dump_stack(paren, PARLEV); |
|
exit(1); |
|
} |
if (ilevel <= 0) |
if (ilevel <= 0) |
break; /* all done thanks.. */ |
break; /* all done thanks.. */ |
release_input(infile+ilevel--); |
release_input(infile+ilevel--); |
|
|
* [the order of else if .. stmts is important.] |
* [the order of else if .. stmts is important.] |
*/ |
*/ |
else if (LOOK_AHEAD(t,lquote)) { /* strip quotes */ |
else if (LOOK_AHEAD(t,lquote)) { /* strip quotes */ |
nlpar = 1; |
nlpar = 0; |
|
record(quotes, nlpar++); |
do { |
do { |
|
|
l = gpbc(); |
l = gpbc(); |
|
|
nlpar--; |
nlpar--; |
s = rquote; |
s = rquote; |
} else if (LOOK_AHEAD(l,lquote)) { |
} else if (LOOK_AHEAD(l,lquote)) { |
nlpar++; |
record(quotes, nlpar++); |
s = lquote; |
s = lquote; |
} else if (l == EOF) { |
} else if (l == EOF) { |
if (nlpar == 1) |
if (nlpar == 1) |
errx(1, "missing right quote."); |
warnx("unclosed quote:"); |
else |
else |
errx(1, "missing %d right quotes.", nlpar); |
warnx("%d unclosed quotes:", nlpar); |
|
dump_stack(quotes, nlpar); |
|
exit(1); |
} else { |
} else { |
chars[0] = l; |
chars[0] = l; |
chars[1] = EOS; |
chars[1] = EOS; |
|
|
while (isspace(l = gpbc())) |
while (isspace(l = gpbc())) |
; /* skip blank, tab, nl.. */ |
; /* skip blank, tab, nl.. */ |
putback(l); |
putback(l); |
PARLEV++; |
record(paren, PARLEV++); |
break; |
break; |
|
|
case RPAREN: |
case RPAREN: |
|
|
} |
} |
} |
} |
|
|
|
static void |
|
record(t, lev) |
|
struct position *t; |
|
int lev; |
|
{ |
|
if (lev < MAXRECORD) { |
|
t[lev].name = CURRENT_NAME; |
|
t[lev].line = CURRENT_LINE; |
|
} |
|
} |
|
|
|
static void |
|
dump_stack(t, lev) |
|
struct position *t; |
|
int lev; |
|
{ |
|
int i; |
|
|
|
for (i = 0; i < lev; i++) { |
|
if (i == MAXRECORD) { |
|
fprintf(stderr, " ...\n"); |
|
break; |
|
} |
|
fprintf(stderr, " %s at line %lu\n", |
|
t[i].name, t[i].line); |
|
} |
|
} |