This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: make file_name_nondirectory use IS_DIR_SEPARATOR


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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]