version 1.2, 2015/11/19 22:16:43 |
version 1.3, 2015/11/19 22:25:53 |
|
|
|
|
/* allocate argv, and populate it with the argument list. */ |
/* allocate argv, and populate it with the argument list. */ |
max_args = 8; |
max_args = 8; |
f->argv = |
f->argv = flex_alloc (sizeof (char *) * (max_args + 1)); |
(const char **) flex_alloc (sizeof (char *) * |
|
(max_args + 1)); |
|
if (!f->argv) |
if (!f->argv) |
flexerror (_("flex_alloc failed (f->argv) in filter_create_ext")); |
flexerror (_("flex_alloc failed (f->argv) in filter_create_ext")); |
f->argv[f->argc++] = cmd; |
f->argv[f->argc++] = cmd; |
|
|
while ((s = va_arg (ap, const char *)) != NULL) { |
while ((s = va_arg (ap, const char *)) != NULL) { |
if (f->argc >= max_args) { |
if (f->argc >= max_args) { |
max_args += 8; |
max_args += 8; |
f->argv = |
f->argv = flex_realloc (f->argv, |
(const char **) flex_realloc (f->argv, |
sizeof (char *) * (max_args + 1)); |
sizeof (char |
|
*) * |
|
(max_args + |
|
1)); |
|
} |
} |
f->argv[f->argc++] = s; |
f->argv[f->argc++] = s; |
} |
} |
|
|
* to sync the stream. This is a Hail Mary situation. It seems to work. |
* to sync the stream. This is a Hail Mary situation. It seems to work. |
*/ |
*/ |
close (pipes[1]); |
close (pipes[1]); |
clearerr(stdin); |
clearerr(stdin); |
if (dup2 (pipes[0], fileno (stdin)) == -1) |
if (dup2 (pipes[0], fileno (stdin)) == -1) |
flexfatal (_("dup2(pipes[0],0)")); |
flexfatal (_("dup2(pipes[0],0)")); |
close (pipes[0]); |
close (pipes[0]); |
fseek (stdin, 0, SEEK_CUR); |
fseek (stdin, 0, SEEK_CUR); |
|
|
/* run as a filter, either internally or by exec */ |
/* run as a filter, either internally or by exec */ |
if (chain->filter_func) { |
if (chain->filter_func) { |
|
|
else { |
else { |
execvp (chain->argv[0], |
execvp (chain->argv[0], |
(char **const) (chain->argv)); |
(char **const) (chain->argv)); |
lerrsf_fatal ( _("exec of %s failed"), |
lerrsf_fatal ( _("exec of %s failed"), |
chain->argv[0]); |
chain->argv[0]); |
} |
} |
|
|
exit (1); |
exit (1); |
|
|
if (dup2 (pipes[1], fileno (stdout)) == -1) |
if (dup2 (pipes[1], fileno (stdout)) == -1) |
flexfatal (_("dup2(pipes[1],1)")); |
flexfatal (_("dup2(pipes[1],1)")); |
close (pipes[1]); |
close (pipes[1]); |
fseek (stdout, 0, SEEK_CUR); |
fseek (stdout, 0, SEEK_CUR); |
|
|
return true; |
return true; |
} |
} |
|
|
*/ |
*/ |
|
|
if (write_header) { |
if (write_header) { |
fputs (check_4_gnu_m4, to_h); |
fputs (check_4_gnu_m4, to_h); |
fputs ("m4_changecom`'m4_dnl\n", to_h); |
fputs ("m4_changecom`'m4_dnl\n", to_h); |
fputs ("m4_changequote`'m4_dnl\n", to_h); |
fputs ("m4_changequote`'m4_dnl\n", to_h); |
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); |
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_h); |
fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); |
fputs ("m4_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); |
fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", |
fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", |
to_h); |
to_h); |
fprintf (to_h, "#ifndef %sHEADER_H\n", prefix); |
fprintf (to_h, "#ifndef %sHEADER_H\n", prefix); |
|
|
|
|
} |
} |
|
|
fputs (check_4_gnu_m4, to_c); |
fputs (check_4_gnu_m4, to_c); |
fputs ("m4_changecom`'m4_dnl\n", to_c); |
fputs ("m4_changecom`'m4_dnl\n", to_c); |
fputs ("m4_changequote`'m4_dnl\n", to_c); |
fputs ("m4_changequote`'m4_dnl\n", to_c); |
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c); |
fputs ("m4_changequote([[,]])[[]]m4_dnl\n", to_c); |
|
|
fname = regmatch_dup (&m[2], buf); |
fname = regmatch_dup (&m[2], buf); |
|
|
if (strcmp (fname, |
if (strcmp (fname, |
outfilename ? outfilename : "<stdout>") |
outfilename ? outfilename : "<stdout>") == 0 || |
== 0 |
strcmp (fname, headerfilename ? headerfilename : |
|| strcmp (fname, |
"<stdout>") == 0) { |
headerfilename ? headerfilename : "<stdout>") |
|
== 0) { |
|
|
|
char *s1, *s2; |
char *s1, *s2; |
char filename[MAXLINE]; |
char filename[MAXLINE]; |
|
|
} |
} |
|
|
/* squeeze blank lines from generated code */ |
/* squeeze blank lines from generated code */ |
else if (in_gen |
else if (in_gen && |
&& regexec (®ex_blank_line, buf, 0, NULL, |
regexec (®ex_blank_line, buf, 0, NULL, 0) == 0) { |
0) == 0) { |
|
if (last_was_blank) |
if (last_was_blank) |
continue; |
continue; |
else |
else |