X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fskip_whitespace.c;h=b6cfbba4dc8c44c707779360e74ad9c743665e81;hb=959cb6742832a3b403a5d0116088a09f33afe927;hp=87b5f23ba1dc47c50c08b966f2921a8e64af48d7;hpb=6a5377ac14bec2f2ae62c4ec085ff3b149cc11ad;p=oweals%2Fbusybox.git diff --git a/libbb/skip_whitespace.c b/libbb/skip_whitespace.c index 87b5f23ba..b6cfbba4d 100644 --- a/libbb/skip_whitespace.c +++ b/libbb/skip_whitespace.c @@ -4,22 +4,36 @@ * * Copyright (C) 2003 Manuel Novoa III * - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ #include "libbb.h" -char *skip_whitespace(const char *s) +char* FAST_FUNC skip_whitespace(const char *s) { - /* NB: isspace('\0') returns 0 */ - while (isspace(*s)) ++s; + /* In POSIX/C locale (the only locale we care about: do we REALLY want + * to allow Unicode whitespace in, say, .conf files? nuts!) + * isspace is only these chars: "\t\n\v\f\r" and space. + * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13. + * Use that. + */ + while (*s == ' ' || (unsigned char)(*s - 9) <= (13 - 9)) + s++; return (char *) s; } -char *skip_non_whitespace(const char *s) +char* FAST_FUNC skip_non_whitespace(const char *s) { - while (*s && !isspace(*s)) ++s; + while (*s != '\0' && *s != ' ' && (unsigned char)(*s - 9) > (13 - 9)) + s++; return (char *) s; } + +char* FAST_FUNC skip_dev_pfx(const char *tty_name) +{ + if (is_prefixed_with(tty_name, "/dev/")) + tty_name += 5; + return (char*)tty_name; +}