X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fconfig_parser.c;h=b229b445ba24ae71358cfcc891e4fafa06d40490;hb=94b1e76af45431f8cb5878679591cd504f629e60;hp=21cd06fb5a6e5d12b85e04249612a3b284f918ce;hpb=92000942039fa99d7334ca5099b467b0d3d17792;p=i3%2Fi3 diff --git a/src/config_parser.c b/src/config_parser.c index 21cd06fb..b229b445 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -823,11 +823,11 @@ static char *migrate_config(char *input, off_t size) { fprintf(stderr, "Migration process exit code was != 0\n"); if (returncode == 2) { fprintf(stderr, "could not start the migration script\n"); - /* TODO: script was not found. tell the user to fix his system or create a v4 config */ + /* TODO: script was not found. tell the user to fix their system or create a v4 config */ } else if (returncode == 1) { fprintf(stderr, "This already was a v4 config. Please add the following line to your config file:\n"); fprintf(stderr, "# i3 config file (v4)\n"); - /* TODO: nag the user with a message to include a hint for i3 in his config file */ + /* TODO: nag the user with a message to include a hint for i3 in their config file */ } return NULL; } @@ -840,7 +840,7 @@ static char *migrate_config(char *input, off_t size) { * parse_config and possibly launching i3-nagbar. * */ -void parse_file(const char *f) { +bool parse_file(const char *f, bool use_nagbar) { SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables); int fd, ret, read_bytes = 0; struct stat stbuf; @@ -917,7 +917,7 @@ void parse_file(const char *f) { * variables (otherwise we will count them twice, which is bad when * 'extra' is negative) */ char *bufcopy = sstrdup(buf); - SLIST_FOREACH (current, &variables, variables) { + SLIST_FOREACH(current, &variables, variables) { int extra = (strlen(current->value) - strlen(current->key)); char *next; for (next = bufcopy; @@ -937,11 +937,11 @@ void parse_file(const char *f) { destwalk = new; while (walk < (buf + stbuf.st_size)) { /* Find the next variable */ - SLIST_FOREACH (current, &variables, variables) - current->next_match = strcasestr(walk, current->key); + SLIST_FOREACH(current, &variables, variables) + current->next_match = strcasestr(walk, current->key); nearest = NULL; int distance = stbuf.st_size; - SLIST_FOREACH (current, &variables, variables) { + SLIST_FOREACH(current, &variables, variables) { if (current->next_match == NULL) continue; if ((current->next_match - walk) < distance) { @@ -1000,7 +1000,7 @@ void parse_file(const char *f) { check_for_duplicate_bindings(context); - if (context->has_errors || context->has_warnings) { + if (use_nagbar && (context->has_errors || context->has_warnings)) { ELOG("FYI: You are using i3 version " I3_VERSION "\n"); if (version == 3) ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n"); @@ -1030,6 +1030,8 @@ void parse_file(const char *f) { free(pageraction); } + bool has_errors = context->has_errors; + FREE(context->line_copy); free(context); free(new); @@ -1042,6 +1044,8 @@ void parse_file(const char *f) { SLIST_REMOVE_HEAD(&variables, variables); FREE(current); } + + return !has_errors; } #endif