aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorS. Christoffer Eliesen <christoffer@eliesen.no>2015-11-19 11:52:58 +0100
committerS. Christoffer Eliesen <christoffer@eliesen.no>2015-11-21 22:22:09 +0100
commitd0af224e6da2505601b9c068912903b3d32e37c6 (patch)
tree7db38e658ece1c7b65e9b4e57e7b2a511076f997 /sway
parenta33e3badad7fbfa7e229f009c5c1b78c552a935b (diff)
stringop: lenient_strcmp: Add.
Diffstat (limited to 'sway')
-rw-r--r--sway/stringop.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sway/stringop.c b/sway/stringop.c
index 8d6cac2f..fe5a97ca 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -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);