Skip to content

Commit

Permalink
#739 remove silly restriction for space labels
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Nov 30, 2020
1 parent b6b495c commit 81e55d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Space/Window commands that utilize the scripting addition should correctly return a non-zero exit code upon failure [#181](https://github.com/koekeishiya/yabai/issues/181)
- Undo [#545](https://github.com/koekeishiya/yabai/issues/545) because it created weird issues with focus [#660](https://github.com/koekeishiya/yabai/issues/660)
- Allow enabling/disabling *mouse_follows_focus* for specific windows using rules, overriding the global setting [#675](https://github.com/koekeishiya/yabai/issues/675)
- Space labels are now allowed to start with a digit, as long as it is followed by at least one or more non-digit character(s) [#739](https://github.com/koekeishiya/yabai/issues/739)

## [3.3.4] - 2020-11-14
### Changed
Expand Down
19 changes: 15 additions & 4 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,17 @@ static bool token_is_float(struct token token, float *value)
char buffer[token.length + 1];
memcpy(buffer, token.text, token.length);
buffer[token.length] = '\0';
return sscanf(buffer, "%f", value) == 1;

char *end = NULL;
float v = strtof(buffer, &end);

if (!end || *end) {
*value = 0.0f;
return false;
} else {
*value = v;
return true;
}
}

static char *token_to_string(struct token token, bool temp)
Expand Down Expand Up @@ -460,14 +470,15 @@ static char *reserved_space_identifiers[] =
static bool parse_label(FILE *rsp, char **message, enum label_type type, char **label)
{
struct token token = get_token(message);
struct token_value value = token_to_value(token, false);

if (!token_is_valid(token)) {
if (value.type == TOKEN_TYPE_INVALID) {
*label = NULL;
return true;
}

if ((token.text[0] >= '0' && token.text[0] <= '9')) {
daemon_fail(rsp, "'%.*s' is not a valid label.\n", token.length, token.text);
if (value.type != TOKEN_TYPE_STRING) {
daemon_fail(rsp, "'%.*s' cannot be used as a label.\n", token.length, token.text);
return false;
}

Expand Down

0 comments on commit 81e55d7

Please sign in to comment.