diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-12-09 11:52:55 +0000 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2019-01-01 09:01:24 +0000 |
commit | 967566e37f93890bd5255725129c929aeeac709e (patch) | |
tree | 7d6bc1470609b2c0da92889db36833cc2e5e8431 /sway | |
parent | 3b4cf3718b05d5ebd98d730abb742e82f8980287 (diff) |
stringop.c: rewrite strip_whitespace
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 6 | ||||
-rw-r--r-- | sway/config.c | 4 | ||||
-rw-r--r-- | sway/input/input-manager.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/sway/commands.c b/sway/commands.c index 927434bc..cd595b03 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -236,15 +236,15 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, criteria_destroy(criteria); config->handler_context.using_criteria = true; // Skip leading whitespace - head += strspn(head, whitespace); + for (; isspace(*head); ++head) {} } // Split command list cmdlist = argsep(&head, ";"); - cmdlist += strspn(cmdlist, whitespace); + for (; isspace(*cmdlist); ++cmdlist) {} do { // Split commands cmd = argsep(&cmdlist, ","); - cmd += strspn(cmd, whitespace); + for (; isspace(*cmd); ++cmd) {} if (strcmp(cmd, "") == 0) { wlr_log(WLR_INFO, "Ignoring empty command."); continue; diff --git a/sway/config.c b/sway/config.c index bb7f796d..c71f315a 100644 --- a/sway/config.c +++ b/sway/config.c @@ -580,7 +580,7 @@ static int detect_brace_on_following_line(FILE *file, char *line, free(peeked); peeked = peek_line(file, lines, &position); if (peeked) { - peeked = strip_whitespace(peeked); + strip_whitespace(peeked); } lines++; } while (peeked && strlen(peeked) == 0); @@ -663,7 +663,7 @@ bool read_config(FILE *file, struct sway_config *config, read += length + 1; } - line = strip_whitespace(line); + strip_whitespace(line); if (line[0] == '#') { free(line); continue; diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 61087733..04e14355 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -49,7 +49,7 @@ char *input_device_get_identifier(struct wlr_input_device *device) { int vendor = device->vendor; int product = device->product; char *name = strdup(device->name); - name = strip_whitespace(name); + strip_whitespace(name); char *p = name; for (; *p; ++p) { |