This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY
- To: fjh at cs dot mu dot oz dot au (Fergus Henderson)
- Subject: Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Tue, 27 Feb 2001 12:29:20 -0500 (EST)
- Cc: gcc-patches at gcc dot gnu dot org
The issues raised by Fergus Henderson have been corrected. I have
bootstrap checked the patch with no regressions under i686 linux.
I also changed the default value of CASE_INSENSITIVE_FILENAMES to
check the code path when lower case translation is in effect, again
under i686 linux. I believe this caused repo1 and repo2 to fail
but there were no other regressions that I observed.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2001-02-25 John David Anglin <dave@hiauly1.hia.nrc.ca>
* alpha/xm-vms.h (CASE_INSENSITIVE_FILENAMES): Define.
* vax/xm-vms.h (CASE_INSENSITIVE_FILENAMES): Define.
(FILE_NAME_NONDIRECTORY): Delete obsolete macro.
* toplev.c (file_name_nondirectory): Delete function.
(strcpy_lc): New function to copy and translate destination string
to lower case.
(output_file_directive, main): Use basename function instead of
file_name_nondirectory.
* dwarf2out.c (compute_section_prefix): Likewise.
* cp/lex.c (handle_pragma_interface, handle_pragma_implementation):
Likewise.
* cp/repo.c (get_base_filename, open_repo_file): Likewise.
* toplev.h (strcpy_lc): Declare.
* cp-tree.h (strcpy_lc): Declare.
* system.h (IS_ABSOLUTE_PATHNAME): Provide VMS definition.
(CASE_INSENSITIVE_FILENAMES): Provide default definition.
--- ./config/alpha/xm-vms.h.orig Wed Sep 22 10:23:22 1999
+++ ./config/alpha/xm-vms.h Sun Feb 25 15:45:14 2001
@@ -61,6 +61,13 @@
{ 0, 0, 0, 0 } \
}
+/* Define CASE_INSENSITIVE_FILENAMES to translate base file names to lower
+ case. This allows cp/lex.c to properly compare filenames to determine
+ if a file implements a class on machines with case insensitive file
+ names. */
+
+#define CASE_INSENSITIVE_FILENAMES 1
+
/* Define a local equivalent (sort of) for unlink */
#define unlink remove
--- cp/cp-tree.h.orig Mon Feb 19 16:49:45 2001
+++ cp/cp-tree.h Sun Feb 25 17:10:55 2001
@@ -4042,8 +4042,10 @@
/* in input.c */
+/* in toplev.c */
+extern char *strcpy_lc PARAMS ((char *, const char *));
+
/* in lex.c */
-extern char *file_name_nondirectory PARAMS ((const char *));
extern tree make_pointer_declarator PARAMS ((tree, tree));
extern tree make_reference_declarator PARAMS ((tree, tree));
extern tree make_call_declarator PARAMS ((tree, tree, tree, tree));
--- dwarf2out.c.orig Fri Feb 16 17:17:26 2001
+++ dwarf2out.c Sun Feb 25 13:14:03 2001
@@ -5445,7 +5445,7 @@
die_checksum (unit_die, &ctx);
md5_finish_ctx (&ctx, checksum);
- p = file_name_nondirectory (get_AT_string (unit_die, DW_AT_name));
+ p = basename (get_AT_string (unit_die, DW_AT_name));
name = (char *) alloca (strlen (p) + 64);
sprintf (name, "%s.", p);
--- cp/lex.c.orig Mon Feb 12 04:58:18 2001
+++ cp/lex.c Sun Feb 25 20:01:07 2001
@@ -1109,10 +1109,17 @@
if (fname == (tree)-1)
return;
else if (fname == 0)
- main_filename = file_name_nondirectory (input_filename);
+ main_filename = basename (input_filename);
else
main_filename = TREE_STRING_POINTER (fname);
+ if (CASE_INSENSITIVE_FILENAMES)
+ {
+ char *d = (char *) alloca (strlen (main_filename) + 1);
+
+ main_filename = strcpy_lc (d, main_filename);
+ }
+
finfo = get_fileinfo (input_filename);
if (impl_file_chain == 0)
@@ -1158,7 +1165,7 @@
main_filename = main_input_filename;
else
main_filename = input_filename;
- main_filename = file_name_nondirectory (main_filename);
+ main_filename = basename (main_filename);
}
else
{
@@ -1166,6 +1173,13 @@
if (cpp_included (parse_in, main_filename))
warning ("#pragma implementation for %s appears after file is included",
main_filename);
+ }
+
+ if (CASE_INSENSITIVE_FILENAMES)
+ {
+ char *d = (char *) alloca (strlen (main_filename) + 1);
+
+ main_filename = strcpy_lc (d, main_filename);
}
for (; ifiles; ifiles = ifiles->next)
--- cp/repo.c.orig Mon Feb 12 04:58:18 2001
+++ cp/repo.c Sun Feb 25 20:02:22 2001
@@ -268,7 +268,7 @@
return NULL;
}
- return file_name_nondirectory (filename);
+ return basename (filename);
}
static void
@@ -281,10 +281,18 @@
if (s == NULL)
return;
- p = file_name_nondirectory (s);
+ p = basename (s);
+
p = strrchr (p, '.');
if (! p)
p = s + strlen (s);
+
+ if (CASE_INSENSITIVE_FILENAMES)
+ {
+ char *d = (char *) alloca (strlen (s) + 1);
+
+ s = strcpy_lc (d, s);
+ }
obstack_grow (&permanent_obstack, s, p - s);
repo_name = obstack_copy0 (&permanent_obstack, ".rpo", 4);
--- ./system.h.orig Fri Dec 22 07:27:36 2000
+++ ./system.h Sun Feb 25 14:02:46 2001
@@ -474,8 +474,18 @@
(IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$' \
|| ((STR)[0] != '\0' && (STR)[1] == ':' && IS_DIR_SEPARATOR ((STR)[2])))
#else
+#ifdef VMS
+/* FIXME: ??? */
+#define IS_ABSOLUTE_PATHNAME(STR) 1
+#else
#define IS_ABSOLUTE_PATHNAME(STR) \
(IS_DIR_SEPARATOR ((STR)[0]) || (STR)[0] == '$')
+#endif
+#endif
+
+/* if defined, within-directory file names are translated to lower case. */
+#ifndef CASE_INSENSITIVE_FILENAMES
+#define CASE_INSENSITIVE_FILENAMES 0
#endif
/* Get libiberty declarations. */
--- toplev.c.orig Fri Feb 16 17:17:37 2001
+++ toplev.c Sun Feb 25 19:59:01 2001
@@ -1725,19 +1725,26 @@
}
}
-/* Given a file name X, return the nondirectory portion. */
+/* Copy SRC including the terminating '\0' character to DEST translating
+ to lower case. */
char *
-file_name_nondirectory (x)
- const char *x;
-{
- char *tmp = (char *) strrchr (x, '/');
- if (DIR_SEPARATOR != '/' && ! tmp)
- tmp = (char *) strrchr (x, DIR_SEPARATOR);
- if (tmp)
- return (char *) (tmp + 1);
- else
- return (char *) x;
+strcpy_lc (dest, src)
+ char *dest;
+ const char *src;
+{
+ register char c;
+ char *s = (char *) src;
+ char *d = dest;
+
+ do
+ {
+ c = TOLOWER (*s++);
+ *d++ = c;
+ }
+ while (c != '\0');
+
+ return dest;
}
/* Output a quoted string. */
@@ -1770,15 +1777,13 @@
FILE *asm_file;
const char *input_name;
{
- int len = strlen (input_name);
- const char *na = input_name + len;
+ const char *na = basename (input_name);
- /* NA gets INPUT_NAME sans directory names. */
- while (na > input_name)
+ if (CASE_INSENSITIVE_FILENAMES)
{
- if (IS_DIR_SEPARATOR (na[-1]))
- break;
- na--;
+ char *d = (char *) alloca (strlen (na) + 1);
+
+ na = strcpy_lc (d, na);
}
#ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME
@@ -4545,16 +4550,19 @@
char **argv;
{
register int i;
- char *p;
/* save in case md file wants to emit args as a comment. */
save_argc = argc;
save_argv = argv;
- p = argv[0] + strlen (argv[0]);
- while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
- --p;
- progname = p;
+ progname = basename (argv[0]);
+
+ if (CASE_INSENSITIVE_FILENAMES)
+ {
+ char *d = xstrdup (progname);
+
+ progname = strcpy_lc (d, progname);
+ }
xmalloc_set_program_name (progname);
--- toplev.h.orig Fri Feb 16 17:17:38 2001
+++ toplev.h Sun Feb 25 17:09:46 2001
@@ -35,7 +35,7 @@
const int));
extern int count_error PARAMS ((int));
extern void strip_off_ending PARAMS ((char *, int));
-extern char *file_name_nondirectory PARAMS ((const char *));
+extern char *strcpy_lc PARAMS ((char *, const char *));
extern void print_time PARAMS ((const char *, long));
extern void debug_start_source_file PARAMS ((const char *));
extern void debug_end_source_file PARAMS ((unsigned));
--- ./config/vax/xm-vms.h.orig Thu Nov 9 02:45:15 2000
+++ ./config/vax/xm-vms.h Sun Feb 25 15:45:46 2001
@@ -84,25 +84,12 @@
#define MAX_READ_LEN (32 * 512)
#define MAX_WRITE_LEN (32 * 512)
-/* Under VMS a directory specification can be enclosed either in square
- brackets or in angle brackets. Thus we need to check both. This
- macro is used to help compare filenames in cp-lex.c.
+/* Define CASE_INSENSITIVE_FILENAMES to translate base file names to lower
+ case. This allows cp/lex.c to properly compare filenames to determine
+ if a file implements a class on machines with case insensitive file
+ names. */
- We also need to make sure that the names are all lower case, because
- we must be able to compare filenames to determine if a file implements
- a class. */
-
-#define FILE_NAME_NONDIRECTORY(C) \
-({ \
- char * pnt_ = (C), * pnt1_; \
- pnt1_ = pnt_ - 1; \
- while (*++pnt1_) \
- if ((*pnt1_ >= 'A' && *pnt1_ <= 'Z')) *pnt1_ |= 0x20; \
- pnt1_ = strrchr (pnt_, ']'); \
- pnt1_ = (pnt1_ == 0 ? strrchr (pnt_, '>') : pnt1_); \
- pnt1_ = (pnt1_ == 0 ? strrchr (pnt_, ':') : pnt1_); \
- (pnt1_ == 0 ? pnt_ : pnt1_ + 1); \
- })
+#define CASE_INSENSITIVE_FILENAMES 1
/* Macro to generate the name of the cross reference file. The standard
one does not work, since it was written assuming that the conventions