From: Akim Demaille Date: Tue, 19 Dec 2000 13:40:42 +0000 (+0000) Subject: * src/output.c (output_parser): Compute the `#line' lines when X-Git-Tag: BISON-1_28b~52 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/ef7ddeddaaafb6b648ff04c8126cc94f8ea458b6?ds=sidebyside * src/output.c (output_parser): Compute the `#line' lines when there are. * src/Makefile.am (bison.simple): Be a simple copy of bison.s1. Suggested by Hans Aberg. --- diff --git a/ChangeLog b/ChangeLog index c19e1b94..256dac88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-12-19 Akim Demaille + + * src/output.c (output_parser): Compute the `#line' lines when + there are. + * src/Makefile.am (bison.simple): Be a simple copy of bison.s1. + Suggested by Hans Aberg. + 2000-12-19 Akim Demaille Let the handling of the skeleton files be local to the procedures diff --git a/THANKS b/THANKS index c0577e74..4c3823e6 100644 --- a/THANKS +++ b/THANKS @@ -1,5 +1,6 @@ Daniel Hagerty hag@gnu.org David J. MacKenzie djm@gnu.org +Hans Aberg haberg@matematik.su.se Jesse Thilo jthilo@gnu.org Jim Meyering meyering@gnu.org Laurent Mascherpa laurent.mascherpa@epita.fr diff --git a/src/.cvsignore b/src/.cvsignore index ade2b0da..0cb59ce8 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -4,4 +4,3 @@ ChangeLog Makefile Makefile.in bison -bison.simple diff --git a/src/Makefile.am b/src/Makefile.am index 5b28d1c2..5fe87968 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,11 +29,7 @@ data_DATA = bison.simple bison.hairy EXTRA_DIST = bison.s1 bison.hairy build.com bison.cld vmshlp.mar -bison.simple: bison.s1 Makefile - sed -e "s/@bison_version@/$(VERSION)/" $(srcdir)/bison.s1 | \ - awk '\ - /^#line/ { printf "#line %d \"$(datadir)/bison.simple\"\n", NR+1; next }\ - { print }' >$@t - mv $@t $@ +bison.simple: bison.s1 + cp $(srcdir)/bison.s1 $@ DISTCLEANFILES = bison.simple diff --git a/src/bison.s1 b/src/bison.s1 index f0418796..0117220a 100644 --- a/src/bison.s1 +++ b/src/bison.s1 @@ -1,7 +1,5 @@ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line -/* This file comes from bison-@bison_version@. */ - /* Skeleton output parser for bison, Copyright 1984, 1989, 1990, 2000 Free Software Foundation, Inc. diff --git a/src/bison.simple b/src/bison.simple index f0418796..0117220a 100644 --- a/src/bison.simple +++ b/src/bison.simple @@ -1,7 +1,5 @@ /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line -/* This file comes from bison-@bison_version@. */ - /* Skeleton output parser for bison, Copyright 1984, 1989, 1990, 2000 Free Software Foundation, Inc. diff --git a/src/output.c b/src/output.c index cf01416a..adef0433 100644 --- a/src/output.c +++ b/src/output.c @@ -1161,53 +1161,57 @@ static void output_parser (void) { int c; - static int number_of_dollar_signs = 0; FILE *fskel; + size_t line; + const char *skeleton = NULL; + int number_of_dollar_signs = 0; if (pure_parser) obstack_grow_literal_string (&table_obstack, "#define YYPURE 1\n\n"); /* Loop over lines in the standard parser file. */ if (semantic_parser) - fskel = xfopen (skeleton_find ("BISON_HAIRY", BISON_HAIRY), "r"); + skeleton = skeleton_find ("BISON_HAIRY", BISON_HAIRY); else - fskel = xfopen (skeleton_find ("BISON_SIMPLE", BISON_SIMPLE), "r"); + skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE); + fskel = xfopen (skeleton, "r"); + + /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a + decimal integer constant. This specifies that the line number of + the *following* line of input, in its original source file, was + LINENUM. */ + line = 2; while (1) { + int is_sync_line = 0; int write_line = 1; c = getc (fskel); - /* See if the line starts with `#line. - If so, set write_line to 0. */ - if (no_lines_flag) - if (c == '#') - { - c = getc (fskel); - if (c == 'l') - { - c = getc (fskel); - if (c == 'i') - { - c = getc (fskel); - if (c == 'n') - { - c = getc (fskel); - if (c == 'e') - write_line = 0; - else - obstack_grow_literal_string (&table_obstack, "#lin"); - } - else - obstack_grow_literal_string (&table_obstack, "#li"); - } - else - obstack_grow_literal_string (&table_obstack, "#l"); - } + /* See if the line starts with `#line'. */ + if (c == '#') + if ((c = getc (fskel)) == 'l') + if ((c = getc (fskel)) == 'i') + if ((c = getc (fskel)) == 'n') + if ((c = getc (fskel)) == 'e') + is_sync_line = 1; + else + obstack_grow_literal_string (&table_obstack, "#lin"); else - obstack_grow_literal_string (&table_obstack, "#"); - } + obstack_grow_literal_string (&table_obstack, "#li"); + else + obstack_grow_literal_string (&table_obstack, "#l"); + else + obstack_grow_literal_string (&table_obstack, "#"); + + /* If was a `#line' line, either compute it, or drop it. */ + if (is_sync_line && !no_lines_flag) + obstack_fgrow2 (&table_obstack, "#line %d %s\n", + line, quotearg_style (c_quoting_style, skeleton)); + + if (is_sync_line) + write_line = 0; /* now write out the line... */ for (; c != '\n' && c != EOF; c = getc (fskel)) @@ -1234,6 +1238,7 @@ output_parser (void) if (c == EOF) break; obstack_1grow (&table_obstack, c); + line++; } assert (number_of_dollar_signs == 1); xfclose (fskel);