]> granicus.if.org Git - flex/commitdiff
scanner: remove BASENAME(); don't strip path from program_name
authorExplorer09 <explorer09@gmail.com>
Tue, 18 Jul 2017 14:37:19 +0000 (22:37 +0800)
committerWill Estes <westes575@gmail.com>
Thu, 24 Aug 2017 12:34:23 +0000 (08:34 -0400)
There's no technical need of stripping path from program_name. I think
the users should be fine if they see the path they use to invoke flex
is diagnostic messages and help texts.

Yes, users will see "Usage: ../flex [OPTIONS]..." now if they invoke
flex with the path "../flex".

The --version output has been changed so that the name field will be
always "flex" or "flex++". If the flex program has been renamed to
"lex" (for compatibility or other reason) this will allow identifying
the implementation name ("flex"). (And it's a recommended practice in
GNU Coding Standards)

src/main.c
src/scanopt.c

index e3ca4407d15f033e37a0ea6d6caece7e5c563683..963d2d85054e38f5caec4882213ba1ae9e5d949f 100644 (file)
@@ -996,7 +996,7 @@ void flexinit (int argc, char **argv)
     flex_init_regex();
 
        /* Enable C++ if program name ends with '+'. */
-       program_name = BASENAME(argv[0]);
+       program_name = argv[0];
 
        if (program_name != NULL &&
            program_name[strlen (program_name) - 1] == '+')
@@ -1208,7 +1208,7 @@ void flexinit (int argc, char **argv)
                        break;
 
                case OPT_VERSION:
-                       printf (_("%s %s\n"), program_name, flex_version);
+                       printf (_("%s %s\n"), (C_plus_plus ? "flex++" : "flex"), flex_version);
                        FLEX_EXIT (0);
 
                case OPT_WARN:
index 3162e9fd62d0f72e0396e666211259dfe6bcad42..7745c11938c5f39febabfe20bcd45a8c350ddd79 100644 (file)
@@ -247,7 +247,7 @@ int     scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
                fprintf (fp, "%s\n", usage);
        }
        else {
-               fprintf (fp, _("Usage: %s [OPTIONS]...\n"), BASENAME(s->argv[0]) );
+               fprintf (fp, _("Usage: %s [OPTIONS]...\n"), s->argv[0]);
        }
        fprintf (fp, "\n");