version 1.23, 2004/02/18 07:43:58 |
version 1.24, 2004/10/19 07:36:51 |
|
|
int yyparse(void); |
int yyparse(void); |
int yywrap(void); |
int yywrap(void); |
|
|
|
int fileindex; |
|
int sargc; |
|
char **sargv; |
|
char *filename; |
|
char *cmdexpr; |
|
|
static void grow(void); |
static void grow(void); |
static ssize_t cs(const char *); |
static ssize_t cs(const char *); |
static ssize_t as(const char *); |
static ssize_t as(const char *); |
|
|
static ssize_t epilogue; |
static ssize_t epilogue; |
static bool st_has_continue; |
static bool st_has_continue; |
static char str_table[UCHAR_MAX][2]; |
static char str_table[UCHAR_MAX][2]; |
static int fileindex; |
|
static int sargc; |
|
static char **sargv; |
|
static char *filename; |
|
static bool do_fork = true; |
static bool do_fork = true; |
static u_short var_count; |
static u_short var_count; |
|
|
|
|
epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE); |
epilogue = node(epilogue, cs("L"), n, cs("s."), END_NODE); |
} |
} |
|
|
int |
|
yywrap(void) |
|
{ |
|
if (fileindex < sargc) { |
|
filename = sargv[fileindex++]; |
|
yyin = fopen(filename, "r"); |
|
lineno = 1; |
|
if (yyin == NULL) |
|
err(1, "cannot open %s", filename); |
|
return 0; |
|
} else if (fileindex == sargc) { |
|
fileindex++; |
|
yyin = stdin; |
|
lineno = 1; |
|
filename = "stdin"; |
|
return 0; |
|
} |
|
return 1; |
|
} |
|
|
|
void |
void |
yyerror(char *s) |
yyerror(char *s) |
{ |
{ |
|
|
static __dead void |
static __dead void |
usage(void) |
usage(void) |
{ |
{ |
fprintf(stderr, "%s: usage: [-cl] [file ...]\n", __progname); |
fprintf(stderr, "%s: usage: [-cl] [-e expression] [file ...]\n", |
|
__progname); |
exit(1); |
exit(1); |
} |
} |
|
|
|
|
{ |
{ |
int i, ch, ret; |
int i, ch, ret; |
int p[2]; |
int p[2]; |
|
char *q; |
|
|
init(); |
init(); |
setlinebuf(stdout); |
setlinebuf(stdout); |
|
|
if (sargv == NULL) |
if (sargv == NULL) |
err(1, NULL); |
err(1, NULL); |
|
|
/* The d debug option is 4.4 BSD dc(1) compatible */ |
if ((cmdexpr = strdup("")) == NULL) |
while ((ch = getopt(argc, argv, "cdl")) != -1) { |
err(1, NULL); |
|
/* The d debug option is 4.4 BSD bc(1) compatible */ |
|
while ((ch = getopt(argc, argv, "cde:l")) != -1) { |
switch (ch) { |
switch (ch) { |
case 'c': |
case 'c': |
case 'd': |
case 'd': |
do_fork = false; |
do_fork = false; |
|
break; |
|
case 'e': |
|
q = cmdexpr; |
|
if (asprintf(&cmdexpr, "%s%s\n", cmdexpr, optarg) == -1) |
|
err(1, NULL); |
|
free(q); |
break; |
break; |
case 'l': |
case 'l': |
sargv[sargc++] = _PATH_LIBB; |
sargv[sargc++] = _PATH_LIBB; |