diff options
author | Ondrej Oprala <ooprala@redhat.com> | 2013-09-23 15:39:34 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2013-11-08 14:14:34 +0100 |
commit | 675de3f5c190cc4fbdf3d05e2b86731a9772398e (patch) | |
tree | a9058b9ecf7e2bb8dd242cb7057a6a6c89da41e0 /include | |
parent | d01d144c4b91b1d0964cebaabdfe2d57860f4ace (diff) | |
download | util-linux-675de3f5c190cc4fbdf3d05e2b86731a9772398e.tar.gz |
strutils: add skip_space() function
[kzak@redhat.com: - add also skip_blank(),
- remove duplicate implementation from libmount]
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/strutils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/strutils.h b/include/strutils.h index c7fe42a6..3883b428 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -5,6 +5,7 @@ #include <inttypes.h> #include <string.h> #include <sys/types.h> +#include <ctype.h> /* default strtoxx_or_err() exit code */ #ifndef STRTOXX_EXIT_CODE @@ -143,4 +144,21 @@ static inline const char *endswith(const char *s, const char *postfix) return (char *)s + sl - pl; } +/* + * Skip leading white space. + */ +static inline const char *skip_space(const char *p) +{ + while (isspace(*p)) + ++p; + return p; +} + +static inline const char *skip_blank(const char *p) +{ + while (isblank(*p)) + ++p; + return p; +} + #endif |