basename.c 416 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef __USE_GNU
  9. char *basename(const char *path)
  10. {
  11. register const char *s;
  12. register const char *p;
  13. p = s = path;
  14. while (*s) {
  15. if (*s++ == '/') {
  16. p = s;
  17. }
  18. }
  19. return (char *) p;
  20. }
  21. #endif