]> git.mdlowis.com Git - proto/labwc.git/commitdiff
string-helpers: add str_equal()
authortokyo4j <hrak1529@gmail.com>
Wed, 8 Jan 2025 06:07:06 +0000 (15:07 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Fri, 24 Jan 2025 22:27:21 +0000 (07:27 +0900)
include/common/string-helpers.h
src/common/scaled-font-buffer.c
src/common/string-helpers.c

index dca707898875bfc0796c582acdee97e7e985dca9..efa5bfd23d751083e84fe75008e72bcd993c6a8d 100644 (file)
@@ -92,4 +92,13 @@ bool str_endswith_ignore_case(const char *const string, const char *const suffix
  */
 bool str_starts_with(const char *s, char needle, const char *ignore_chars);
 
+/**
+ * str_equal - indicate whether two strings are identical
+ * @a: first string to compare
+ * @b: second string to compare
+ *
+ * If both strings are NULL, returns true.
+ */
+bool str_equal(const char *a, const char *b);
+
 #endif /* LABWC_STRING_HELPERS_H */
index 7bd0f1dc0cce2093164fd484b902c46cb0b1e21a..e0d79a572ca6a2b31aef96cfa627e85ddb97f8db 100644 (file)
@@ -10,6 +10,7 @@
 #include "common/mem.h"
 #include "common/scaled-scene-buffer.h"
 #include "common/scaled-font-buffer.h"
+#include "common/string-helpers.h"
 
 static struct lab_data_buffer *
 _create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
@@ -39,11 +40,6 @@ _destroy(struct scaled_scene_buffer *scaled_buffer)
        free(self);
 }
 
-static bool str_equal(const char *a, const char *b)
-{
-       return a == b || (a && b && !strcmp(a, b));
-}
-
 static bool
 _equal(struct scaled_scene_buffer *scaled_buffer_a,
        struct scaled_scene_buffer *scaled_buffer_b)
index e517751ee47e7b5c7f1e6500feaaa60c893dfc93..ef29c33982452a258055d7d9d4de32ecc815ac9c 100644 (file)
@@ -200,3 +200,8 @@ str_starts_with(const char *s, char needle, const char *ignore_chars)
        return (s + strspn(s, ignore_chars))[0] == needle;
 }
 
+bool
+str_equal(const char *a, const char *b)
+{
+       return a == b || (a && b && !strcmp(a, b));
+}