gnats-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to gnats/libiberty/basename.c


From: Milan Zamazal
Subject: Changes to gnats/libiberty/basename.c
Date: Mon, 10 Dec 2001 18:04:14 -0500

Index: gnats/libiberty/basename.c
diff -c gnats/libiberty/basename.c:1.2 gnats/libiberty/basename.c:1.3
*** gnats/libiberty/basename.c:1.2      Tue Oct 26 03:10:16 1999
--- gnats/libiberty/basename.c  Mon Dec 10 18:03:27 2001
***************
*** 14,37 ****
        last component of the pathname ("ls.c" in this case).
  
  BUGS
!       Presumes a UNIX style path with UNIX style separators.
  */
  
  #include "ansidecl.h"
  #include "libiberty.h"
  
  char *
  basename (name)
       const char *name;
  {
!   const char *base = name;
  
!   while (*name)
      {
!       if (*name++ == '/')
        {
!         base = name;
        }
      }
    return (char *) base;
  }
--- 14,66 ----
        last component of the pathname ("ls.c" in this case).
  
  BUGS
!       Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows 
!       style separators.
  */
  
  #include "ansidecl.h"
  #include "libiberty.h"
+ #include "safe-ctype.h"
+ 
+ #ifndef DIR_SEPARATOR
+ #define DIR_SEPARATOR '/'
+ #endif
+ 
+ #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+   defined (__OS2__)
+ #define HAVE_DOS_BASED_FILE_SYSTEM
+ #ifndef DIR_SEPARATOR_2 
+ #define DIR_SEPARATOR_2 '\\'
+ #endif
+ #endif
+ 
+ /* Define IS_DIR_SEPARATOR.  */
+ #ifndef DIR_SEPARATOR_2
+ # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+ #else /* DIR_SEPARATOR_2 */
+ # define IS_DIR_SEPARATOR(ch) \
+       (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+ #endif /* DIR_SEPARATOR_2 */
  
  char *
  basename (name)
       const char *name;
  {
!   const char *base;
  
! #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
!   /* Skip over the disk name in MSDOS pathnames. */
!   if (ISALPHA (name[0]) && name[1] == ':') 
!     name += 2;
! #endif
! 
!   for (base = name; *name; name++)
      {
!       if (IS_DIR_SEPARATOR (*name))
        {
!         base = name + 1;
        }
      }
    return (char *) base;
  }
+ 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]