diff options
| author | werdl <werdl_is_cool@outlook.com> | 2025-05-19 06:55:25 +0100 |
|---|---|---|
| committer | werdl <werdl_is_cool@outlook.com> | 2025-05-19 06:55:25 +0100 |
| commit | a77d543af2e6ccf5b53fe92761f7ac67c53dddb8 (patch) | |
| tree | 471f7695b50345583efedea8c70c828cd958a521 /src/parser.c | |
| parent | 1cc240aebc49a4bf58a6821705a2f37a7882157a (diff) | |
multiple should_float entries preliminary work
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/parser.c b/src/parser.c index 1ceb7e0..e5f7944 100644 --- a/src/parser.c +++ b/src/parser.c @@ -228,7 +228,7 @@ found: cfg->snap_distance = atoi(rest); } else if (!strcmp(key, "should_float")) { - // should_float: <window> + // should_float: binary --arg,binary2 parameter --arg,binary3 if (should_floatn >= 256) { fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno); @@ -237,13 +237,31 @@ found: char *win = strip(rest); - cfg->should_float[should_floatn] = malloc(strlen(win) + 1); - if (!cfg->should_float[should_floatn]) { - fprintf(stderr, "sxwmrc:%d: out of memory\n", lineno); - break; + 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, ","); + + int i = 0; + + while (comma) { + if (should_floatn < 256) { + cfg->should_float[should_floatn][i] = strdup(comma); + i++; + } else { + fprintf(stderr, "sxwmrc:%d: too many should_float entries\n", lineno); + break; + } + comma = strtok(NULL, ","); } - strcpy(cfg->should_float[should_floatn], win); should_floatn++; } else if (!strcmp(key, "call") || !strcmp(key, "bind")) { |
