diff options
author | Ingo Bürk <admin@airblader.de> | 2019-04-07 13:14:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-07 13:14:05 +0200 |
commit | ae64e438aa9ead66a116f5163f5f67547aeb8b08 (patch) | |
tree | 8f9698902f2407986ea82f11d8abd941ddef7113 | |
parent | 1c410949e2d488d26e41cf0e534272e15fbcd9dc (diff) | |
parent | 85b8a6e51324795b7586be127c83511aa4796e70 (diff) |
Merge pull request #42 from Airblader/cleanup-1
chore: Small refactoring
-rw-r--r-- | src/util.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -21,16 +21,13 @@ long parse_int(char *str) { void parse_buttons_numbers(char *str, ignore_buttons_t *ignore_buttons) { char *button = strtok(str, ","); while (button != NULL) { - long number = atol(button); + long number = parse_int(button); button = strtok(NULL, ","); - if (number < 0 || number > UINT_MAX) { + if (number == -1) { continue; } ignore_buttons->count++; - if (ignore_buttons->count == UCHAR_MAX) { - bail("Too much buttons numbers"); - } unsigned int *buttons = (unsigned int *)realloc(ignore_buttons->buttons, ignore_buttons->count * sizeof(unsigned int)); if (buttons == NULL) { @@ -39,10 +36,11 @@ void parse_buttons_numbers(char *str, ignore_buttons_t *ignore_buttons) { } else { ignore_buttons->buttons = buttons; } + ignore_buttons->buttons[ignore_buttons->count - 1] = number; } - if (!ignore_buttons->count) { - bail("Amount of buttons to ignore = 0"); + if (ignore_buttons->count == 0) { + bail("--ignore-buttons was specified, but no button could be parsed."); } } |