ret = read(readpipe[0], converted + read_bytes, conv_size - read_bytes);
if (ret == -1) {
warn("Cannot read from pipe");
+ FREE(converted);
return NULL;
}
read_bytes += ret;
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';
for_window:
TOK_FOR_WINDOW match command
{
+ if (match_is_empty(¤t_match)) {
+ ELOG("Match is empty, ignoring this for_window statement\n");
+ break;
+ }
printf("\t should execute command %s for the criteria mentioned above\n", $3);
Assignment *assignment = scalloc(sizeof(Assignment));
assignment->type = A_COMMAND;
}
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
char *hex;
if (asprintf(&hex, "#%s", $2) == -1)
die("asprintf()");
+ free($2);
$$ = get_colorpixel(hex);
free(hex);
}