]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.y
Merge branch 'master' into next
[i3/i3] / src / cfgparse.y
index 4a4c26ca39eff116292942daa209aa8852e4e985..fd23597e28bd2bff4ec965066c12b0125ff6434f 100644 (file)
@@ -397,13 +397,18 @@ void parse_file(const char *f) {
             continue;
 
         if (strcasecmp(key, "set") == 0) {
-            if (value[0] != '$')
-                die("Malformed variable assignment, name has to start with $\n");
+            if (value[0] != '$') {
+                ELOG("Malformed variable assignment, name has to start with $\n");
+                continue;
+            }
 
             /* get key/value for this variable */
             char *v_key = value, *v_value;
-            if ((v_value = strstr(value, " ")) == NULL)
-                die("Malformed variable assignment, need a value\n");
+            if ((v_value = strstr(value, " ")) == NULL &&
+                (v_value = strstr(value, "\t")) == NULL) {
+                ELOG("Malformed variable assignment, need a value\n");
+                continue;
+            }
 
             *(v_value++) = '\0';
 
@@ -996,10 +1001,25 @@ workspace:
             }
 
             DLOG("Should assign workspace %s to output %s\n", ws_name, $4);
-            struct Workspace_Assignment *assignment = scalloc(sizeof(struct Workspace_Assignment));
-            assignment->name = ws_name;
-            assignment->output = $4;
-            TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
+            /* Check for earlier assignments of the same workspace so that we
+             * don’t have assignments of a single workspace to different
+             * outputs */
+            struct Workspace_Assignment *assignment;
+            bool duplicate = false;
+            TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) {
+                if (strcasecmp(assignment->name, ws_name) == 0) {
+                    ELOG("You have a duplicate workspace assignment for workspace \"%s\"\n",
+                         ws_name);
+                    assignment->output = $4;
+                    duplicate = true;
+                }
+            }
+            if (!duplicate) {
+                assignment = scalloc(sizeof(struct Workspace_Assignment));
+                assignment->name = ws_name;
+                assignment->output = $4;
+                TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
+            }
         }
     }
     | TOKWORKSPACE NUMBER workspace_name