summaryrefslogtreecommitdiffstats
path: root/include/strutils.h
diff options
context:
space:
mode:
authorOndrej Oprala2013-09-23 15:39:34 +0200
committerKarel Zak2013-11-08 14:14:34 +0100
commit675de3f5c190cc4fbdf3d05e2b86731a9772398e (patch)
treea9058b9ecf7e2bb8dd242cb7057a6a6c89da41e0 /include/strutils.h
parenthexdump: rename in() to first_letter() (diff)
downloadkernel-qcow2-util-linux-675de3f5c190cc4fbdf3d05e2b86731a9772398e.tar.gz
kernel-qcow2-util-linux-675de3f5c190cc4fbdf3d05e2b86731a9772398e.tar.xz
kernel-qcow2-util-linux-675de3f5c190cc4fbdf3d05e2b86731a9772398e.zip
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/strutils.h')
-rw-r--r--include/strutils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/strutils.h b/include/strutils.h
index c7fe42a63..3883b4288 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