diff options
Diffstat (limited to 'Build/source/texk/kpathsea/progname.c')
-rw-r--r-- | Build/source/texk/kpathsea/progname.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c index f73cf07d391..01f2710c7aa 100644 --- a/Build/source/texk/kpathsea/progname.c +++ b/Build/source/texk/kpathsea/progname.c @@ -724,6 +724,23 @@ kpse_set_program_name (const_string argv0, const_string progname) } #endif +/* Returns ARGV0 with any leading path and on some systems the suffix + for executables stripped off. This returns a new string. + For example, `kpse_program_basename ("/foo/bar.EXE")' returns "bar" + on WIndows or Cygwin and "bar.EXE" otherwise. */ + +string +kpse_program_basename (const_string argv0) +{ + string base = xstrdup (xbasename (argv0)); +#ifdef EXEEXT + string dot = strrchr (base, '.'); + if (dot && FILESTRCASEEQ (dot, EXEEXT)) + *dot = 0; +#endif + return base; +} + #ifdef TEST static const char *tab[] = { |