version 1.53, 2002/04/26 16:15:16 |
version 1.54, 2002/04/28 14:37:12 |
|
|
char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */ |
char rquote[MAXCCHARS+1] = {RQUOTE}; /* right quote character (') */ |
char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */ |
char scommt[MAXCCHARS+1] = {SCOMMT}; /* start character for comment */ |
char ecommt[MAXCCHARS+1] = {ECOMMT}; /* end character for comment */ |
char ecommt[MAXCCHARS+1] = {ECOMMT}; /* end character for comment */ |
|
int synch_lines = 0; /* line synchronisation for C preprocessor */ |
|
|
struct keyblk keywrds[] = { /* m4 keywords to be installed */ |
struct keyblk keywrds[] = { /* m4 keywords to be installed */ |
{ "include", INCLTYPE }, |
{ "include", INCLTYPE }, |
|
|
static void initkwds(void); |
static void initkwds(void); |
static ndptr inspect(int, char *); |
static ndptr inspect(int, char *); |
static int do_look_ahead(int, const char *); |
static int do_look_ahead(int, const char *); |
|
static void reallyoutputstr(const char *); |
|
static void reallyputchar(int); |
|
|
static void enlarge_stack(void); |
static void enlarge_stack(void); |
|
|
|
|
outfile = NULL; |
outfile = NULL; |
resizedivs(MAXOUT); |
resizedivs(MAXOUT); |
|
|
while ((c = getopt(argc, argv, "gt:d:D:U:o:I:")) != -1) |
while ((c = getopt(argc, argv, "gst:d:D:U:o:I:")) != -1) |
switch(c) { |
switch(c) { |
|
|
case 'D': /* define something..*/ |
case 'D': /* define something..*/ |
|
|
case 'd': |
case 'd': |
set_trace_flags(optarg); |
set_trace_flags(optarg); |
break; |
break; |
|
case 's': |
|
synch_lines = 1; |
|
break; |
case 't': |
case 't': |
mark_traced(optarg, 1); |
mark_traced(optarg, 1); |
break; |
break; |
|
|
if (ilevel <= 0) |
if (ilevel <= 0) |
break; /* all done thanks.. */ |
break; /* all done thanks.. */ |
release_input(infile+ilevel--); |
release_input(infile+ilevel--); |
|
emit_synchline(); |
bufbase = bbase[ilevel]; |
bufbase = bbase[ilevel]; |
continue; |
continue; |
} |
} |
|
|
} else { |
} else { |
if (nlpar > 0) { |
if (nlpar > 0) { |
if (sp < 0) |
if (sp < 0) |
putc(l, active); |
reallyputchar(l); |
else |
else |
CHRSAVE(l); |
CHRSAVE(l); |
} |
} |
|
|
} |
} |
|
|
else if (sp < 0 && LOOK_AHEAD(t, scommt)) { |
else if (sp < 0 && LOOK_AHEAD(t, scommt)) { |
fputs(scommt, active); |
reallyoutputstr(scommt); |
|
|
for(;;) { |
for(;;) { |
t = gpbc(); |
t = gpbc(); |
if (LOOK_AHEAD(t, ecommt)) { |
if (LOOK_AHEAD(t, ecommt)) { |
fputs(ecommt, active); |
reallyoutputstr(ecommt); |
break; |
break; |
} |
} |
if (t == EOF) |
if (t == EOF) |
break; |
break; |
putc(t, active); |
reallyputchar(t); |
} |
} |
} |
} |
|
|
else if (sp < 0) { /* not in a macro at all */ |
else if (sp < 0) { /* not in a macro at all */ |
putc(t, active); /* output directly.. */ |
reallyputchar(t); /* output directly.. */ |
} |
} |
|
|
else switch(t) { |
else switch(t) { |
|
|
outputstr(const char *s) |
outputstr(const char *s) |
{ |
{ |
if (sp < 0) |
if (sp < 0) |
while (*s) |
reallyoutputstr(s); |
putc(*s++, active); |
|
else |
else |
while (*s) |
while (*s) |
CHRSAVE(*s++); |
CHRSAVE(*s++); |
} |
} |
|
|
|
void |
|
reallyoutputstr(const char *s) |
|
{ |
|
if (synch_lines) { |
|
while (*s) { |
|
fputc(*s, active); |
|
if (*s++ == '\n') { |
|
infile[ilevel].synch_lineno++; |
|
if (infile[ilevel].synch_lineno != |
|
infile[ilevel].lineno) |
|
do_emit_synchline(); |
|
} |
|
} |
|
} else |
|
fputs(s, active); |
|
} |
|
|
|
void |
|
reallyputchar(int c) |
|
{ |
|
putc(c, active); |
|
if (synch_lines && c == '\n') { |
|
infile[ilevel].synch_lineno++; |
|
if (infile[ilevel].synch_lineno != infile[ilevel].lineno) |
|
do_emit_synchline(); |
|
} |
|
} |
|
|
/* |
/* |
* build an input token.. |
* build an input token.. |
* consider only those starting with _ or A-Za-z. This is a |
* consider only those starting with _ or A-Za-z. This is a |
|
|
outputstr(name); |
outputstr(name); |
while (isalnum(c = gpbc()) || c == '_') { |
while (isalnum(c = gpbc()) || c == '_') { |
if (sp < 0) |
if (sp < 0) |
putc(c, active); |
reallyputchar(c); |
else |
else |
CHRSAVE(c); |
CHRSAVE(c); |
} |
} |