version 1.41, 2009/10/14 17:19:47 |
version 1.42, 2010/09/07 19:58:09 |
|
|
unsigned char *buf; /* push-back buffer */ |
unsigned char *buf; /* push-back buffer */ |
unsigned char *bufbase; /* the base for current ilevel */ |
unsigned char *bufbase; /* the base for current ilevel */ |
unsigned char *bbase[MAXINP]; /* the base for each ilevel */ |
unsigned char *bbase[MAXINP]; /* the base for each ilevel */ |
unsigned char *bp; /* first available character */ |
unsigned char *bp; /* first available character */ |
unsigned char *endpbb; /* end of push-back buffer */ |
unsigned char *endpbb; /* end of push-back buffer */ |
|
|
|
|
|
|
while ((n /= 10) > 0); |
while ((n /= 10) > 0); |
} |
} |
|
|
void |
void |
initspaces() |
initspaces() |
{ |
{ |
int i; |
int i; |
|
|
bbase[i] = buf; |
bbase[i] = buf; |
} |
} |
|
|
void |
void |
enlarge_strspace() |
enlarge_strspace() |
{ |
{ |
char *newstrspace; |
char *newstrspace; |
|
|
if (!newstrspace) |
if (!newstrspace) |
errx(1, "string space overflow"); |
errx(1, "string space overflow"); |
memcpy(newstrspace, strspace, strsize/2); |
memcpy(newstrspace, strspace, strsize/2); |
for (i = 0; i <= sp; i++) |
for (i = 0; i <= sp; i++) |
if (sstack[i]) |
if (sstack[i]) |
mstack[i].sstr = (mstack[i].sstr - strspace) |
mstack[i].sstr = (mstack[i].sstr - strspace) |
+ newstrspace; |
+ newstrspace; |
ep = (ep-strspace) + newstrspace; |
ep = (ep-strspace) + newstrspace; |
free(strspace); |
free(strspace); |
|
|
void |
void |
chrsave(int c) |
chrsave(int c) |
{ |
{ |
if (ep >= endest) |
if (ep >= endest) |
enlarge_strspace(); |
enlarge_strspace(); |
*ep++ = c; |
*ep++ = c; |
} |
} |
|
|
{ |
{ |
int i; |
int i; |
|
|
outfile = (FILE **)xrealloc(outfile, sizeof(FILE *) * n, |
outfile = (FILE **)xrealloc(outfile, sizeof(FILE *) * n, |
"too many diverts %d", n); |
"too many diverts %d", n); |
for (i = maxout; i < n; i++) |
for (i = maxout; i < n; i++) |
outfile[i] = NULL; |
outfile[i] = NULL; |
|
|
err(1, "malloc"); |
err(1, "malloc"); |
else { |
else { |
va_list va; |
va_list va; |
|
|
va_start(va, fmt); |
va_start(va, fmt); |
verr(1, fmt, va); |
verr(1, fmt, va); |
va_end(va); |
va_end(va); |
|
|
va_start(va, fmt); |
va_start(va, fmt); |
verr(1, fmt, va); |
verr(1, fmt, va); |
va_end(va); |
va_end(va); |
} |
} |
} |
} |
return p; |
return p; |
} |
} |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
int |
int |
obtain_char(struct input_file *f) |
obtain_char(struct input_file *f) |
{ |
{ |
if (f->c == EOF) |
if (f->c == EOF) |
|
|
return f->c; |
return f->c; |
} |
} |
|
|
void |
void |
set_input(struct input_file *f, FILE *real, const char *name) |
set_input(struct input_file *f, FILE *real, const char *name) |
{ |
{ |
f->file = real; |
f->file = real; |
|
|
infile[ilevel].synch_lineno = infile[ilevel].lineno; |
infile[ilevel].synch_lineno = infile[ilevel].lineno; |
} |
} |
|
|
void |
void |
release_input(struct input_file *f) |
release_input(struct input_file *f) |
{ |
{ |
if (f->file != stdin) |
if (f->file != stdin) |
fclose(f->file); |
fclose(f->file); |
f->c = EOF; |
f->c = EOF; |
/* |
/* |
* XXX can't free filename, as there might still be |
* XXX can't free filename, as there might still be |
* error information pointing to it. |
* error information pointing to it. |
*/ |
*/ |
} |
} |
|
|
pbstr(lquote); |
pbstr(lquote); |
} |
} |
|
|
/* |
/* |
* buffer_mark/dump_buffer: allows one to save a mark in a buffer, |
* buffer_mark/dump_buffer: allows one to save a mark in a buffer, |
* and later dump everything that was added since then to a file. |
* and later dump everything that was added since then to a file. |
*/ |
*/ |