bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

--update: when used, do not generate the output files


From: Akim Demaille
Subject: --update: when used, do not generate the output files
Date: Tue, 22 Jan 2019 06:55:14 +0100

commit 8f7cf7e7e24e984334dcce56a3e8fdd5d827f217
Author: Akim Demaille <address@hidden>
Date:   Mon Jan 21 19:37:10 2019 +0100

    --update: when used, do not generate the output files
    
    It is inconvenient that we also generate the output files when we
    update the grammar file, and it's somewhat unexpected.  Let's not do
    that.
    
    * src/main.c (main): Skip generation when --update is passed.
    * src/getargs.c (usage): Update the help message.
    * doc/bison.texi (Bison Options): Likewise.
    * tests/input.at: Check that we don't generate the output.

diff --git a/doc/bison.texi b/doc/bison.texi
index c31e851b..884a7bd8 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -10272,8 +10272,8 @@ Print the name of the directory containing skeletons 
and XSLT.
 @item -u
 @item --update
 Update the grammar file (remove duplicates, update deprecated directives,
-etc.).  Leaves a backup of the original file with a @code{~} appended.  For
-instance:
+etc.) and exit (i.e., do not generate any of the output files).  Leaves a
+backup of the original file with a @code{~} appended.  For instance:
 
 @example
 @group
diff --git a/src/getargs.c b/src/getargs.c
index a66e4c66..95572681 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -287,7 +287,7 @@ Operation modes:\n\
                              and exit\n\
       --print-datadir        output directory containing skeletons and XSLT\n\
                              and exit\n\
-  -u, --update               apply fixes to the source grammar file\n\
+  -u, --update               apply fixes to the source grammar file and exit\n\
   -y, --yacc                 emulate POSIX Yacc\n\
   -W, --warnings[=CATEGORY]  report the warnings falling in CATEGORY\n\
   -f, --feature[=FEATURE]    activate miscellaneous features\n\
diff --git a/src/main.c b/src/main.c
index 10a07d2e..0fbbca05 100644
--- a/src/main.c
+++ b/src/main.c
@@ -155,6 +155,8 @@ main (int argc, char *argv[])
 
   print_precedence_warnings ();
 
+  if (!update_flag)
+    {
       /* Output file names. */
       compute_output_file_names ();
 
@@ -181,6 +183,7 @@ main (int argc, char *argv[])
           print_xml ();
           timevar_pop (tv_xml);
         }
+    }
 
   /* Stop if there were errors, to avoid trashing previous output
      files.  */
@@ -193,9 +196,12 @@ main (int argc, char *argv[])
   timevar_pop (tv_free);
 
   /* Output the tables and the parser to ftable.  In file output.  */
+  if (!update_flag)
+    {
       timevar_push (tv_parser);
       output ();
       timevar_pop (tv_parser);
+    }
 
   timevar_push (tv_free);
   nullable_free ();
diff --git a/tests/input.at b/tests/input.at
index 0fa593d6..e0fe8830 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -2507,7 +2507,7 @@ AT_DATA_GRAMMAR([[input.y]],
 %no-default_prec
 %no_default-prec
 %no_lines
-%output = "foo"
+%output = "output.c"
 %pure_parser
 %token_table
 %error-verbose
@@ -2566,7 +2566,9 @@ AT_BISON_CHECK([[-ffixit input.y]], [], [], [experr])
 AT_CHECK([[sed -e '/^fix-it:/d' errors-all >experr]])
 AT_BISON_CHECK([[input.y]], [], [], [experr])
 
-# Update the input file.
+
+# Update the input file.  Make sure we generated nothing.
+AT_CHECK([rm -f output.c])
 AT_CHECK([cp input.y input.y.orig])
 AT_CHECK([sed -e '/fix-it/d' <errors-all >experr])
 AT_CHECK([echo "bison: file 'input.y' was updated (backup: 'input.y~')" 
>>experr])
@@ -2575,6 +2577,9 @@ AT_BISON_CHECK([[--update input.y]], [], [[]], [experr])
 # Check the backup.
 AT_CHECK([diff input.y.orig input.y~])
 
+# Check we did not generate any file.
+AT_CHECK([test ! -f output.c])
+
 # Check the update.
 AT_CHECK([cat input.y], [],
 [[%code top {
@@ -2595,7 +2600,7 @@ AT_CHECK([cat input.y], [],
 %no-default-prec
 %no-default-prec
 %no-lines
-%output "foo"
+%output "output.c"
 %pure-parser
 %token-table
 %glr-parser




reply via email to

[Prev in Thread] Current Thread [Next in Thread]