basename.c 497 B

1234567891011121314151617181920212223242526272829
  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. /* Experimentally off - libc_hidden_proto(basename) */
  10. char *basename(const char *path)
  11. {
  12. register const char *s;
  13. register const char *p;
  14. p = s = path;
  15. while (*s) {
  16. if (*s++ == '/') {
  17. p = s;
  18. }
  19. }
  20. return (char *) p;
  21. }
  22. libc_hidden_def(basename)
  23. #endif