#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
-#include <limits.h>
#include "all.h"
typedef struct yy_buffer_state *YY_BUFFER_STATE;
extern int yylex(struct context *context);
extern int yyparse(void);
+extern int yylex_destroy(void);
extern FILE *yyin;
YY_BUFFER_STATE yy_scan_string(const char *);
}
/*
- * Calls i3-migrate-config-to-v4.pl to migrate a configuration file (input
+ * Calls i3-migrate-config-to-v4 to migrate a configuration file (input
* buffer).
*
* Returns the converted config file or NULL if there was an error (for
NULL, /* will be replaced by the executable path */
NULL
};
- exec_i3_utility("i3-migrate-config-to-v4.pl", argv);
+ exec_i3_utility("i3-migrate-config-to-v4", argv);
}
/* parent */
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 (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
+ ELOG("Malformed variable assignment, need a value\n");
+ continue;
+ }
+
+ if (!(v_value = strstr(value, " ")))
+ v_value = strstr(value, "\t");
*(v_value++) = '\0';
}
}
fclose(fstr);
- close(fd);
/* For every custom variable, see how often it occurs in the file and
* how much extra bytes it requires when replaced. */
int extra = (strlen(current->value) - strlen(current->key));
char *next;
for (next = bufcopy;
- (next = strcasestr(bufcopy + (next - bufcopy), current->key)) != NULL;
+ next < (bufcopy + stbuf.st_size) &&
+ (next = strcasestr(next, current->key)) != NULL;
next += strlen(current->key)) {
*next = '_';
extra_bytes += extra;
printf("\n");
printf("Please convert your config file to v4. You can use this command:\n");
printf(" mv %s %s.O\n", f, f);
- printf(" i3-migrate-config-to-v4.pl %s.O > %s\n", f, f);
+ printf(" i3-migrate-config-to-v4 %s.O > %s\n", f, f);
printf("****************************************************************\n");
printf("\n");
free(new);
} else {
printf("\n");
printf("**********************************************************************\n");
- printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4.pl\n");
+ printf("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
printf("was not correctly installed on your system?\n");
printf("**********************************************************************\n");
printf("\n");
start_configerror_nagbar(f);
}
+ yylex_destroy();
FREE(context->line_copy);
free(context);
free(new);
%token TOK_MARK "mark"
%token TOK_CLASS "class"
+%token TOK_INSTANCE "instance"
%token TOK_ID "id"
%token TOK_CON_ID "con_id"
%token TOK_TITLE "title"
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;
;
criteria:
+ criteria criterion
+ | criterion
+ ;
+
+criterion:
TOK_CLASS '=' STR
{
printf("criteria: class = %s\n", $3);
current_match.class = $3;
}
+ | TOK_INSTANCE '=' STR
+ {
+ printf("criteria: instance = %s\n", $3);
+ current_match.instance = $3;
+ }
| TOK_CON_ID '=' STR
{
printf("criteria: id = %s\n", $3);
}
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
/* Compatibility with older versions: If the assignment target starts
* with ~, we create the equivalent of:
*
- * for_window [class="foo"] mode floating
+ * for_window [class="foo"] floating enable
*/
if (*workspace == '~') {
workspace++;
{
config.font = load_font($2, true);
printf("font %s\n", $2);
+ free($2);
}
;
char *hex;
if (asprintf(&hex, "#%s", $2) == -1)
die("asprintf()");
+ free($2);
$$ = get_colorpixel(hex);
free(hex);
}