3
0

skip_whitespace.c 938 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * skip_whitespace implementation for busybox
  4. *
  5. * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  8. */
  9. #include "libbb.h"
  10. char* FAST_FUNC skip_whitespace(const char *s)
  11. {
  12. /* In POSIX/C locale (the only locale we care about: do we REALLY want
  13. * to allow Unicode whitespace in, say, .conf files? nuts!)
  14. * isspace is only these chars: "\t\n\v\f\r" and space.
  15. * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13.
  16. * Use that.
  17. */
  18. while (*s == ' ' || (unsigned char)(*s - 9) <= (13 - 9))
  19. s++;
  20. return (char *) s;
  21. }
  22. char* FAST_FUNC skip_non_whitespace(const char *s)
  23. {
  24. while (*s != '\0' && *s != ' ' && (unsigned char)(*s - 9) > (13 - 9))
  25. s++;
  26. return (char *) s;
  27. }
  28. char* FAST_FUNC skip_dev_pfx(const char *tty_name)
  29. {
  30. if (is_prefixed_with(tty_name, "/dev/"))
  31. tty_name += 5;
  32. return (char*)tty_name;
  33. }