diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-10-02 08:59:33 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2012-10-02 08:59:33 +0000 |
commit | 9309132d9b8d8ceff18e18393ae4b04f87d9e53f (patch) | |
tree | 88ede4d8489baa045e4a1a361ee340fe803b29ec /Build/source/texk | |
parent | 9dec8c56da45a8de6d74390249da6f0b8f99bcd5 (diff) |
dviljk: Reduce TL/W32TeX diffs
git-svn-id: svn://tug.org/texlive/trunk@27863 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rw-r--r-- | Build/source/texk/dviljk/ChangeLog | 6 | ||||
-rw-r--r-- | Build/source/texk/dviljk/dvi2xx.c | 50 | ||||
-rw-r--r-- | Build/source/texk/dviljk/dvi2xx.h | 1 |
3 files changed, 50 insertions, 7 deletions
diff --git a/Build/source/texk/dviljk/ChangeLog b/Build/source/texk/dviljk/ChangeLog index feaa1f8cbdd..b4f9287dcee 100644 --- a/Build/source/texk/dviljk/ChangeLog +++ b/Build/source/texk/dviljk/ChangeLog @@ -1,3 +1,9 @@ +2012-10-02 Peter Breitenlohner <peb@mppmu.mpg.de> + + * dvi2xx.c [WIN32]: Define is_dir() and handle tmp_dir + (from Akira). Use IS_DIR_SEP_CH(). + * dvi2xx.h: #include <kpathsea/c-pathch.h>. + 2012-09-07 Peter Breitenlohner <peb@mppmu.mpg.de> * dvi2xx.c: The macro max(x,y) is not the usual function, so diff --git a/Build/source/texk/dviljk/dvi2xx.c b/Build/source/texk/dviljk/dvi2xx.c index 91206b7dbe5..a19c5f2de01 100644 --- a/Build/source/texk/dviljk/dvi2xx.c +++ b/Build/source/texk/dviljk/dvi2xx.c @@ -121,6 +121,25 @@ VisChar(unsigned char c) } #endif +#ifdef WIN32 +static int is_dir(const char *buff) +{ + HANDLE h; + WIN32_FIND_DATA w32fd; + + if(((h = FindFirstFile(buff, &w32fd)) + != INVALID_HANDLE_VALUE) && + (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + FindClose(h); + return (1); + } + else { + FindClose(h); + return (0); + } +} +#endif + /**********************************************************************/ /******************************* main *******************************/ @@ -4019,19 +4038,36 @@ void DoSpecial(char *str, int n) We need to create the temporary directory only once per run; it will be deleted in AllDone(). */ if ( tmp_dir[0] == '\0' ) { - const char * base_dir; + const char * base_dir, * base_base; +#ifdef WIN32 +# define def_tmp "c:/tmp" + if ( (base_dir = getenv("TMPDIR")) == NULL && + (base_dir = getenv("TMP")) == NULL && + (base_dir = getenv("TEMP")) == NULL ) { +#else +# define def_tmp "/tmp" if ( (base_dir = getenv("TMPDIR")) == NULL ) { - base_dir = "/tmp"; +#endif + base_dir = def_tmp; } else if ( strlen(base_dir) > STRSIZE - sizeof("/dviljkXXXXXX/include.pcl") ) { - Warning ("TMPDIR %s is too long, using /tmp instead", base_dir); - base_dir = "/tmp"; + Warning ("TMPDIR %s is too long, using " def_tmp " instead", base_dir); + base_dir = def_tmp; } /* FIXME: Actually, we would need a function to sanitize base_dir here. There may still be constructs like /.. or similar. [03 Jul 07 -js] */ - if ( base_dir[0] == '/' && base_dir[1] == '\0' ) { - Warning ("Feeling naughty, do we? / is no temporary directory, dude"); - base_dir = "/tmp"; + base_base = base_dir; +#ifdef WIN32 + if ( isalnum(base_dir[0]) && base_dir[1] == ':' ) + base_base += 2; +#endif + if ( IS_DIR_SEP_CH(base_base[0]) && base_base[1] == '\0' ) { + Warning ("Feeling naughty, do we? %s is no temporary directory, dude", base_dir); + base_dir = def_tmp; } +#ifdef WIN32 + if ( !is_dir(base_dir) ) + mkdir(base_dir, 0700); +#endif strcpy (tmp_dir, base_dir); strcat (tmp_dir, "/dviljkXXXXXX"); if ( mkdtemp(tmp_dir) == NULL ) { diff --git a/Build/source/texk/dviljk/dvi2xx.h b/Build/source/texk/dviljk/dvi2xx.h index f19606a6cc0..0a06d43ceb6 100644 --- a/Build/source/texk/dviljk/dvi2xx.h +++ b/Build/source/texk/dviljk/dvi2xx.h @@ -12,6 +12,7 @@ #include <kpathsea/config.h> #include <kpathsea/c-std.h> #include <kpathsea/c-limits.h> +#include <kpathsea/c-pathch.h> #include <kpathsea/magstep.h> #include <kpathsea/proginit.h> #include <kpathsea/progname.h> |