aboutsummaryrefslogtreecommitdiff
path: root/gcc/prefix.c
diff options
context:
space:
mode:
authorMark Elbrecht <snowball3@usa.net>1999-04-10 04:27:16 +0000
committerJeff Law <law@gcc.gnu.org>1999-04-09 22:27:16 -0600
commit509781a4d18e93e42b163d271fb5a47cdd9eac93 (patch)
treef18172ebf9899f2b5f68a983a1356b114443f93f /gcc/prefix.c
parentc44033714b2800977881fdb85cc7662c89eafbf1 (diff)
downloadgcc-509781a4d18e93e42b163d271fb5a47cdd9eac93.zip
gcc-509781a4d18e93e42b163d271fb5a47cdd9eac93.tar.gz
gcc-509781a4d18e93e42b163d271fb5a47cdd9eac93.tar.bz2
collect2.c (find_a_file): Use HAVE_DOS_BASED_FILE_SYSTEM in place of the DIR_SEPARATOR test.
* 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
Diffstat (limited to 'gcc/prefix.c')
-rw-r--r--gcc/prefix.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/gcc/prefix.c b/gcc/prefix.c
index e5ca923..8bf5696 100644
--- a/gcc/prefix.c
+++ b/gcc/prefix.c
@@ -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