summaryrefslogtreecommitdiff
path: root/sway/stringop.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2015-11-22 09:18:20 -0500
committerDrew DeVault <[email protected]>2015-11-22 09:18:20 -0500
commit7bd82a26b00f2ad57563bee55a098f97c52421f3 (patch)
tree793b93d9df55478856a9d6dda7d99d3f8bd7d0e7 /sway/stringop.c
parent56e80c0f73a9891c50d30ea8f53630fb112f3d23 (diff)
parent5531dbe1b2026a88670c812d40f0efccb4b52c7f (diff)
Merge pull request #245 from sce/workspace_output_duplicates
Fix `workspace_output` duplicates
Diffstat (limited to 'sway/stringop.c')
-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);