This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Import include/filenames.h from BFD (Windows/DJGPP testers needed)
- From: Zack Weinberg <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: DJ Delorie <dj at redhat dot com>
- Date: Mon, 30 Jun 2003 12:18:32 -0700
- Subject: Import include/filenames.h from BFD (Windows/DJGPP testers needed)
This patch brings over include/filenames.h from BFD and changes all
the apposite locations to use it. I have bootstrapped it on
i686-linux with no problem, but I need help testing it on Windows
and/or DJGPP hosts.
zw
include:
* filenames.h: New file, imported from binutils.
gcc:
* system.h: Include filenames.h.
(IS_DIR_SEPARATOR, IS_ABSOLUTE_PATHNAME): Don't define.
(DIR_SEPARATOR, DIR_SEPARATOR_2): If not already defined,
define based on HAVE_DOS_BASED_FILE_SYSTEM.
* config/i386/xm-cygwin.h, config/i386/xm-djgpp.h
* config/i386/xm-mingw32.h: Don't define HAVE_DOS_BASED_FILE_SYSTEM,
DIR_SEPARATOR, or DIR_SEPARATOR_2.
* doc/hostconfig.texi: Update to match.
* cppfiles.c, gcc.c, gensupport.c, protoize.c, config/i386/cygwin.h:
Use IS_ABSOLUTE_PATH throughout.
* gcc.c (DIR_UP): Delete, unused.
* protoize.c (IS_SAME_PATH): Define in terms of FILENAME_CMP.
(is_abspath): Delete.
gcc/java:
* jcf-path.c: Don't default-define PATH_SEPARATOR nor DIR_SEPARATOR.
Use FILENAME_CMP.
* jcf-write.c: Don't default-define DIR_SEPARATOR.
* jcf.h: Delete COMPARE_FILENAMES definition.
===================================================================
Index: include/filenames.h
--- include/filenames.h 1 Jan 1970 00:00:00 -0000
+++ include/filenames.h 30 Jun 2003 18:43:22 -0000
@@ -0,0 +1,51 @@
+/* Macros for taking apart, interpreting and processing file names.
+
+ These are here because some non-Posix (a.k.a. DOSish) systems have
+ drive letter brain-damage at the beginning of an absolute file name,
+ use forward- and back-slash in path names interchangeably, and
+ some of them have case-insensitive file names.
+
+ Copyright 2000, 2001 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program 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 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef FILENAMES_H
+#define FILENAMES_H
+
+#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+
+#ifndef HAVE_DOS_BASED_FILE_SYSTEM
+#define HAVE_DOS_BASED_FILE_SYSTEM 1
+#endif
+
+#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
+/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
+ only semi-absolute. This is because the users of IS_ABSOLUTE_PATH
+ want to know whether to prepend the current working directory to
+ a file name, which should not be done with a name like d:foo. */
+#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)[1] == ':')))
+#define FILENAME_CMP(s1, s2) strcasecmp(s1, s2)
+
+#else /* not DOSish */
+
+#define IS_DIR_SEPARATOR(c) ((c) == '/')
+#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
+#define FILENAME_CMP(s1, s2) strcmp(s1, s2)
+
+#endif /* not DOSish */
+
+#endif /* FILENAMES_H */
===================================================================
Index: gcc/system.h
--- gcc/system.h 29 Jun 2003 18:34:34 -0000 1.161
+++ gcc/system.h 30 Jun 2003 18:43:19 -0000
@@ -458,29 +458,15 @@ extern void abort (void);
#define PATH_SEPARATOR ':'
#endif
-#ifndef DIR_SEPARATOR
-#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 */
+/* Filename handling macros. */
+#include "filenames.h"
-/* Say how to test for an absolute pathname. On Unix systems, this is if
- it starts with a leading slash or a '$', the latter meaning the value of
- an environment variable is to be used. On machine with DOS-based
- file systems, it is also absolute if it starts with a drive identifier. */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-#define IS_ABSOLUTE_PATHNAME(STR) \
- (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$' \
- || ((STR)[0] != '\0' && (STR)[1] == ':' && IS_DIR_SEPARATOR ((STR)[2])))
-#else
-#define IS_ABSOLUTE_PATHNAME(STR) \
- (IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$')
+/* These should be phased out in favor of IS_DIR_SEPARATOR, where possible. */
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# ifdef HAVE_DOS_BASED_FILE_SYSTEM
+# define DIR_SEPARATOR_2 '\\'
+# endif
#endif
/* Get libiberty declarations. */
===================================================================
Index: gcc/doc/hostconfig.texi
--- gcc/doc/hostconfig.texi 6 Feb 2003 01:47:56 -0000 1.5
+++ gcc/doc/hostconfig.texi 30 Jun 2003 19:17:59 -0000
@@ -47,35 +47,40 @@ common thing to do in this hook is to de
@cindex configuration file
@cindex @file{xm-@var{machine}.h}
-GCC supports some filesystems that are very different to standard Unix
-filesystems. These macros, defined in @file{xm-@var{machine}.h},
-let you choose.
+GCC needs to know a number of things about the semantics of the host
+machine's filesystem. Filesystems with Unix and MS-DOS semantics are
+automatically detected. For other systems, you can define the
+following macros in @file{xm-@var{machine}.h}.
@ftable @code
-@item VMS
-Define this macro if the host system is VMS@.
-
@item HAVE_DOS_BASED_FILE_SYSTEM
-Define this macro if the host file system obeys the semantics defined by
-MS-DOS instead of Unix. DOS file systems are case insensitive, file
-specifications may begin with a drive letter, and both forward slash and
-backslash (@samp{/} and @samp{\}) are directory separators. If you
-define this macro, you probably need to define the next three macros too.
-
-@item PATH_SEPARATOR
-If defined, this macro should expand to a character constant specifying
-the separator for elements of search paths. The default value is a
-colon (@samp{:}). DOS-based systems usually use semicolon (@samp{;}).
+This macro is automatically defined by @file{system.h} if the host
+file system obeys the semantics defined by MS-DOS instead of Unix.
+DOS file systems are case insensitive, file specifications may begin
+with a drive letter, and both forward slash and backslash (@samp{/}
+and @samp{\}) are directory separators.
@item DIR_SEPARATOR
@itemx DIR_SEPARATOR_2
If defined, these macros expand to character constants specifying
-separators for directory names within a file specification. They are
-used somewhat inconsistently throughout the compiler. If your system
-behaves like Unix (only forward slash separates pathnames), define
-neither of them. If your system behaves like DOS (both forward and
-backward slash can be used), define @code{DIR_SEPARATOR} to @samp{/}
-and @code{DIR_SEPARATOR_2} to @samp{\}.
+separators for directory names within a file specification.
+@file{system.h} will automatically give them appropriate values on
+Unix and MS-DOS file systems. If your file system is neither of
+these, define one or both appropriately in @file{xm-@var{machine}.h}.
+
+However, operating systems like VMS, where constructing a pathname is
+more complicated than just stringing together directory names
+separated by a special character, should not define either of these
+macros.
+
+@item PATH_SEPARATOR
+If defined, this macro should expand to a character constant
+specifying the separator for elements of search paths. The default
+value is a colon (@samp{:}). DOS-based systems usually, but not
+always, use semicolon (@samp{;}).
+
+@item VMS
+Define this macro if the host system is VMS@.
@item HOST_OBJECT_SUFFIX
Define this macro to be a C string representing the suffix for object
===================================================================
Index: gcc/cppfiles.c
--- gcc/cppfiles.c 25 Jun 2003 21:01:09 -0000 1.173
+++ gcc/cppfiles.c 30 Jun 2003 18:43:17 -0000
@@ -547,7 +547,7 @@ cpp_included (cpp_reader *pfile, const c
char *name, *n;
splay_tree_node nd;
- if (IS_ABSOLUTE_PATHNAME (fname))
+ if (IS_ABSOLUTE_PATH (fname))
{
/* Just look it up. */
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
@@ -592,7 +592,7 @@ find_include_file (cpp_reader *pfile, co
return NO_INCLUDE_PATH;
}
- if (IS_ABSOLUTE_PATHNAME (fname))
+ if (IS_ABSOLUTE_PATH (fname))
return open_file_pch (pfile, fname);
/* For #include_next, skip in the search path past the dir in which
@@ -962,7 +962,7 @@ read_name_map (cpp_reader *pfile, const
ptr->map_from = from;
/* Make the real filename absolute. */
- if (IS_ABSOLUTE_PATHNAME (to))
+ if (IS_ABSOLUTE_PATH (to))
ptr->map_to = to;
else
{
===================================================================
Index: gcc/gcc.c
--- gcc/gcc.c 29 Jun 2003 13:53:07 -0000 1.383
+++ gcc/gcc.c 30 Jun 2003 18:43:18 -0000
@@ -111,14 +111,6 @@ extern int getrusage PARAMS ((int, struc
#define TARGET_OBJECT_SUFFIX ".o"
#endif
-#ifndef VMS
-/* FIXME: the location independence code for VMS is hairier than this,
- and hasn't been written. */
-#ifndef DIR_UP
-#define DIR_UP ".."
-#endif /* DIR_UP */
-#endif /* VMS */
-
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
/* Most every one is fine with LIBRARY_PATH. For some, it conflicts. */
@@ -2442,7 +2434,7 @@ find_a_file (pprefix, name, mode, multil
/* Determine the filename to execute (special case for absolute paths). */
- if (IS_ABSOLUTE_PATHNAME (name))
+ if (IS_ABSOLUTE_PATH (name))
{
if (access (name, mode) == 0)
{
@@ -2626,7 +2618,7 @@ add_sysrooted_prefix (pprefix, prefix, c
int *warn;
int os_multilib;
{
- if (!IS_ABSOLUTE_PATHNAME (prefix))
+ if (!IS_ABSOLUTE_PATH (prefix))
abort ();
if (target_system_root)
@@ -3823,7 +3815,7 @@ warranty; not even for MERCHANTABILITY o
directories, so that we can search both the user specified directory
and the standard place. */
- if (!IS_ABSOLUTE_PATHNAME (tooldir_prefix))
+ if (!IS_ABSOLUTE_PATH (tooldir_prefix))
{
if (gcc_exec_prefix)
{
@@ -4530,7 +4522,7 @@ do_spec_1 (spec, inswitch, soft_matched_
/* Relative directories always come from -B,
and it is better not to use them for searching
at run time. In particular, stage1 loses. */
- if (!IS_ABSOLUTE_PATHNAME (pl->prefix))
+ if (!IS_ABSOLUTE_PATH (pl->prefix))
continue;
#endif
/* Try subdirectory if there is one. */
@@ -6205,7 +6197,7 @@ 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 (IS_ABSOLUTE_PATHNAME (standard_startfile_prefix))
+ if (IS_ABSOLUTE_PATH (standard_startfile_prefix))
add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, NULL, 1);
@@ -7453,7 +7445,7 @@ if_exists_spec_function (argc, argv)
const char **argv;
{
/* Must have only one argument. */
- if (argc == 1 && IS_ABSOLUTE_PATHNAME (argv[0]) && ! access (argv[0], R_OK))
+ if (argc == 1 && IS_ABSOLUTE_PATH (argv[0]) && ! access (argv[0], R_OK))
return argv[0];
return NULL;
@@ -7473,7 +7465,7 @@ if_exists_else_spec_function (argc, argv
if (argc != 2)
return NULL;
- if (IS_ABSOLUTE_PATHNAME (argv[0]) && ! access (argv[0], R_OK))
+ if (IS_ABSOLUTE_PATH (argv[0]) && ! access (argv[0], R_OK))
return argv[0];
return argv[1];
===================================================================
Index: gcc/gensupport.c
--- gcc/gensupport.c 16 Jun 2003 21:41:04 -0000 1.40
+++ gcc/gensupport.c 30 Jun 2003 18:43:18 -0000
@@ -195,7 +195,7 @@ process_include (rtx desc, int lineno)
FILE *input_file;
/* If specified file name is absolute, skip the include stack. */
- if (! IS_ABSOLUTE_PATHNAME (filename))
+ if (! IS_ABSOLUTE_PATH (filename))
{
struct file_name_list *stackp;
===================================================================
Index: gcc/protoize.c
--- gcc/protoize.c 19 Jun 2003 10:46:50 -0000 1.83
+++ gcc/protoize.c 30 Jun 2003 18:43:19 -0000
@@ -48,11 +48,7 @@ Software Foundation, 59 Temple Place - S
#endif
/* Macro to see if the paths match. */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-#define IS_SAME_PATH(a,b) (strcasecmp (a, b) == 0)
-#else
-#define IS_SAME_PATH(a,b) (strcmp (a, b) == 0)
-#endif
+#define IS_SAME_PATH(a,b) (FILENAME_CMP (a, b) == 0)
/* Suffix for aux-info files. */
#ifdef __MSDOS__
@@ -94,7 +90,6 @@ static int directory_specified_p PARAMS
static int file_excluded_p PARAMS ((const char *));
static char *unexpand_if_needed PARAMS ((const char *));
static char *abspath PARAMS ((const char *, const char *));
-static int is_abspath PARAMS ((const char *));
static void check_aux_info PARAMS ((int));
static const char *find_corresponding_lparen PARAMS ((const char *));
static int referenced_file_is_newer PARAMS ((const char *, time_t));
@@ -694,7 +689,7 @@ in_system_include_dir (path)
{
const struct default_include *p;
- if (! is_abspath (path))
+ if (! IS_ABSOLUTE_PATH (path))
abort (); /* Must be an absolutized filename. */
for (p = cpp_include_defaults; p->fname; p++)
@@ -1114,20 +1109,6 @@ continue_outer: ;
return (got_unexpanded ? savestring (line_buf, copy_p - line_buf) : 0);
}
-/* Return 1 if pathname is absolute. */
-
-static int
-is_abspath (path)
- const char *path;
-{
- return (IS_DIR_SEPARATOR (path[0])
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- /* Check for disk name on MS-DOS-based systems. */
- || (path[0] && path[1] == ':' && IS_DIR_SEPARATOR (path[2]))
-#endif
- );
-}
-
/* Return the absolutized filename for the given relative
filename. Note that if that filename is already absolute, it may
still be returned in a modified form because this routine also
@@ -1156,7 +1137,7 @@ abspath (cwd, rel_filename)
{
const char *src_p;
- if (! is_abspath (rel_filename))
+ if (! IS_ABSOLUTE_PATH (rel_filename))
{
src_p = cwd2;
while ((*endp++ = *src_p++))
@@ -2264,7 +2245,7 @@ start_over: ;
continue;
aux_info_second_line = p;
aux_info_relocated_name = 0;
- if (! is_abspath (invocation_filename))
+ if (! IS_ABSOLUTE_PATH (invocation_filename))
{
/* INVOCATION_FILENAME is relative;
append it to BASE_SOURCE_FILENAME's dir. */
===================================================================
Index: gcc/config/i386/cygwin.h
--- gcc/config/i386/cygwin.h 21 Mar 2003 03:57:09 -0000 1.82
+++ gcc/config/i386/cygwin.h 30 Jun 2003 18:43:19 -0000
@@ -213,7 +213,7 @@ do \
{ \
char *cprefix = concat (tooldir_base_prefix, spec_machine, \
dir_separator_str, NULL); \
- if (!IS_ABSOLUTE_PATHNAME (cprefix)) \
+ if (!IS_ABSOLUTE_PATH (cprefix)) \
cprefix = concat (standard_exec_prefix, spec_machine, dir_separator_str, \
spec_version, dir_separator_str, tooldir_prefix, NULL); \
add_prefix (&exec_prefixes,\
===================================================================
Index: gcc/config/i386/xm-cygwin.h
--- gcc/config/i386/xm-cygwin.h 31 Oct 2001 14:32:30 -0000 1.13
+++ gcc/config/i386/xm-cygwin.h 30 Jun 2003 18:43:19 -0000
@@ -20,16 +20,3 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
#define HOST_EXECUTABLE_SUFFIX ".exe"
-
-/* Even though Cygwin tries to hide the DOS based filesystem, it
- still shows though at times. */
-#define HAVE_DOS_BASED_FILE_SYSTEM
-
-/* We support both "/" and "\" since everybody tests both but we
- default to "/". This is important because if gcc produces Win32
- paths containing backslashes, make and configure may treat the
- backslashes as escape characters. Many Win32 programs use forward
- slashes so using a forward slash shouldn't be problematic from the
- perspective of wanting gcc to produce native Win32 paths. */
-#undef DIR_SEPARATOR_2
-#define DIR_SEPARATOR_2 '\\'
===================================================================
Index: gcc/config/i386/xm-djgpp.h
--- gcc/config/i386/xm-djgpp.h 3 Dec 2001 19:13:32 -0000 1.16
+++ gcc/config/i386/xm-djgpp.h 30 Jun 2003 18:43:19 -0000
@@ -23,13 +23,6 @@ Boston, MA 02111-1307, USA. */
#define HOST_EXECUTABLE_SUFFIX ".exe"
-/* Even though we support "/", allow "\" since everybody tests both. */
-#define DIR_SEPARATOR '/'
-#define DIR_SEPARATOR_2 '\\'
-
-/* Allow test for DOS drive names. */
-#define HAVE_DOS_BASED_FILE_SYSTEM
-
/* System dependent initialization for collect2
to tell system() to act like Unix. */
#define COLLECT2_HOST_INITIALIZATION \
===================================================================
Index: gcc/config/i386/xm-mingw32.h
--- gcc/config/i386/xm-mingw32.h 10 Jan 2002 22:21:39 -0000 1.15
+++ gcc/config/i386/xm-mingw32.h 30 Jun 2003 18:43:19 -0000
@@ -19,14 +19,6 @@ along with GNU CC; see the file COPYING.
the Free Software Foundation, 59 Temple Place - Suite 330,
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 HOST_EXECUTABLE_SUFFIX ".exe"
#undef PATH_SEPARATOR
===================================================================
Index: gcc/java/jcf-path.c
--- gcc/java/jcf-path.c 7 Mar 2003 04:40:08 -0000 1.28
+++ gcc/java/jcf-path.c 30 Jun 2003 18:43:20 -0000
@@ -34,15 +34,6 @@ The Free Software Foundation is independ
#include "jcf.h"
-/* By default, colon separates directories in a path. */
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR ':'
-#endif
-
-#ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
-#endif
-
#ifndef DIR_UP
#define DIR_UP ".."
#endif
@@ -147,15 +138,15 @@ add_entry (struct entry **entp, const ch
len = strlen (filename);
- if (len > 4 && (COMPARE_FILENAMES (filename + len - 4, ".zip") == 0
- || COMPARE_FILENAMES (filename + len - 4, ".jar") == 0))
+ if (len > 4 && (FILENAME_CMP (filename + len - 4, ".zip") == 0
+ || FILENAME_CMP (filename + len - 4, ".jar") == 0))
{
n->flags |= FLAG_ZIP;
/* If the user uses -classpath then he'll have to include
libgcj.jar in the value. We check for this in a simplistic
way. Symlinks will fool this test. This is only used for
-MM and -MMD, so it probably isn't terribly important. */
- if (! COMPARE_FILENAMES (filename, LIBGCJ_ZIP_FILE))
+ if (! FILENAME_CMP (filename, LIBGCJ_ZIP_FILE))
n->flags |= FLAG_SYSTEM;
}
===================================================================
Index: gcc/java/jcf-write.c
--- gcc/java/jcf-write.c 9 Jun 2003 19:54:26 -0000 1.127
+++ gcc/java/jcf-write.c 30 Jun 2003 18:43:20 -0000
@@ -40,10 +40,6 @@ The Free Software Foundation is independ
#include "ggc.h"
#include "tm_p.h"
-#ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
-#endif
-
extern struct obstack temporary_obstack;
/* Base directory in which `.class' files should be written.
===================================================================
Index: gcc/java/jcf.h
--- gcc/java/jcf.h 9 Jun 2003 19:54:26 -0000 1.38
+++ gcc/java/jcf.h 30 Jun 2003 18:43:20 -0000
@@ -54,15 +54,6 @@ The Free Software Foundation is independ
#define JCF_USE_SCANDIR 0
#endif
-/* On case-insensitive file systems, file name components must be
- compared using "strcasecmp", if available, instead of "strcmp".
- Assumes "config.h" has already been included. */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM) && defined (HAVE_STRCASECMP)
-#define COMPARE_FILENAMES(X, Y) strcasecmp ((X), (Y))
-#else
-#define COMPARE_FILENAMES(X, Y) strcmp ((X), (Y))
-#endif
-
/* On case-insensitive file systems, we need to ensure that a request
to open a .java or .class file is honored only if the file to be
opened is of the exact case we are asking for. In other words, we