diff options
author | Michael Reed <m.reed@mykolab.com> | 2015-12-25 14:39:18 -0500 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2015-12-27 13:39:09 -0500 |
commit | 0e00f445a91ea30e1d8fce8e89bef71a829b9588 (patch) | |
tree | 2ca13d6bba5362e36e87334564412fb34ef2e6ad /src | |
parent | 6fa7ed0446e02aaeb81b712325bbf1a3636feb18 (diff) |
Simplify basename2().
It's only call site does not activate the `strip_ext` code path, so the
function can be simplified a lot. While here, remove a double
assignment.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -44,7 +44,7 @@ static char flex_version[] = FLEX_VERSION; void flexinit(int, char **); void readin(void); void set_up_initial_allocations(void); -static char *basename2(char *path, int should_strip_ext); +static char *basename2(char *path); /* these globals are all defined and commented in flexdef.h */ @@ -1000,7 +1000,7 @@ void flexinit (int argc, char **argv) flex_init_regex(); /* Enable C++ if program name ends with '+'. */ - program_name = basename2 (argv[0], 0); + program_name = basename2 (argv[0]); if (program_name[0] != '\0' && program_name[strlen (program_name) - 1] == '+') @@ -1793,19 +1793,13 @@ void set_up_initial_allocations (void) /* extracts basename from path, optionally stripping the extension "\.*" * (same concept as /bin/sh `basename`, but different handling of extension). */ -static char *basename2 (char *path, int /* boolean */ strip_ext) +static char *basename2 (char *path) { - char *b, *e = 0; + char *b; - b = path; for (b = path; *path; path++) if (*path == '/') b = path + 1; - else if (*path == '.') - e = path; - - if (strip_ext && e && e > b) - *e = '\0'; return b; } |