From 41faa55aedf9280ca575bee212238a8347313d49 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 29 Jun 1997 22:26:18 +0000 Subject: (base_name_strip_trailing_slashes): Remove. --- lib/basename.c | 68 ---------------------------------------------------------- 1 file changed, 68 deletions(-) (limited to 'lib/basename.c') diff --git a/lib/basename.c b/lib/basename.c index 0fd981f30..4087e3dc0 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -28,71 +28,3 @@ base_name (name) return (char *) base; } - -#ifdef STDC_HEADERS -# include -#else -char *malloc (); -#endif - -char * -base_name_strip_trailing_slashes (name) - char const *name; -{ - char const *end_p = name += FILESYSTEM_PREFIX_LEN (name); - char const *first, *p; - char *base; - int length; - - /* Make END_P point to the byte after the last non-slash character - in NAME if one exists. */ - for (p = name; *p; p++) - if (!ISSLASH (*p)) - end_p = p + 1; - - if (end_p == name) - { - first = end_p; - } - else - { - first = end_p - 1; - while (first > name && !ISSLASH (*(first - 1))) - --first; - } - - length = end_p - first; - base = (char *) malloc (length + 1); - if (base == 0) - return 0; - - memcpy (base, first, length); - base[length] = '\0'; - - return base; -} - -#ifdef TEST -# include -# include - -# define CHECK(a,b) assert (strcmp (base_name_strip_trailing_slashes(a), b) \ - == 0) - -int -main () -{ - CHECK ("a", "a"); - CHECK ("ab", "ab"); - CHECK ("ab/c", "c"); - CHECK ("/ab/c", "c"); - CHECK ("/ab/c/", "c"); - CHECK ("/ab/c////", "c"); - CHECK ("/", ""); - CHECK ("////", ""); - CHECK ("////a", "a"); - CHECK ("//a//", "a"); - CHECK ("/a", "a"); - exit (0); -} -#endif -- cgit v1.2.3-54-g00ecf