delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2008/12/06/13:23:01

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX19/FChWNPB/YCGAuvEgR8j6NQ67Uis2x6fgPwEIt5
DVeqOz+laxb9Aj
Message-ID: <000d01c957ce$660a2470$2602a8c0@computername>
From: "Juan Manuel Guerrero" <juan DOT guerrero AT gmx DOT de>
To: <djgpp-workers AT delorie DOT com>
Subject: Two bug fixes for __get_current_directory commited
Date: Sat, 6 Dec 2008 19:13:53 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
X-Y-GMX-Trusted: 0
X-FuHaFi: 0.46
Reply-To: djgpp-workers AT delorie DOT com

OFYI:
I have checked in a patch two fix to bugs I have already reported in
<http://www.delorie.com/archives/browse.cgi?p=djgpp-workers/2008/06/23/14:51:09>
and some other occassions.

The first bug in __get_current_directory that is fixed will make sure
that paths like this:
  c:foo\bar
are no longer returned like this:
  c:\/foo/bar
The second bug fixed in __get_current_directory is that lower case
driver specifier characters will now also been recognized as valid
drive specifier characters.

Regards,
Juan M. Guerrero


2008-06-23  Juan Manuell Guerrero  <juan DOT guerrero AT gmx DOT de>

 * src/libc/posix/sys/stat/fixpath.c: If path is root path remove
 the backslash following the drive specifier.  The trailing slash is
 always added by the calling function.
 Also always allow for lower case drive specifier character in the path.

 * src/docs/kb/wc204.txi: Document changes.



Index: djgpp/src/docs/kb/wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.187
diff -U5 -r1.187 wc204.txi
--- djgpp/src/docs/kb/wc204.txi 25 Sep 2008 13:02:25 -0000 1.187
+++ djgpp/src/docs/kb/wc204.txi 6 Dec 2008 10:24:51 -0000
@@ -1156,5 +1156,12 @@
 @findex _fixpath AT r{, and no longer report ENOSYS on plain DOS}
 @findex __canonicalize_path AT r{, and no longer report ENOSYS on plain DOS}
 @code{realpath} and @code{_fixpath} will no longer report to their calling function
 @code{ENOSYS} if the used operating system (usualy plain DOS) does not provide a LFN API.
 The existance of a LFN API has no influence on the canonicalization of the path.
+
+@findex realpath AT r{, and Windows 2000/XP root directories and drive specifier character case}
+@findex _fixpath AT r{, and Windows 2000/XP root directories and drive specifier character case}
+@findex __canonicalize_path AT r{, and Windows 2000/XP root directories and drive specifier character case}
+Lower case drive specifier characters will now be recognized as valid drive specifier too.
+Relative paths that start from the root directory will be correctly canonicalized
+because the backslash following the drive specifier is now removed.
Index: djgpp/src/libc/posix/sys/stat/fixpath.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/sys/stat/fixpath.c,v
retrieving revision 1.10
diff -U5 -r1.10 fixpath.c
--- djgpp/src/libc/posix/sys/stat/fixpath.c 17 Sep 2008 06:45:50 -0000 1.10
+++ djgpp/src/libc/posix/sys/stat/fixpath.c 6 Dec 2008 10:24:52 -0000
@@ -1,5 +1,6 @@
+/* Copyright (C) 2008 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
@@ -15,10 +16,14 @@
 #include <crt0.h>  /* For crt0 flags */
 #include <dos.h>  /* For Win NT version check */
 #include <sys/stat.h>
 #include <libc/dosio.h>

+#define IS_DRIVE_SPECIFIER(path)  ((((path)[0] == (drive_number + 'A')) || ((path)[0] == (drive_number + 'a'))) && ((path)[1] ==
':'))
+#define IS_ROOT_DIR(path)         (((path)[2] == '\\') && ((path)[3] == '\0'))
+
+
 static unsigned use_lfn;

 static char *__get_current_directory(char *out, int drive_number);

 static char *
@@ -48,11 +53,11 @@
     return out;
   }
   else
   {
     dosmemget(__tb, sizeof(tmpbuf), tmpbuf);
-    strcpy(out+1,tmpbuf);
+    strcpy(out + 1, tmpbuf);

     if (*(out + 1) != '\0')
     {
       *out = '/';
       return out + strlen(out);
@@ -85,14 +90,20 @@
   if (!(r.x.flags & 1))
   {
     dosmemget(__tb + FILENAME_MAX, sizeof(tmpbuf), tmpbuf);

     /* Validate return form and drive matches what _fixpath expects. */
-    if (tmpbuf[0] == (drive_number + 'A') && tmpbuf[1] == ':')
+    if (IS_DRIVE_SPECIFIER(tmpbuf))
     {
-      strcpy(out, tmpbuf+2); /* Trim drive, just directory */
-      return out + strlen(out);
+      if (IS_ROOT_DIR(tmpbuf))
+        /* Root path, don't insert "/", it'll be added later */
+        return out;
+      else
+      {
+        strcpy(out, tmpbuf + 2);  /* Trim drive, just directory */
+        return out + strlen(out);
+      }
     }
   }
 #ifdef TEST
   else
   {
@@ -170,11 +181,11 @@
     {
       drive_number = *ip - 'A';
       if (*ip <= 'Z')
  *op++ = drive_number + 'a';
       else
- * op++ = *ip;
+ *op++ = *ip;
       ++ip;
     }
     *op++ = *ip++;
   }
   else
@@ -288,11 +299,11 @@
 #endif
     if (*op == '\\')
       *op = '/';
     if (!preserve_case && (*op == '/' || *op == '\0'))
     {
-      memcpy(long_name, name_start+1, op - name_start - 1);
+      memcpy(long_name, name_start + 1, op - name_start - 1);
       long_name[op - name_start - 1] = '\0';
       if (_is_DOS83(long_name))
       {
 #if 0
  while (++name_start < op)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019