]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
collect2.c (find_a_file): Use HAVE_DOS_BASED_FILE_SYSTEM in place of the DIR_SEPARATO...
authorMark Elbrecht <snowball3@usa.net>
Sat, 10 Apr 1999 04:27:16 +0000 (04:27 +0000)
committerJeff Law <law@gcc.gnu.org>
Sat, 10 Apr 1999 04:27:16 +0000 (22:27 -0600)
        * collect2.c (find_a_file): Use HAVE_DOS_BASED_FILE_SYSTEM in place
        of the DIR_SEPARATOR test.
        Consider any file starting with a drivename to be absolute.
        If the absolute filename test fails and EXECUTABLE_SUFFIX is
        defined, append EXECUTABLE_SUFFIX to the file and try again.
        * cppinit.c (base_name): Use HAVE_DOS_BASED_FILE_SYSTEM
        in place of __MSDOS__ and _WIN32.
        * cppfiles.c (simplify_pathname): Likewise.
        * gcc.c (IS_DIR_SEPARATOR): Define new macro. Returns true if a
        character is a directory separator.
        (find_a_file): Use it.
        (convert_filename): Likewise.
        (process_command): Likewise.
        (do_spec_1): Likewise.
        (is_directory): Likewise.
        (main): Likewise.
        * prefix.c (IS_DIR_SEPARATOR): Define. Tests whether a character is
        a directory separator.
        (translate_name): Use it.
        (update_path): Change DIR_SEPARATOR_2 to DIR_SEPARATOR. Fix
        warning in block where '/' is changed to DIR_SEPARATOR.
        * i386/xm-djgpp.h (DIR_SEPARATOR): Set to '/'.
        (DIR_SEPARATOR_2): New macro. Set to '\'.
        (HAVE_DOS_BASED_FILESYS): Define.
        * i386/xm-mingw32.h: Updated copyright. Set
        DIR_SEPARATOR_2 to '/'. Define HAVE_DOS_BASED_FILE_SYSTEM.
        * i386/xm-os2.h: Likewise.
        * winnt/xm-winnt.h: Likewise.
        * i386/xm-dos.h: Likewise.  Add copyright.

From-SVN: r26328

gcc/ChangeLog
gcc/collect2.c
gcc/config/i386/xm-djgpp.h
gcc/config/i386/xm-dos.h
gcc/config/i386/xm-mingw32.h
gcc/config/i386/xm-os2.h
gcc/config/winnt/xm-winnt.h
gcc/cppfiles.c
gcc/cppinit.c
gcc/gcc.c
gcc/prefix.c

index fd8f5d7a3e08977b4e167f57fa890202a6d47ef0..0022e4a886297ebe245d5e1395bbeb1763629c50 100644 (file)
@@ -1,3 +1,35 @@
+Sat Apr 10 05:14:50 1999  Mark Elbrecht  <snowball3@usa.net>
+
+       * collect2.c (find_a_file): Use HAVE_DOS_BASED_FILE_SYSTEM in place
+       of the DIR_SEPARATOR test.
+       Consider any file starting with a drivename to be absolute.
+       If the absolute filename test fails and EXECUTABLE_SUFFIX is 
+       defined, append EXECUTABLE_SUFFIX to the file and try again.
+       * cppinit.c (base_name): Use HAVE_DOS_BASED_FILE_SYSTEM 
+       in place of __MSDOS__ and _WIN32.
+       * cppfiles.c (simplify_pathname): Likewise.
+       * gcc.c (IS_DIR_SEPARATOR): Define new macro. Returns true if a
+       character is a directory separator.
+       (find_a_file): Use it.
+       (convert_filename): Likewise.
+       (process_command): Likewise.
+       (do_spec_1): Likewise.
+       (is_directory): Likewise.
+       (main): Likewise.
+       * prefix.c (IS_DIR_SEPARATOR): Define. Tests whether a character is
+       a directory separator.
+       (translate_name): Use it.
+       (update_path): Change DIR_SEPARATOR_2 to DIR_SEPARATOR. Fix 
+       warning in block where '/' is changed to DIR_SEPARATOR.
+       * i386/xm-djgpp.h (DIR_SEPARATOR): Set to '/'.
+       (DIR_SEPARATOR_2): New macro. Set to '\'.
+       (HAVE_DOS_BASED_FILESYS): Define.
+       * i386/xm-mingw32.h: Updated copyright. Set 
+       DIR_SEPARATOR_2 to '/'. Define HAVE_DOS_BASED_FILE_SYSTEM.
+       * i386/xm-os2.h: Likewise.
+       * winnt/xm-winnt.h: Likewise.
+       * i386/xm-dos.h: Likewise.  Add copyright.
+
 1999-04-10  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * pdp11.h (TARGET_SWITCHES): Add option to vary assembler syntax.
index 2f31d94138bd82ec8de67b0b22e368b2f2ed3f5e..95a99a70e8b462c7cde5501324b0a1ffa9e4040d 100644 (file)
@@ -823,9 +823,8 @@ find_a_file (pprefix, name)
   /* Determine the filename to execute (special case for absolute paths).  */
 
   if (*name == '/'
-#ifdef DIR_SEPARATOR
-      || (DIR_SEPARATOR == '\\' && name[1] == ':'
-      && (name[2] == DIR_SEPARATOR || name[2] == '/'))
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+      || (*name && name[1] == ':')
 #endif
       )
     {
@@ -839,6 +838,16 @@ find_a_file (pprefix, name)
          return temp;
        }
 
+#ifdef EXECUTABLE_SUFFIX
+       /* Some systems have a suffix for executable files.
+          So try appending that.  */
+      strcpy (temp, name);
+       strcat (temp, EXECUTABLE_SUFFIX);
+       
+       if (access (temp, X_OK) == 0)
+         return temp;
+#endif
+
       if (debug)
        fprintf (stderr, "  - failed to locate using absolute path\n");
     }
index de91855f2e70e064208f4f9c63664c1f2d9a561f..50034fd071d5d8d33562c95ae0895bab307573c0 100644 (file)
@@ -28,7 +28,11 @@ Boston, MA 02111-1307, USA.  */
 #define EXECUTABLE_SUFFIX ".exe"
 
 /* Even though we support "/", allow "\" since everybody tests both.  */
-#define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_2 '\\'
+
+/* Allow test for DOS drive names.  */
+#define HAVE_DOS_BASED_FILESYSTEM
 
 #define NO_SYS_SIGLIST 1
 
index a734a81b94eb315184e7e3291022cf949c197fd6..4e1cb42c8c1138aed5a5171a1d32339d5c494881 100644 (file)
@@ -1,3 +1,23 @@
+/* Configuration for GNU C-compiler for Intel 80386 running DOS.
+   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
 #include "i386/xm-i386.h"
 
 /* Use semicolons to separate elements of a path.  */
@@ -5,6 +25,10 @@
 
 /* Use backslashs to separate levels of directory.  */
 #define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_2 '/'
+
+/* Allow checks for drive names. */
+#define HAVE_DOS_BASED_FILE_SYSTEM
 
 /* Suffix for executable file names.  */
 #define EXECUTABLE_SUFFIX ".exe"
index d818142d9e52da40c75a1894befe7ac1071bb0d2..6872580f33e444ebfa25e2cd4fcee2d15b906d73 100644 (file)
@@ -1,6 +1,6 @@
 /* Configuration for GNU C-compiler for hosting on Windows32.
    using GNU tools and the Windows32 API Library.
-   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -36,6 +36,12 @@ Boston, MA 02111-1307, USA. */
 
 /* Even though we support "/", allow "\" since everybody tests both.  */
 #define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_2 '/'
+
+/* Mingw32 does not try to hide the underlying DOS-based file system
+   like Cygwin does.  */
+#define HAVE_DOS_BASED_FILE_SYSTEM
+
 #define EXECUTABLE_SUFFIX ".exe"
 
 #undef PATH_SEPARATOR
index aed925e993c58ffb2bdd9a7a5fb333f157efe17c..b8a5ad057a3a08072368c8481dff2ec9ec105afe 100644 (file)
@@ -1,6 +1,6 @@
 /* Configuration for GNU compiler
    for an Intel i386 or later processor running OS/2 2.x.
-   Copyright (C) 1993, 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
    Contributed by Samuel Figueroa (figueroa@apple.com)
 
 This file is part of GNU CC.
@@ -54,6 +54,12 @@ int spawnvp (int modeflag, char *path, char *argv[]);
 #ifndef DIR_SEPARATOR
 #define DIR_SEPARATOR '\\'
 #endif
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '/'
+#endif
+
+/* Allow handling of drive names. */
+#define HAVE_DOS_BASED_FILE_SYSTEM
 
 #define EXECUTABLE_SUFFIX ".exe"
 
index f56073cb8de8c4cf1c6560807decfa05e9ed08a2..0bf8f87d62dddaaa5070f5cbc05c110efee01d28 100644 (file)
@@ -1,5 +1,5 @@
 /* Configuration for GNU compiler for processor running Windows NT 3.x.
-   Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 1997, 1999 Free Software Foundation, Inc.
    Contributed by Douglas B. Rupp (drupp@cs.washington.edu)
 
 This file is part of GNU CC.
@@ -47,7 +47,12 @@ Boston, MA 02111-1307, USA.  */
 #define OBJECT_SUFFIX ".obj"
 #define EXECUTABLE_SUFFIX ".exe"
 #define PATH_SEPARATOR ';'
+
 #define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_2 '/'
+
+/* Allows checks for drive names.  */
+#define HAVE_DOS_BASED_FILE_SYSTEM
 
 #define S_IRUSR 0000400
 #define S_IWUSR 0000200
index 4c64b9be69fd19f13201a913aacfa454dffb9b99..6fd240787fdecbfa4c44faf6037225692b23df01 100644 (file)
@@ -1168,7 +1168,7 @@ simplify_pathname (path)
     char *base;
     int absolute = 0;
 
-#if defined _WIN32 || defined __MSDOS__
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
     /* Convert all backslashes to slashes. */
     for (from = path; *from; from++)
        if (*from == '\\') *from = '/';
index 0c151434fdaaed709e73def4bf299d87af8e7550..73008008357f997bd7d2ed4c484e5592bfbcb148 100644 (file)
@@ -430,7 +430,7 @@ base_name (fname)
 {
   char *s = (char *)fname;
   char *p;
-#if defined (__MSDOS__) || defined (_WIN32)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
   if (ISALPHA (s[0]) && s[1] == ':') s += 2;
   if ((p = rindex (s, '\\'))) s = p + 1;
 #elif defined VMS
index dc321422488e08216fb21b64eb64cbc360c0f25c..f3bb55d1e4278434b22721a3717080cff3c64655 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -66,6 +66,14 @@ compilation is specified by a string called a "spec".  */
 #define DIR_SEPARATOR '/'
 #endif
 
+/* Define IS_DIR_SEPARATOR.  */
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+       (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
 static char dir_separator_str[] = {DIR_SEPARATOR, 0};
 
 #define obstack_chunk_alloc xmalloc
@@ -1991,10 +1999,12 @@ find_a_file (pprefix, name, mode)
 
   /* Determine the filename to execute (special case for absolute paths).  */
 
-  if (*name == '/' || *name == DIR_SEPARATOR
+  if (IS_DIR_SEPARATOR (*name)
+#ifdef HAVE_DOS_BASED_FILESYSTEM
       /* Check for disk name on MS-DOS-based systems.  */
-      || (DIR_SEPARATOR == '\\' && name[1] == ':'
-         && (name[2] == DIR_SEPARATOR || name[2] == '/')))
+      || (name[0] && name[1] == ':' && IS_DIR_SEPARATOR (name[2]))
+#endif
+      )
     {
       if (access (name, mode) == 0)
        {
@@ -2434,7 +2444,7 @@ convert_filename (name, do_exe)
     return name;
 
   for (i = len - 1; i >= 0; i--)
-    if (name[i] == '/' || name[i] == DIR_SEPARATOR)
+    if (IS_DIR_SEPARATOR (name[i]))
       break;
 
   for (i++; i < len; i++)
@@ -2597,13 +2607,12 @@ process_command (argc, argv)
     {
       int len = strlen (gcc_exec_prefix);
       if (len > (int) sizeof ("/lib/gcc-lib/")-1
-         && (gcc_exec_prefix[len-1] == '/'
-             || gcc_exec_prefix[len-1] == DIR_SEPARATOR))
+         && (IS_DIR_SEPARATOR (gcc_exec_prefix[len-1])))
        {
          temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1;
-         if ((*temp == '/' || *temp == DIR_SEPARATOR)
+         if (IS_DIR_SEPARATOR (*temp)
              && strncmp (temp+1, "lib", 3) == 0
-             && (temp[4] == '/' || temp[4] == DIR_SEPARATOR)
+             && IS_DIR_SEPARATOR (temp[4])
              && strncmp (temp+5, "gcc-lib", 7) == 0)
            len -= sizeof ("/lib/gcc-lib/") - 1;
        }
@@ -2630,7 +2639,7 @@ process_command (argc, argv)
              strncpy (nstore, startp, endp-startp);
              if (endp == startp)
                strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
-             else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
+             else if (!IS_DIR_SEPARATOR (endp[-1]))
                {
                  nstore[endp-startp] = DIR_SEPARATOR;
                  nstore[endp-startp+1] = 0;
@@ -2664,7 +2673,7 @@ process_command (argc, argv)
              strncpy (nstore, startp, endp-startp);
              if (endp == startp)
                strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
-             else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
+             else if (!IS_DIR_SEPARATOR (endp[-1]))
                {
                  nstore[endp-startp] = DIR_SEPARATOR;
                  nstore[endp-startp+1] = 0;
@@ -2697,7 +2706,7 @@ process_command (argc, argv)
              strncpy (nstore, startp, endp-startp);
              if (endp == startp)
                strcpy (nstore, concat (".", dir_separator_str, NULL_PTR));
-             else if (endp[-1] != '/' && endp[-1] != DIR_SEPARATOR)
+             else if (!IS_DIR_SEPARATOR (endp[-1]))
                {
                  nstore[endp-startp] = DIR_SEPARATOR;
                  nstore[endp-startp+1] = 0;
@@ -2902,12 +2911,10 @@ process_command (argc, argv)
                  int len = strlen (value);
                  if ((len == 7
                       || (len > 7
-                          && (value[len - 8] == '/'
-                              || value[len - 8] == DIR_SEPARATOR)))
+                          && (IS_DIR_SEPARATOR (value[len - 8]))))
                      && strncmp (value + len - 7, "stage", 5) == 0
                      && ISDIGIT (value[len - 2])
-                     && (value[len - 1] == '/'
-                         || value[len - 1] == DIR_SEPARATOR))
+                     && (IS_DIR_SEPARATOR (value[len - 1])))
                    {
                      if (len == 7)
                        add_prefix (&include_prefixes, "include", NULL_PTR,
@@ -3074,7 +3081,7 @@ process_command (argc, argv)
      directories, so that we can search both the user specified directory
      and the standard place.  */
 
-  if (*tooldir_prefix != '/' && *tooldir_prefix != DIR_SEPARATOR)
+  if (!IS_DIR_SEPARATOR (*tooldir_prefix))
     {
       if (gcc_exec_prefix)
        {
@@ -3525,7 +3532,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
                  /* Relative directories always come from -B,
                     and it is better not to use them for searching
                     at run time.  In particular, stage1 loses  */
-                 if (pl->prefix[0] != '/' && pl->prefix[0] != DIR_SEPARATOR)
+                 if (!IS_DIR_SEPARATOR (pl->prefix[0]))
                    continue;
 #endif
                  /* Try subdirectory if there is one.  */
@@ -3582,8 +3589,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
                          buffer = (char *) xrealloc (buffer, bufsize);
                          strcpy (buffer, machine_suffix);
                          idx = strlen (buffer);
-                         if (buffer[idx - 1] == '/'
-                             || buffer[idx - 1] == DIR_SEPARATOR)
+                         if (IS_DIR_SEPARATOR (buffer[idx - 1]))
                            buffer[idx - 1] = 0;
                          do_spec_1 (buffer, 1, NULL_PTR);
                          /* Make this a separate argument.  */
@@ -3604,8 +3610,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
                          buffer = (char *) xrealloc (buffer, bufsize);
                          strcpy (buffer, pl->prefix);
                          idx = strlen (buffer);
-                         if (buffer[idx - 1] == '/'
-                             || buffer[idx - 1] == DIR_SEPARATOR)
+                         if (IS_DIR_SEPARATOR (buffer[idx - 1]))
                            buffer[idx - 1] = 0;
                          do_spec_1 (buffer, 1, NULL_PTR);
                          /* Make this a separate argument.  */
@@ -4598,7 +4603,7 @@ is_directory (path1, path2, linker)
   memcpy (path, path1, len1);
   memcpy (path + len1, path2, len2);
   cp = path + len1 + len2;
-  if (cp[-1] != '/' && cp[-1] != DIR_SEPARATOR)
+  if (!IS_DIR_SEPARATOR (cp[-1]))
     *cp++ = DIR_SEPARATOR;
   *cp++ = '.';
   *cp = '\0';
@@ -4646,7 +4651,8 @@ main (argc, argv)
   struct user_specs *uptr;
 
   p = argv[0] + strlen (argv[0]);
-  while (p != argv[0] && p[-1] != '/' && p[-1] != DIR_SEPARATOR) --p;
+  while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
+    --p;
   programname = p;
 
 #ifdef HAVE_LC_MESSAGES
@@ -4848,14 +4854,12 @@ main (argc, argv)
         standard_exec_prefix.  This lets us move the installed tree
         as a unit.  If GCC_EXEC_PREFIX is defined, base
         standard_startfile_prefix on that as well.  */
-      if (*standard_startfile_prefix == '/'
-         || *standard_startfile_prefix == DIR_SEPARATOR
-         || *standard_startfile_prefix == '$'
-#ifdef __MSDOS__
-         /* Check for disk name on MS-DOS-based systems.  */
+      if (IS_DIR_SEPARATOR (*standard_startfile_prefix)
+           || *standard_startfile_prefix == '$'
+#ifdef HAVE_DOS_BASED_FILESYSTEM
+           /* Check for disk name on MS-DOS-based systems.  */
           || (standard_startfile_prefix[1] == ':'
-             && (standard_startfile_prefix[2] == DIR_SEPARATOR
-                 || standard_startfile_prefix[2] == '/'))
+             && (IS_DIR_SEPARATOR (standard_startfile_prefix[2])))
 #endif
          )
        add_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS",
@@ -4884,7 +4888,7 @@ main (argc, argv)
     }
   else
     {
-      if (*standard_startfile_prefix != DIR_SEPARATOR && gcc_exec_prefix)
+      if (!IS_DIR_SEPARATOR (*standard_startfile_prefix) && gcc_exec_prefix)
        add_prefix (&startfile_prefixes,
                    concat (gcc_exec_prefix, machine_suffix,
                            standard_startfile_prefix, NULL_PTR),
@@ -5046,7 +5050,7 @@ main (argc, argv)
 
          input_basename = input_filename;
          for (p = input_filename; *p; p++)
-           if (*p == '/' || *p == DIR_SEPARATOR)
+           if (IS_DIR_SEPARATOR (*p))
              input_basename = p + 1;
 
          /* Find a suffix starting with the last period,
index e5ca9239410eea29e97edac2f3930219481b4498..8bf5696f07fa07df86ed72c061bc6c966009aac8 100644 (file)
@@ -81,6 +81,17 @@ static char *lookup_key              PROTO((char *));
 static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
 #endif
 
+#ifndef DIR_SEPARATOR
+# define IS_DIR_SEPARATOR(ch) ((ch) == '/')
+#else /* DIR_SEPARATOR */
+# ifndef DIR_SEPARATOR_2
+#  define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+# else /* DIR_SEPARATOR && DIR_SEPARATOR_2 */
+#  define IS_DIR_SEPARATOR(ch) \
+       (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+# endif /* DIR_SEPARATOR && DIR_SEPARATOR_2 */
+#endif /* DIR_SEPARATOR */
+
 /* Given KEY, as above, return its value.  */
 
 static const char *
@@ -241,11 +252,7 @@ translate_name (name)
     return name;
 
   for (keylen = 0;
-       (name[keylen + 1] != 0 && name[keylen + 1] != '/'
-#ifdef DIR_SEPARATOR
-       && name[keylen + 1] != DIR_SEPARATOR
-#endif
-       );
+       (name[keylen + 1] != 0 && !IS_DIR_SEPARATOR (name[keylen + 1]));
        keylen++)
     ;
 
@@ -268,11 +275,7 @@ translate_name (name)
     prefix = PREFIX;
 
   /* Remove any trailing directory separator from what we got.  */
-  if (prefix[strlen (prefix) - 1] == '/'
-#ifdef DIR_SEPARATOR
-      || prefix[strlen (prefix) - 1] == DIR_SEPARATOR
-#endif
-      )
+  if (IS_DIR_SEPARATOR (prefix[strlen (prefix) - 1]))
     {
       char * temp = save_string (prefix, strlen (prefix));
       temp[strlen (temp) - 1] = 0;
@@ -299,17 +302,33 @@ update_path (path, key)
       while (path[0] == '@' || path[0] == '$')
        path = translate_name (path);
     }
+
+#ifdef DIR_SEPARATOR_2
+  /* Convert DIR_SEPARATOR_2 to DIR_SEPARATOR. */
+  if (DIR_SEPARATOR != DIR_SEPARATOR_2)
+    {
+      int i;
+      int len = strlen (path);
+      char *new_path = save_string (path, len);
+      for (i = 0; i < len; i++)
+        if (new_path[i] == DIR_SEPARATOR_2)
+          new_path[i] = DIR_SEPARATOR;
+      path = new_path;
+    }
+#endif
       
-#ifdef DIR_SEPARATOR
+#if defined (DIR_SEPARATOR) && !defined (DIR_SEPARATOR_2)
   if (DIR_SEPARATOR != '/')
     {
       int i;
       int len = strlen (path);
+      char *new_path = save_string (path, len);
 
-      path = save_string (path, len);
       for (i = 0; i < len; i++)
-       if (path[i] == '/')
-         path[i] = DIR_SEPARATOR;
+        if (new_path[i] == '/')
+          new_path[i] = DIR_SEPARATOR;
+
+      path = new_path;
     }
 #endif