]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix construction of temporary names on mingw.
authorBruno Haible <bruno@clisp.org>
Fri, 14 Jul 2006 11:42:18 +0000 (11:42 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:30 +0000 (12:13 +0200)
gettext-tools/lib/ChangeLog
gettext-tools/lib/tmpdir.c

index 93ccfcf5bdbe68f604289d082383954ff4dfc5ad..2ecb2b8cedb89f83ce1dfe5019885163e9b44a27 100644 (file)
@@ -1,3 +1,11 @@
+2006-07-13  Bruno Haible  <bruno@clisp.org>
+
+       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 <sdteffen@gmail.com>.
+
 2006-07-13  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (EXTRA_DIST): Add javaversion.class.
index a007900927faec7e29766b3d156a1164ff7726f3..89818dc15c1b5510ca527ef5b53b518dd0bf7fea 100644 (file)
 # 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" */