]> granicus.if.org Git - flex/commitdiff
scanner: add optionn to specify backup filename.
authorEricSharkey <eric@lisaneric.org>
Sun, 21 May 2017 20:09:42 +0000 (16:09 -0400)
committerWill Estes <westes575@gmail.com>
Mon, 3 Jul 2017 13:41:42 +0000 (09:41 -0400)
In a directory containing multiple scanners, we want to allow
specifying the name of the backup file else the backup files will be
overwritten.

src/main.c
src/options.c
src/options.h

index 337c40d2920275c679799315c082ca684f7cf549..1f12cba990ae0bab874ebe3471cf502e67cfcfca 100644 (file)
@@ -117,7 +117,7 @@ struct yytbl_writer tableswr;
 char   *program_name = "flex";
 
 static const char outfile_template[] = "lex.%s.%s";
-static const char backing_name[] = "lex.backup";
+static const char *backing_name = "lex.backup";
 static const char tablesfile_template[] = "lex.%s.tables";
 
 /* From scan.l */
@@ -1035,6 +1035,11 @@ void flexinit (int argc, char **argv)
                        backing_up_report = true;
                        break;
 
+               case OPT_BACKUP_FILE:
+                       backing_up_report = true;
+                        backing_name = arg;
+                       break;
+
                case OPT_DONOTHING:
                        break;
 
@@ -1827,7 +1832,8 @@ void usage (void)
                  "  -t, --stdout            write scanner on stdout instead of %s\n"
                  "      --yyclass=NAME      name of C++ class\n"
                  "      --header-file=FILE   create a C header file in addition to the scanner\n"
-                 "      --tables-file[=FILE] write tables to FILE\n" "\n"
+                 "      --tables-file[=FILE] write tables to FILE\n"
+                 "      --backup-file=FILE  write backing-up information to FILE\n" "\n"
                  "Scanner behavior:\n"
                  "  -7, --7bit              generate 7-bit scanner\n"
                  "  -8, --8bit              generate 8-bit scanner\n"
index 8e42adbdfd9d37b7630094d55d0c90659b91c01a..e98159c4cefd55b3ce43892c43885c693b4a1fa9 100644 (file)
@@ -62,6 +62,8 @@ optspec_t flexopts[] = {
        ,
        {"--backup", OPT_BACKUP, 0}
        ,                       /* Generate backing-up information to lex.backup. */
+       {"--backup-file=FILE", OPT_BACKUP_FILE, 0}
+       ,                       /* Generate backing-up information to FILE. */
        {"-B", OPT_BATCH, 0}
        ,
        {"--batch", OPT_BATCH, 0}
index 5016680fd134008ae3f957d370ad4effdc7ba839..acee2753a78785676042f024945222704e79214a 100644 (file)
@@ -46,6 +46,7 @@ enum flexopt_flag_t {
        OPT_ALWAYS_INTERACTIVE,
        OPT_ARRAY,
        OPT_BACKUP,
+       OPT_BACKUP_FILE,
        OPT_BATCH,
         OPT_BISON_BRIDGE,
         OPT_BISON_BRIDGE_LOCATIONS,