diff options
Diffstat (limited to 'Build/source/texk/kpathsea/progname.c')
-rw-r--r-- | Build/source/texk/kpathsea/progname.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c index 8f84bed7004..9313ccbabb0 100644 --- a/Build/source/texk/kpathsea/progname.c +++ b/Build/source/texk/kpathsea/progname.c @@ -291,7 +291,11 @@ remove_dots (kpathsea kpse, string dir) unsigned last; string p = NAME_BEGINS_WITH_DEVICE (ret) ? ret + 2 : ret; for (last = strlen (p); last > 0; last--) { +#if defined(WIN32) + if (p[last - 1] == '/') { +#else if (IS_DIR_SEP (p[last - 1])) { +#endif /* If we have `/../', that's the same as `/'. */ p[(last - 1 ? last - 1 : 1)] = 0; break; @@ -469,6 +473,24 @@ mk_suffixlist (kpathsea kpse) } #endif /* WIN32 || __CYGWIN__ */ +/* Append a dot if SELFAUTO{LOC,DIR,PARENT} is just `/'. Otherwise, + e.g., $SELFAUTODIR/texmf would search the entire filesystem. */ +static inline string +fix_selfdir (string dir) +{ +#if defined(WIN32) + if (dir[strlen (dir) - 1] == '/') { +#else + if (IS_DIR_SEP (dir[strlen (dir) - 1])) { +#endif + string ret = concat (dir, "."); + free (dir); + return ret; + } + + return dir; +} + void kpathsea_set_program_name (kpathsea kpse, const_string argv0, const_string progname) @@ -651,10 +673,11 @@ kpathsea_set_program_name (kpathsea kpse, const_string argv0, #endif /* SELFAUTODIR is actually the parent of the invocation directory, and SELFAUTOPARENT the grandparent. This is how teTeX did it. */ + sdir = fix_selfdir (sdir); kpathsea_xputenv (kpse, "SELFAUTOLOC", sdir); - sdir_parent = xdirname (sdir); + sdir_parent = fix_selfdir (xdirname (sdir)); kpathsea_xputenv (kpse, "SELFAUTODIR", sdir_parent); - sdir_grandparent = xdirname (sdir_parent); + sdir_grandparent = fix_selfdir (xdirname (sdir_parent)); kpathsea_xputenv (kpse, "SELFAUTOPARENT", sdir_grandparent); #if defined(WIN32) || defined(__CYGWIN__) |