From 2ecffc40c146978bd7a054c6c943e9ab1ae48a52 Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Mon, 8 Aug 2011 11:04:42 +0000 Subject: kpathsea: progname.c: Simplify fix_selfdir() and clarify remove_dots(). git-svn-id: svn://tug.org/texlive/trunk@23460 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/kpathsea/progname.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'Build/source/texk/kpathsea/progname.c') diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c index eccf31028a4..56d896c5907 100644 --- a/Build/source/texk/kpathsea/progname.c +++ b/Build/source/texk/kpathsea/progname.c @@ -291,13 +291,9 @@ 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 (IS_DIR_SEP_CH (p[last - 1])) { /* If we have `/../', that's the same as `/'. */ - p[(last - 1 ? last - 1 : 1)] = 0; + p[(last > 1 ? last - 1 : 1)] = 0; break; } } @@ -479,8 +475,8 @@ static inline string fix_selfdir (string dir) { #if defined(WIN32) - if (IS_DIR_SEP (*dir) && dir[1] == 0) - *dir = 0; + if (IS_DIR_SEP_CH (*dir) && dir[1] == 0) + dir++; #endif return dir; } @@ -667,10 +663,10 @@ 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_parent = xdirname (sdir); - sdir_grandparent = xdirname (sdir_parent); kpathsea_xputenv (kpse, "SELFAUTOLOC", fix_selfdir (sdir)); + sdir_parent = xdirname (sdir); kpathsea_xputenv (kpse, "SELFAUTODIR", fix_selfdir (sdir_parent)); + sdir_grandparent = xdirname (sdir_parent); kpathsea_xputenv (kpse, "SELFAUTOPARENT", fix_selfdir (sdir_grandparent)); #if defined(WIN32) || defined(__CYGWIN__) -- cgit v1.2.3