=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/lex/filter.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/lex/filter.c 2015/11/19 22:16:43 1.2 --- src/usr.bin/lex/filter.c 2015/11/19 22:25:53 1.3 *************** *** 1,4 **** ! /* $OpenBSD: filter.c,v 1.2 2015/11/19 22:16:43 tedu Exp $ */ /* filter - postprocessing of flex output through filters */ --- 1,4 ---- ! /* $OpenBSD: filter.c,v 1.3 2015/11/19 22:25:53 tedu Exp $ */ /* filter - postprocessing of flex output through filters */ *************** *** 68,76 **** /* allocate argv, and populate it with the argument list. */ max_args = 8; ! f->argv = ! (const char **) flex_alloc (sizeof (char *) * ! (max_args + 1)); if (!f->argv) flexerror (_("flex_alloc failed (f->argv) in filter_create_ext")); f->argv[f->argc++] = cmd; --- 68,74 ---- /* allocate argv, and populate it with the argument list. */ max_args = 8; ! f->argv = flex_alloc (sizeof (char *) * (max_args + 1)); if (!f->argv) flexerror (_("flex_alloc failed (f->argv) in filter_create_ext")); f->argv[f->argc++] = cmd; *************** *** 79,90 **** while ((s = va_arg (ap, const char *)) != NULL) { if (f->argc >= max_args) { max_args += 8; ! f->argv = ! (const char **) flex_realloc (f->argv, ! sizeof (char ! *) * ! (max_args + ! 1)); } f->argv[f->argc++] = s; } --- 77,84 ---- while ((s = va_arg (ap, const char *)) != NULL) { if (f->argc >= max_args) { max_args += 8; ! f->argv = flex_realloc (f->argv, ! sizeof (char *) * (max_args + 1)); } f->argv[f->argc++] = s; } *************** *** 174,184 **** * to sync the stream. This is a Hail Mary situation. It seems to work. */ close (pipes[1]); ! clearerr(stdin); if (dup2 (pipes[0], fileno (stdin)) == -1) flexfatal (_("dup2(pipes[0],0)")); close (pipes[0]); ! fseek (stdin, 0, SEEK_CUR); /* run as a filter, either internally or by exec */ if (chain->filter_func) { --- 168,178 ---- * to sync the stream. This is a Hail Mary situation. It seems to work. */ close (pipes[1]); ! clearerr(stdin); if (dup2 (pipes[0], fileno (stdin)) == -1) flexfatal (_("dup2(pipes[0],0)")); close (pipes[0]); ! fseek (stdin, 0, SEEK_CUR); /* run as a filter, either internally or by exec */ if (chain->filter_func) { *************** *** 191,198 **** else { execvp (chain->argv[0], (char **const) (chain->argv)); ! lerrsf_fatal ( _("exec of %s failed"), ! chain->argv[0]); } exit (1); --- 185,192 ---- else { execvp (chain->argv[0], (char **const) (chain->argv)); ! lerrsf_fatal ( _("exec of %s failed"), ! chain->argv[0]); } exit (1); *************** *** 203,209 **** if (dup2 (pipes[1], fileno (stdout)) == -1) flexfatal (_("dup2(pipes[1],1)")); close (pipes[1]); ! fseek (stdout, 0, SEEK_CUR); return true; } --- 197,203 ---- if (dup2 (pipes[1], fileno (stdout)) == -1) flexfatal (_("dup2(pipes[1],1)")); close (pipes[1]); ! fseek (stdout, 0, SEEK_CUR); return true; } *************** *** 269,279 **** */ if (write_header) { ! fputs (check_4_gnu_m4, 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_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); fprintf (to_h, "#ifndef %sHEADER_H\n", prefix); --- 263,273 ---- */ if (write_header) { ! fputs (check_4_gnu_m4, 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_define([[M4_YY_NOOP]])[[]]m4_dnl\n", to_h); fputs ("m4_define( [[M4_YY_IN_HEADER]],[[]])m4_dnl\n", to_h); fprintf (to_h, "#ifndef %sHEADER_H\n", prefix); *************** *** 285,291 **** } ! fputs (check_4_gnu_m4, 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); --- 279,285 ---- } ! fputs (check_4_gnu_m4, 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); *************** *** 374,384 **** fname = regmatch_dup (&m[2], buf); if (strcmp (fname, ! outfilename ? outfilename : "") ! == 0 ! || strcmp (fname, ! headerfilename ? headerfilename : "") ! == 0) { char *s1, *s2; char filename[MAXLINE]; --- 368,376 ---- fname = regmatch_dup (&m[2], buf); if (strcmp (fname, ! outfilename ? outfilename : "") == 0 || ! strcmp (fname, headerfilename ? headerfilename : ! "") == 0) { char *s1, *s2; char filename[MAXLINE]; *************** *** 414,422 **** } /* squeeze blank lines from generated code */ ! else if (in_gen ! && regexec (®ex_blank_line, buf, 0, NULL, ! 0) == 0) { if (last_was_blank) continue; else --- 406,413 ---- } /* squeeze blank lines from generated code */ ! else if (in_gen && ! regexec (®ex_blank_line, buf, 0, NULL, 0) == 0) { if (last_was_blank) continue; else