diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-06-24 09:37:07 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2013-06-24 09:37:07 +0000 |
commit | d8ee324e03e46ef3361a8ade3062034bc45795af (patch) | |
tree | 16db0d512972def0afb897cf289ac8ff65a6b389 /Build/source/texk/kpathsea/progname.c | |
parent | 151106e752f349fac3ef91258cdf305c1cd6dc79 (diff) |
kpathsea 6.2.0dev
git-svn-id: svn://tug.org/texlive/trunk@30892 c570f23f-e606-0410-a88d-b1316a301751
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[] = { |