diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-01 08:46:32 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-08-01 08:46:32 +0000 |
commit | 9728af2a7e87fddfa3a77ae6dc24755d3dda3e71 (patch) | |
tree | 64b82ddb79cab4231dfe15675ece3b8166d26fe2 /Build | |
parent | fb351593e88110ae50ef4977b77ef6c553258480 (diff) |
kpathsea: More changes to reduce diffs with W32TeX
git-svn-id: svn://tug.org/texlive/trunk@23300 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/kpathsea/ChangeLog | 17 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/c-pathch.h | 63 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/elt-dirs.c | 47 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/mingw32.c | 1 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/mingw32.h | 16 | ||||
-rw-r--r-- | Build/source/texk/kpathsea/progname.c | 25 |
6 files changed, 88 insertions, 81 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog index bfe6def546b..fe041db5dd4 100644 --- a/Build/source/texk/kpathsea/ChangeLog +++ b/Build/source/texk/kpathsea/ChangeLog @@ -1,3 +1,16 @@ +2011-07-31 Peter Breitenlohner <peb@mppmu.mpg.de> + + More diffs between TeX Live and W32TeX. + * c-pathch.h: IS_DIR_SEP_CH macro to be used with `slashified' + filenames without need to test for 2-Byte Kanji codes. + + * elt-dirs.c (kpathsea_normalize_path): Slashify, reformulate, + and test for 2-Byte Kanji (CP 932, SJIS) codes. + (kpathsea_element_dirs): First call kpathsea_normalize_path() + which might modify `elt' and then test for cached answer. + + * progname.c: Make sure SELFAUTO* is not just / only for WIN32. + 2011-07-30 Peter Breitenlohner <peb@mppmu.mpg.de> * dir.c (kpathsea_dir_p, dir_p), lib.h: Unconstify string parms. @@ -5,6 +18,10 @@ expand_elt): Unconstify string parms and local vars. * progname.c (kpathsea_selfdir): Don't uselessly initialize ret. + * mingw32.c: #include <kpathsea/c-pathch.h>. + * mingw32.h [IS_DIR_SEP, IS_DEVICE_SEP, IS_UNC_NAME]: Do not + duplicate them here, use definitions from c-pathch.h. + 2011-07-29 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * tilde.c [WIN32]: Use kpathsea_getpwnam(). diff --git a/Build/source/texk/kpathsea/c-pathch.h b/Build/source/texk/kpathsea/c-pathch.h index 97970f40c67..cc8b936abf8 100644 --- a/Build/source/texk/kpathsea/c-pathch.h +++ b/Build/source/texk/kpathsea/c-pathch.h @@ -24,46 +24,45 @@ /* What separates filename components? */ #ifndef DIR_SEP -#ifdef VMS -#define DIR_SEP ':' -#define DIR_SEP_STRING ":" -#else -#ifdef DOSISH +# if defined(VMS) +# define DIR_SEP ':' +# define DIR_SEP_STRING ":" +# elif defined(DOSISH) /* not VMS */ /* Either \'s or 's work. Wayne Sullivan's web2pc prefers /, so we'll go with that. */ -#define DIR_SEP '/' -#define DIR_SEP_STRING "/" -#define IS_DEVICE_SEP(ch) ((ch) == ':') -#define NAME_BEGINS_WITH_DEVICE(name) (*(name) && IS_DEVICE_SEP((name)[1])) +# define DIR_SEP '/' +# define DIR_SEP_STRING "/" +# define IS_DEVICE_SEP(ch) ((ch) == ':') +# define NAME_BEGINS_WITH_DEVICE(name) (*(name) && IS_DEVICE_SEP((name)[1])) /* On DOS, it's good to allow both \ and / between directories. */ -#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\') -/* On win32, UNC names are authorized */ -#ifdef WIN32 -#define IS_UNC_NAME(name) (strlen(name)>=3 && IS_DIR_SEP(*name) \ - && IS_DIR_SEP(*(name+1)) && isalnum(*(name+2))) -#endif -#else -#ifdef AMIGA -#define DIR_SEP '/' -#define DIR_SEP_STRING "/" -#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == ':') -#define IS_DEVICE_SEP(ch) ((ch) == ':') -#else -#ifdef VMCMS -#define DIR_SEP ' ' -#define DIR_SEP_STRING " " -#else -#define DIR_SEP '/' -#define DIR_SEP_STRING "/" -#endif /* not VM/CMS */ -#endif /* not AMIGA */ -#endif /* not DOSISH */ -#endif /* not VMS */ +# define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\') +# ifdef WIN32 +/* On win32, UNC names are authorized */ +# define IS_UNC_NAME(name) (strlen(name)>=3 && IS_DIR_SEP(*name) \ + && IS_DIR_SEP(*(name+1)) && isalnum(*(name+2))) +/* Used after converting '\\' into '/' */ +# define IS_DIR_SEP_CH(ch) ((ch) == '/') +# endif +# elif defined(AMIGA) /* not DOSISH */ +# define DIR_SEP '/' +# define DIR_SEP_STRING "/" +# define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == ':') +# define IS_DEVICE_SEP(ch) ((ch) == ':') +# elif defined(VMCMS) /* not AMIGA */ +# define DIR_SEP ' ' +# define DIR_SEP_STRING " " +# else /* not VMCMS */ +# define DIR_SEP '/' +# define DIR_SEP_STRING "/" +# endif /* not VMCMS */ #endif /* not DIR_SEP */ #ifndef IS_DIR_SEP #define IS_DIR_SEP(ch) ((ch) == DIR_SEP) #endif +#ifndef IS_DIR_SEP_CH +#define IS_DIR_SEP_CH(ch) IS_DIR_SEP(ch) +#endif #ifndef IS_DEVICE_SEP /* No `devices' on, e.g., Unix. */ #define IS_DEVICE_SEP(ch) 0 #endif diff --git a/Build/source/texk/kpathsea/elt-dirs.c b/Build/source/texk/kpathsea/elt-dirs.c index cb658207d03..2fe3139cf90 100644 --- a/Build/source/texk/kpathsea/elt-dirs.c +++ b/Build/source/texk/kpathsea/elt-dirs.c @@ -332,6 +332,10 @@ expand_elt (kpathsea kpse, str_llist_type * str_list_ptr, string elt, checked_dir_list_add (kpse, str_list_ptr, elt); } +/* On win32 we slashify ELT, i.e., change '\\' to '/', and then can use + IS_DIR_SEP_CH instead of IS_DIR_SEP and need not test for the presence + of 2-Byte Kanji (CP 932, SJIS) codes. */ + /* The first bits of a path element can be problematic because they look like a request to expand a whole disk, rather than a subtree. - It can contain a drive specification. @@ -346,8 +350,8 @@ expand_elt (kpathsea kpse, str_llist_type * str_list_ptr, string elt, handle well filenames like c://dir/foo. So canonicalize the names. The resulting name will always be shorter than the one passed, so no problem. - - If possible, we merely skip multiple leading slashes to prevent - expanding from the root of a UNIX filesystem tree. */ + - Remove multiple leading slashes to prevent expanding from the root + of a UNIX filesystem tree. */ unsigned kpathsea_normalize_path (kpathsea kpse, string elt) @@ -355,33 +359,38 @@ kpathsea_normalize_path (kpathsea kpse, string elt) unsigned ret; unsigned i; +#if defined(WIN32) + for (i = 0; elt[i]; i++) { + if (elt[i] == '\\') + elt[i] = '/'; + else if (IS_KANJI(elt + i)) + i++; + } +#endif + if (NAME_BEGINS_WITH_DEVICE(elt)) { if (*elt >= 'A' && *elt <= 'Z') *elt += 'a' - 'A'; - for (i = 2; IS_DIR_SEP(elt[i]); ++i) - ; - if (i > 3) - memmove (elt+3, elt+i, strlen(elt+i) + 1); ret = 2; } else if (IS_UNC_NAME(elt)) { - for (ret = 2; elt[ret] && !IS_DIR_SEP(elt[ret]); ++ret) - ; - for (i = ret; elt[i] && IS_DIR_SEP(elt[i]); ++i) + for (ret = 2; elt[ret] && !IS_DIR_SEP_CH(elt[ret]); ret++) ; - if (i > ret+1) - memmove (elt+ret+1, elt+i, strlen(elt+i) + 1); - } else { - for (ret = 0; IS_DIR_SEP(elt[ret]); ++ret) - ; - } + } else + ret = 0; + for (i = ret; IS_DIR_SEP_CH(elt[i]); ++i) + ; + if (i > ret + 1) { #ifdef KPSE_DEBUG - if (KPATHSEA_DEBUG_P (KPSE_DEBUG_STAT) && ret != 1) + if (KPATHSEA_DEBUG_P (KPSE_DEBUG_STAT)) DEBUGF2 ("kpse_normalize_path (%s) => %u\n", elt, ret); #endif /* KPSE_DEBUG */ + memmove (elt + ret + 1, elt + i, strlen (elt + i) + 1); + } + return ret; } @@ -399,11 +408,15 @@ str_llist_type * kpathsea_element_dirs (kpathsea kpse, string elt) { str_llist_type *ret; + unsigned i; /* If given nothing, return nothing. */ if (!elt || !*elt) return NULL; + /* Normalize ELT before looking for a cached value. */ + i = kpathsea_normalize_path (kpse, elt); + /* If we've already cached the answer for ELT, return it. */ ret = cached (kpse, elt); if (ret) @@ -414,7 +427,7 @@ kpathsea_element_dirs (kpathsea kpse, string elt) *ret = NULL; /* We handle the hard case in a subroutine. */ - expand_elt (kpse, ret, elt, kpathsea_normalize_path (kpse, elt)); + expand_elt (kpse, ret, elt, i); /* Remember the directory list we just found, in case future calls are made with the same ELT. */ diff --git a/Build/source/texk/kpathsea/mingw32.c b/Build/source/texk/kpathsea/mingw32.c index 913df2deba5..9da8d774074 100644 --- a/Build/source/texk/kpathsea/mingw32.c +++ b/Build/source/texk/kpathsea/mingw32.c @@ -26,6 +26,7 @@ #ifdef __MINGW32__ #include <kpathsea/config.h> +#include <kpathsea/c-pathch.h> #include <kpathsea/c-proto.h> #include <kpathsea/mingw32.h> #include <kpathsea/lib.h> diff --git a/Build/source/texk/kpathsea/mingw32.h b/Build/source/texk/kpathsea/mingw32.h index 7bc15cc9c56..c32312c2fce 100644 --- a/Build/source/texk/kpathsea/mingw32.h +++ b/Build/source/texk/kpathsea/mingw32.h @@ -26,22 +26,6 @@ #define MAX_PIPES 128 #endif -/* On DOS, it's good to allow both \ and / between directories. */ -#ifndef IS_DIR_SEP -#define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\') -#endif -#ifndef IS_DEVICE_SEP -#define IS_DEVICE_SEP(ch) ((ch) == ':') -#endif -#ifndef NAME_BEGINS_WITH_DEVICE -#define NAME_BEGINS_WITH_DEVICE(name) (*(name) && IS_DEVICE_SEP((name)[1])) -#endif -/* On win32, UNC names are authorized */ -#ifndef IS_UNC_NAME -#define IS_UNC_NAME(name) (strlen(name)>=3 && IS_DIR_SEP(*name) \ - && IS_DIR_SEP(*(name+1)) && isalnum(*(name+2))) -#endif - #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */ extern void init_user_info (void); diff --git a/Build/source/texk/kpathsea/progname.c b/Build/source/texk/kpathsea/progname.c index a4b1272fe34..eccf31028a4 100644 --- a/Build/source/texk/kpathsea/progname.c +++ b/Build/source/texk/kpathsea/progname.c @@ -473,21 +473,15 @@ 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. */ +/* On win32 SELFAUTO{LOC,DIR,PARENT} must not be just `/', otherwise, + e.g., $SELFAUTODIR/texmf/tex would be mistaken as UNC name. */ static inline string fix_selfdir (string dir) { #if defined(WIN32) - if (dir[strlen (dir) - 1] == '/') { -#else - if (IS_DIR_SEP (dir[strlen (dir) - 1])) { + if (IS_DIR_SEP (*dir) && dir[1] == 0) + *dir = 0; #endif - string ret = concat (dir, "."); - free (dir); - return ret; - } - return dir; } @@ -673,12 +667,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 = fix_selfdir (xdirname (sdir)); - kpathsea_xputenv (kpse, "SELFAUTODIR", sdir_parent); - sdir_grandparent = fix_selfdir (xdirname (sdir_parent)); - kpathsea_xputenv (kpse, "SELFAUTOPARENT", sdir_grandparent); + sdir_parent = xdirname (sdir); + sdir_grandparent = xdirname (sdir_parent); + kpathsea_xputenv (kpse, "SELFAUTOLOC", fix_selfdir (sdir)); + kpathsea_xputenv (kpse, "SELFAUTODIR", fix_selfdir (sdir_parent)); + kpathsea_xputenv (kpse, "SELFAUTOPARENT", fix_selfdir (sdir_grandparent)); #if defined(WIN32) || defined(__CYGWIN__) mk_suffixlist(kpse); |