]> git.mdlowis.com Git - proto/labwc.git/commitdiff
string-helper: add str_space_only()
authortokyo4j <hrak1529@gmail.com>
Fri, 11 Apr 2025 20:06:08 +0000 (05:06 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 30 Jul 2025 19:36:27 +0000 (20:36 +0100)
include/common/string-helpers.h
src/common/string-helpers.c

index e49fa1107c7e66889ffa134db6a72a50f3ed09fb..0509d33c9b2f8272979a1b5ccc847d9ef5c7505b 100644 (file)
@@ -9,6 +9,12 @@
  */
 bool string_null_or_empty(const char *s);
 
+/**
+ * str_space_only - Check if the string only contains white-space characters
+ * @s: string to check
+ */
+bool str_space_only(const char *s);
+
 /**
  * trim_last_field() - Trim last field of string splitting on provided delim
  * @buf: string to trim
index 2d8f8de3ec6736c5d602e7e71fdbfc6dd3b0674e..a0d730344b800f62318c63358a2a77f471c344ee 100644 (file)
@@ -204,3 +204,14 @@ str_equal(const char *a, const char *b)
 {
        return a == b || (a && b && !strcmp(a, b));
 }
+
+bool
+str_space_only(const char *s)
+{
+       for (; *s; s++) {
+               if (!isspace(*s)) {
+                       return false;
+               }
+       }
+       return true;
+}