summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2007-10-10 04:32:15 +0000
committerPaul Smith <psmith@gnu.org>2007-10-10 04:32:15 +0000
commite54dfb428420943a73e3b2098dc5c694c4fdf58d (patch)
tree0979061bf1f3532b6333753e46ebc09d0a8462ac /dir.c
parent19b6504f8a92ec9db6330976dba85804e9c18d6e (diff)
downloadgunmake-e54dfb428420943a73e3b2098dc5c694c4fdf58d.tar.gz
Some Windows fixes to allow builds to succeed.
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/dir.c b/dir.c
index 7a3cdba..4f3732a 100644
--- a/dir.c
+++ b/dir.c
@@ -454,26 +454,29 @@ find_directory (const char *name)
/* The directory is not in the name hash table.
Find its device and inode numbers, and look it up by them. */
-#ifdef WINDOWS32
- /* Remove any trailing '\'. Windows32 stat fails even on valid
- directories if they end in '\'. */
- if (p[-1] == '\\')
- p[-1] = '\0';
-#endif
-
#ifdef VMS
r = vmsstat_dir (name, &st);
+#elif defined(WINDOWS32)
+ {
+ char tem[MAXPATHLEN], *tstart, *tend;
+
+ /* Remove any trailing slashes. Windows32 stat fails even on
+ valid directories if they end in a slash. */
+ memcpy (tem, name, p - name + 1);
+ tstart = tem;
+ if (tstart[1] == ':')
+ tstart += 2;
+ for (tend = tem + (p - name - 1);
+ tend > tstart && (*tend == '/' || *tend == '\\');
+ tend--)
+ *tend = '\0';
+
+ r = stat (tem, &st);
+ }
#else
EINTRLOOP (r, stat (name, &st));
#endif
-#ifdef WINDOWS32
- /* Put back the trailing '\'. If we don't, we're permanently
- truncating the value! */
- if (p[-1] == '\0')
- p[-1] = '\\';
-#endif
-
if (r < 0)
{
/* Couldn't stat the directory. Mark this by