OSDN Git Service

* mount.cc (mount_info::get_cygdrive_info): Fix usage of user and
authorcorinna <corinna>
Fri, 13 Jun 2008 15:22:58 +0000 (15:22 +0000)
committercorinna <corinna>
Fri, 13 Jun 2008 15:22:58 +0000 (15:22 +0000)
system arguments.  Strip trailing slash from path for backward
compatibility.

winsup/cygwin/ChangeLog
winsup/cygwin/mount.cc

index e876e54..6c1c506 100644 (file)
@@ -1,5 +1,11 @@
 2008-06-12  Corinna Vinschen  <corinna@vinschen.de>
 
+       * mount.cc (mount_info::get_cygdrive_info): Fix usage of user and
+       system arguments.  Strip trailing slash from path for backward
+       compatibility.
+
+2008-06-12  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler.h (set_console_state_for_spawn): Drop declaration.
        * fhandler_console.cc (set_console_state_for_spawn): Remove.
        (fhandler_console::open): Set console state last.  Don't set
index 1c11d86..3d1a8cb 100644 (file)
@@ -1027,22 +1027,30 @@ mount_info::write_cygdrive_info (const char *cygdrive_prefix, unsigned flags)
 }
 
 int
-mount_info::get_cygdrive_info (char *user, char *system, charuser_flags,
-                              charsystem_flags)
+mount_info::get_cygdrive_info (char *user, char *system, char *user_flags,
+                              char *system_flags)
 {
   if (user)
     *user = '\0';
-  /* Get the user flags, if appropriate */
+  if (system)
+    *system = '\0';
   if (user_flags)
     *user_flags = '\0';
-
-  if (system)
-    strcpy (system, cygdrive);
-
   if (system_flags)
-    strcpy (system_flags,
-           (cygdrive_flags & MOUNT_BINARY) ? "binmode" : "textmode");
+    *system_flags = '\0';
 
+  char *path = (cygdrive_flags & MOUNT_SYSTEM) ? system : user;
+  char *flags = (cygdrive_flags & MOUNT_SYSTEM) ? system_flags : user_flags;
+
+  if (path)
+    {
+      strcpy (path, cygdrive);
+      /* Strip trailing slash for backward compatibility. */
+      if (cygdrive_len > 2)
+        path[cygdrive_len - 1] = '\0';
+    }
+  if (flags)
+    strcpy (flags, (cygdrive_flags & MOUNT_BINARY) ? "binmode" : "textmode");
   return 0;
 }