From: Bruno Haible Date: Fri, 14 Jul 2006 11:42:18 +0000 (+0000) Subject: Fix construction of temporary names on mingw. X-Git-Tag: v0.15~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8b46713af0c13b36723b160d8e0da711d04ed1d;p=thirdparty%2Fgettext.git Fix construction of temporary names on mingw. --- diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 93ccfcf5b..2ecb2b8ce 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,11 @@ +2006-07-13 Bruno Haible + + Fix construction of temporary directory names on mingw. + * tmpdir.c (ISSLASH): New macro. + (path_search): Use it, and remove also the first character if it is + a slash. + Reported by Steffen Macke . + 2006-07-13 Bruno Haible * Makefile.am (EXTRA_DIST): Add javaversion.class. diff --git a/gettext-tools/lib/tmpdir.c b/gettext-tools/lib/tmpdir.c index a00790092..89818dc15 100644 --- a/gettext-tools/lib/tmpdir.c +++ b/gettext-tools/lib/tmpdir.c @@ -73,6 +73,17 @@ # define __secure_getenv getenv #endif +/* Pathname support. + ISSLASH(C) tests whether C is a directory separator character. + */ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ + /* Win32, Cygwin, OS/2, DOS */ +# define ISSLASH(C) ((C) == '/' || (C) == '\\') +#else + /* Unix */ +# define ISSLASH(C) ((C) == '/') +#endif + /* Return nonzero if DIR is an existent directory. */ static bool @@ -131,7 +142,7 @@ path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, } dlen = strlen (dir); - while (dlen > 1 && dir[dlen - 1] == '/') + while (dlen >= 1 && ISSLASH (dir[dlen - 1])) dlen--; /* remove trailing slashes */ /* check we have room for "${dir}/${pfx}XXXXXX\0" */