From fb731ac0221e1866534dfe072b84b8af7a5d88f3 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Tue, 18 Jul 2017 22:37:19 +0800 Subject: scanner: remove BASENAME(); don't strip path from program_name 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 | 4 ++-- src/scanopt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index e3ca440..963d2d8 100644 --- a/src/main.c +++ b/src/main.c @@ -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: diff --git a/src/scanopt.c b/src/scanopt.c index 3162e9f..7745c11 100644 --- a/src/scanopt.c +++ b/src/scanopt.c @@ -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"); -- cgit v1.2.3