This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
DIR_SEPARATOR patches
- To: egcs-patches at egcs dot cygnus dot com
- Subject: DIR_SEPARATOR patches
- From: "Mark E." <snowball3 at usa dot net>
- Date: Thu, 25 Mar 1999 22:18:44 -0500
These patches deal with the two directory separators that DOS allows.
The gcc.c change creates a new macro 'IS_DIR_SEPARATOR' to hide
the nasty details.
If this patch is acceptable, patches for cccp.c and prefix.c dealing with
the same issue will follow.
Changelog:
* gcc/config/i386/xm-djgpp.h
(DIR_SEPARATOR): Set to '/'.
(DIR_SEPARATOR_2): New macro. Set to '\\'.
(HAVE_DOS_BASED_FILESYSTEM): New macro. Define.
* gcc/gcc.c
(IS_DIR_SEPARATOR): New macro. Checks whether or not
a given character is a directory separator.
(find_a_file): Use it.
(convert_filename): Likewise.
(process_command): Likewise.
(do_spec_1): Likewise.
(main): Likewise.
BTW Jeff, sorry about the last set of collect2 patches. I should have
checked everything over more carefully. This time, I had the coding
standards on the screen for reference as I made my changes.
---
Mark Elbrecht, snowball3@usa.net
http://snowball.digitalspace.net/
*** gcc/gcc.c.orig Thu Mar 18 07:29:04 1999
--- gcc/gcc.c Thu Mar 25 21:48:10 1999
*************** compilation is specified by a string cal
*** 63,68 ****
--- 63,79 ----
#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 */
+
+ #ifndef DIR_SEPARATOR
#define DIR_SEPARATOR '/'
#endif
*************** find_a_file (pprefix, name, mode)
*** 1992,2001 ****
/* Determine the filename to execute (special case for absolute paths). */
! if (*name == '/' || *name == DIR_SEPARATOR
/* Check for disk name on MS-DOS-based systems. */
! || (DIR_SEPARATOR == '\\' && name[1] == ':'
! && (name[2] == DIR_SEPARATOR || name[2] == '/')))
{
if (access (name, mode) == 0)
{
--- 2003,2014 ----
/* Determine the filename to execute (special case for absolute paths). */
! if (IS_DIR_SEPARATOR (*name)
! #ifdef HAVE_DOS_BASED_FILESYSTEM
/* Check for disk name on MS-DOS-based systems. */
! || (name[0] && name[1] == ':' && IS_DIR_SEPARATOR (name[2]))
! #endif
! )
{
if (access (name, mode) == 0)
{
*************** convert_filename (name, do_exe)
*** 2435,2441 ****
return name;
for (i = len - 1; i >= 0; i--)
! if (name[i] == '/' || name[i] == DIR_SEPARATOR)
break;
for (i++; i < len; i++)
--- 2448,2454 ----
return name;
for (i = len - 1; i >= 0; i--)
! if (IS_DIR_SEPARATOR (name[i]))
break;
for (i++; i < len; i++)
*************** process_command (argc, argv)
*** 2598,2610 ****
{
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))
{
temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1;
! if ((*temp == '/' || *temp == DIR_SEPARATOR)
&& strncmp (temp+1, "lib", 3) == 0
! && (temp[4] == '/' || temp[4] == DIR_SEPARATOR)
&& strncmp (temp+5, "gcc-lib", 7) == 0)
len -= sizeof ("/lib/gcc-lib/") - 1;
}
--- 2611,2622 ----
{
int len = strlen (gcc_exec_prefix);
if (len > (int) sizeof ("/lib/gcc-lib/")-1
! && (IS_DIR_SEPARATOR (gcc_exec_prefix[len-1])))
{
temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1;
! if (IS_DIR_SEPARATOR (*temp)
&& strncmp (temp+1, "lib", 3) == 0
! && IS_DIR_SEPARATOR (temp[4])
&& strncmp (temp+5, "gcc-lib", 7) == 0)
len -= sizeof ("/lib/gcc-lib/") - 1;
}
*************** process_command (argc, argv)
*** 2905,2916 ****
int len = strlen (value);
if ((len == 7
|| (len > 7
! && (value[len - 8] == '/'
! || value[len - 8] == DIR_SEPARATOR)))
&& strncmp (value + len - 7, "stage", 5) == 0
&& ISDIGIT (value[len - 2])
! && (value[len - 1] == '/'
! || value[len - 1] == DIR_SEPARATOR))
{
if (len == 7)
add_prefix (&include_prefixes, "include", NULL_PTR,
--- 2917,2926 ----
int len = strlen (value);
if ((len == 7
|| (len > 7
! && (IS_DIR_SEPARATOR (value[len - 8]))))
&& strncmp (value + len - 7, "stage", 5) == 0
&& ISDIGIT (value[len - 2])
! && (IS_DIR_SEPARATOR (value[len - 1])))
{
if (len == 7)
add_prefix (&include_prefixes, "include", NULL_PTR,
*************** do_spec_1 (spec, inswitch, soft_matched_
*** 3585,3592 ****
buffer = (char *) xrealloc (buffer, bufsize);
strcpy (buffer, machine_suffix);
idx = strlen (buffer);
! if (buffer[idx - 1] == '/'
! || buffer[idx - 1] == DIR_SEPARATOR)
buffer[idx - 1] = 0;
do_spec_1 (buffer, 1, NULL_PTR);
/* Make this a separate argument. */
--- 3595,3601 ----
buffer = (char *) xrealloc (buffer, bufsize);
strcpy (buffer, machine_suffix);
idx = strlen (buffer);
! if (IS_DIR_SEPARATOR (buffer[idx - 1]))
buffer[idx - 1] = 0;
do_spec_1 (buffer, 1, NULL_PTR);
/* Make this a separate argument. */
*************** do_spec_1 (spec, inswitch, soft_matched_
*** 3607,3614 ****
buffer = (char *) xrealloc (buffer, bufsize);
strcpy (buffer, pl->prefix);
idx = strlen (buffer);
! if (buffer[idx - 1] == '/'
! || buffer[idx - 1] == DIR_SEPARATOR)
buffer[idx - 1] = 0;
do_spec_1 (buffer, 1, NULL_PTR);
/* Make this a separate argument. */
--- 3616,3622 ----
buffer = (char *) xrealloc (buffer, bufsize);
strcpy (buffer, pl->prefix);
idx = strlen (buffer);
! if (IS_DIR_SEPARATOR (buffer[idx - 1]))
buffer[idx - 1] = 0;
do_spec_1 (buffer, 1, NULL_PTR);
/* Make this a separate argument. */
*************** main (argc, argv)
*** 4852,4865 ****
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. */
|| (standard_startfile_prefix[1] == ':'
! && (standard_startfile_prefix[2] == DIR_SEPARATOR
! || standard_startfile_prefix[2] == '/'))
#endif
)
add_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS",
--- 4860,4871 ----
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_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] == ':'
! && (IS_DIR_SEPARATOR (standard_startfile_prefix[2])))
#endif
)
add_prefix (&startfile_prefixes, standard_startfile_prefix, "BINUTILS",
*************** main (argc, argv)
*** 5052,5058 ****
input_basename = input_filename;
for (p = input_filename; *p; p++)
! if (*p == '/' || *p == DIR_SEPARATOR)
input_basename = p + 1;
/* Find a suffix starting with the last period,
--- 5058,5064 ----
input_basename = input_filename;
for (p = input_filename; *p; p++)
! if (IS_DIR_SEPARATOR (*p))
input_basename = p + 1;
/* Find a suffix starting with the last period,
*** gcc/config/i386/xm-djgpp.h.orig Wed Mar 24 18:35:34 1999
--- gcc/config/i386/xm-djgpp.h Thu Mar 25 21:03:44 1999
*************** Boston, MA 02111-1307, USA. */
*** 28,34 ****
#define EXECUTABLE_SUFFIX ".exe"
/* Even though we support "/", allow "\" since everybody tests both. */
! #define DIR_SEPARATOR '\\'
#define NO_SYS_SIGLIST 1
--- 28,38 ----
#define 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_FILESYSTEM
#define NO_SYS_SIGLIST 1