return NULL;
}
-static const long get_long(const char *identifier) {
+static long get_long(const char *identifier) {
for (int c = 0; c < 10; c++) {
if (stack[c].identifier == NULL)
break;
static cmdp_state state;
static Match current_match;
-static struct ConfigResult subcommand_output;
-static struct ConfigResult command_output;
+static struct ConfigResultIR subcommand_output;
+static struct ConfigResultIR command_output;
/* A list which contains the states that lead to the current state, e.g.
* INITIAL, WORKSPACE_LAYOUT.
return result;
}
-struct ConfigResult *parse_config(const char *input, struct context *context) {
+struct ConfigResultIR *parse_config(const char *input, struct context *context) {
/* Dump the entire config file into the debug log. We cannot just use
* DLOG("%s", input); because one log message must not exceed 4 KiB. */
const char *dumpwalk = input;
state = INITIAL;
statelist_idx = 1;
-/* A YAJL JSON generator used for formatting replies. */
-#if YAJL_MAJOR >= 2
+ /* A YAJL JSON generator used for formatting replies. */
command_output.json_gen = yajl_gen_alloc(NULL);
-#else
- command_output.json_gen = yajl_gen_alloc(NULL, NULL);
-#endif
y(array_open);
/* The "<=" operator is intentional: We also handle the terminating 0-byte
* explicitly by looking for an 'end' token. */
- while ((walk - input) <= len) {
+ while ((size_t)(walk - input) <= len) {
/* Skip whitespace before every token, newlines are relevant since they
* separate configuration directives. */
while ((*walk == ' ' || *walk == '\t') && *walk != '\0')
y(map_close);
/* Skip the rest of this line, but continue parsing. */
- while ((walk - input) <= len && *walk != '\n')
+ while ((size_t)(walk - input) <= len && *walk != '\n')
walk++;
free(position);
strncasecmp(line, "force_focus_wrapping", strlen("force_focus_wrapping")) == 0 ||
strncasecmp(line, "# i3 config file (v4)", strlen("# i3 config file (v4)")) == 0 ||
strncasecmp(line, "workspace_layout", strlen("workspace_layout")) == 0) {
- printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
+ LOG("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
return 4;
}
strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
strncasecmp(bind, "bar", strlen("bar")) == 0) {
- printf("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
+ LOG("deciding for version 4 due to this line: %.*s\n", (int)(walk-line), line);
return 4;
}
}
return converted;
}
-/*
- * Checks for duplicate key bindings (the same keycode or keysym is configured
- * more than once). If a duplicate binding is found, a message is printed to
- * stderr and the has_errors variable is set to true, which will start
- * i3-nagbar.
- *
- */
-static void check_for_duplicate_bindings(struct context *context) {
- Binding *bind, *current;
- TAILQ_FOREACH(current, bindings, bindings) {
- TAILQ_FOREACH(bind, bindings, bindings) {
- /* Abort when we reach the current keybinding, only check the
- * bindings before */
- if (bind == current)
- break;
-
- /* Check if one is using keysym while the other is using bindsym.
- * If so, skip. */
- /* XXX: It should be checked at a later place (when translating the
- * keysym to keycodes) if there are any duplicates */
- if ((bind->symbol == NULL && current->symbol != NULL) ||
- (bind->symbol != NULL && current->symbol == NULL))
- continue;
-
- /* If bind is NULL, current has to be NULL, too (see above).
- * If the keycodes differ, it can't be a duplicate. */
- if (bind->symbol != NULL &&
- strcasecmp(bind->symbol, current->symbol) != 0)
- continue;
-
- /* Check if the keycodes or modifiers are different. If so, they
- * can't be duplicate */
- if (bind->keycode != current->keycode ||
- bind->mods != current->mods ||
- bind->release != current->release)
- continue;
-
- context->has_errors = true;
- if (current->keycode != 0) {
- ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
- current->mods, current->keycode, current->command);
- } else {
- ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
- current->mods, current->symbol, current->command);
- }
- }
- }
-}
-
/*
* Parses the given file by first replacing the variables, then calling
* parse_config and possibly launching i3-nagbar.
free(new);
new = converted;
} else {
- printf("\n");
- printf("**********************************************************************\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");
+ LOG("\n");
+ LOG("**********************************************************************\n");
+ LOG("ERROR: Could not convert config file. Maybe i3-migrate-config-to-v4\n");
+ LOG("was not correctly installed on your system?\n");
+ LOG("**********************************************************************\n");
+ LOG("\n");
}
}
context = scalloc(sizeof(struct context));
context->filename = f;
- struct ConfigResult *config_output = parse_config(new, context);
+ struct ConfigResultIR *config_output = parse_config(new, context);
yajl_gen_free(config_output->json_gen);
check_for_duplicate_bindings(context);
char *argv[] = {
NULL, /* will be replaced by the executable path */
"-f",
- config.font.pattern,
+ (config.font.pattern ? config.font.pattern : "fixed"),
"-t",
(context->has_errors ? "error" : "warning"),
"-m",