This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: make file_name_nondirectory use IS_DIR_SEPARATOR
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: make file_name_nondirectory use IS_DIR_SEPARATOR
- From: Lars Brinkhoff <lars at nocrew dot org>
- Date: 21 Feb 2001 12:42:01 +0100
- Organization: nocrew
Isn't file_name_nondirectory in toplev.c supposed to honour the
IS_DIR_SEPARATOR (and DIR_SEPARATOR_2) macros?
If this macro is approved, please note that I don't have CVS write
access.
2001-02-21 lars brinkhoff <lars@nocrew.org>
* toplev.c (file_name_nondirectory): Use IS_DIR_SEPARATOR
instead of '/' and DIR_SEPARATOR.
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.425
diff -u -r1.425 toplev.c
--- toplev.c 2001/02/19 00:09:28 1.425
+++ toplev.c 2001/02/21 11:34:02
@@ -1708,13 +1708,15 @@
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;
+ int i;
+
+ for (i = strlen (x) - 1; i >= 0; i--)
+ {
+ if (IS_DIR_SEPARATOR (x[i]))
+ return x + i + 1;
+ }
+
+ return x;
}
/* Output a quoted string. */