endofname.c 486 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Utility routines.
  3. *
  4. * Copyright (C) 2013 Denys Vlasenko
  5. *
  6. * Licensed under GPLv2, see file LICENSE in this source tree.
  7. */
  8. //kbuild:lib-y += endofname.o
  9. #include "libbb.h"
  10. #define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
  11. #define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
  12. const char* FAST_FUNC
  13. endofname(const char *name)
  14. {
  15. if (!is_name(*name))
  16. return name;
  17. while (*++name) {
  18. if (!is_in_name(*name))
  19. break;
  20. }
  21. return name;
  22. }