home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-base.tgz / libg++-2.7.1-src.tar / fsf / libg++ / libiberty / win32.c < prev    next >
C/C++ Source or Header  |  1995-07-07  |  2KB  |  65 lines

  1.  
  2. /* Win32-Unix compatibility library.
  3.    Copyright (C) 1995 Free Software Foundation, Inc.
  4.  
  5. This file is part of the libiberty library.
  6. Libiberty is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Library General Public
  8. License as published by the Free Software Foundation; either
  9. version 2 of the License, or (at your option) any later version.
  10.  
  11. Libiberty is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. Library General Public License for more details.
  15.  
  16. You should have received a copy of the GNU Library General Public
  17. License along with libiberty; see the file COPYING.LIB.  If
  18. not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* sac@cygnus.com */
  22.  
  23. /* This should only be compiled and linked under Win32. */
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27.  
  28. /*
  29.  
  30. NAME
  31.  
  32.     basename -- return pointer to last component of a pathname
  33.  
  34. SYNOPSIS
  35.  
  36.     char *basename (const char *name)
  37.  
  38. DESCRIPTION
  39.  
  40.     Given a pointer to a string containing a typical pathname
  41.     (/usr/src/cmd/ls/ls.c for example), returns a pointer to the
  42.     last component of the pathname ("ls.c" in this case).
  43.  
  44.  
  45. */
  46.  
  47.  
  48. char *
  49. basename (name)
  50.      const char *name;
  51. {
  52.   const char *base = name;
  53.  
  54.   while (*name)
  55.     {
  56.       if (*name == '/'
  57.       || *name == '\\')
  58.     {
  59.       base = name+1;
  60.     }
  61.       name++;
  62.     }
  63.   return (char *) base;
  64. }
  65.