mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
string-helpers: add str_equal()
This commit is contained in:
parent
45f73b58a1
commit
5e29f79258
3 changed files with 15 additions and 5 deletions
|
|
@ -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);
|
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 */
|
#endif /* LABWC_STRING_HELPERS_H */
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "common/scaled-scene-buffer.h"
|
#include "common/scaled-scene-buffer.h"
|
||||||
#include "common/scaled-font-buffer.h"
|
#include "common/scaled-font-buffer.h"
|
||||||
|
#include "common/string-helpers.h"
|
||||||
|
|
||||||
static struct lab_data_buffer *
|
static struct lab_data_buffer *
|
||||||
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
_create_buffer(struct scaled_scene_buffer *scaled_buffer, double scale)
|
||||||
|
|
@ -39,11 +40,6 @@ _destroy(struct scaled_scene_buffer *scaled_buffer)
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool str_equal(const char *a, const char *b)
|
|
||||||
{
|
|
||||||
return a == b || (a && b && !strcmp(a, b));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
_equal(struct scaled_scene_buffer *scaled_buffer_a,
|
_equal(struct scaled_scene_buffer *scaled_buffer_a,
|
||||||
struct scaled_scene_buffer *scaled_buffer_b)
|
struct scaled_scene_buffer *scaled_buffer_b)
|
||||||
|
|
|
||||||
|
|
@ -200,3 +200,8 @@ str_starts_with(const char *s, char needle, const char *ignore_chars)
|
||||||
return (s + strspn(s, ignore_chars))[0] == needle;
|
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));
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue