mirror of
https://github.com/swaywm/sway.git
synced 2025-11-16 06:59:49 -05:00
stringop: lenient_strcmp: Add.
This commit is contained in:
parent
a33e3badad
commit
d0af224e6d
2 changed files with 16 additions and 0 deletions
|
|
@ -74,6 +74,19 @@ void strip_quotes(char *str) {
|
|||
*end = '\0';
|
||||
}
|
||||
|
||||
// strcmp that also handles null pointers.
|
||||
int lenient_strcmp(char *a, char *b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
} else if (!a) {
|
||||
return -1;
|
||||
} else if (!b) {
|
||||
return 1;
|
||||
} else {
|
||||
return strcmp(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
list_t *split_string(const char *str, const char *delims) {
|
||||
list_t *res = create_list();
|
||||
char *copy = strdup(str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue