diff options
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/parser.c b/src/parser.c index e5f7944..6ee0d6e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -236,32 +236,46 @@ found: } char *win = strip(rest); - - int count = 0; - for (char *p = win; *p; p++) { - if (*p == ',') { - count++; - } - } - cfg->should_float[should_floatn] = malloc((count + 2) * sizeof(char *)); - - // split by commas - char *comma = strtok(win, ","); + cfg->should_float[should_floatn] = malloc(256 * sizeof(char *)); - int i = 0; + char *comma_ptr, *space_ptr; + char *comma = strtok_r(win, ",", &comma_ptr); while (comma) { if (should_floatn < 256) { - cfg->should_float[should_floatn][i] = strdup(comma); - i++; + // if comma starts and ends with quotes, remove them + if (*comma == '"') { + comma++; + } + char *end = comma + strlen(comma) - 1; + if (*end == '"') { + *end = '\0'; + } + + printf("comma: %s\n", comma); + char *argv = strtok_r(comma, " ", &space_ptr); + int i = 0; + + + while (argv) { + printf("argv: %s\n", argv); + cfg->should_float[should_floatn][i] = strdup(argv); + argv = strtok_r(NULL, " ", &space_ptr); + i++; + } + + should_floatn++; + cfg->should_float[should_floatn] = malloc(256 * sizeof(char *)); + } else { fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno); break; } - comma = strtok(NULL, ","); + comma = strtok_r(NULL, ",", &comma_ptr); } + should_floatn++; } else if (!strcmp(key, "call") || !strcmp(key, "bind")) { @@ -345,6 +359,15 @@ found: } } + // print should_float + for (int i = 0; i < should_floatn; i++) { + fprintf(stderr, "sxwmrc: should_float[%d]: ", i); + for (int j = 0; cfg->should_float[i][j]; j++) { + fprintf(stderr, "%s ", cfg->should_float[i][j]); + } + fprintf(stderr, "\n"); + } + fclose(f); remap_and_dedupe_binds(cfg); return 0; |
