diff options
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/apps/misc.c b/apps/misc.c index 51e02f6a62..4d7ddd57e6 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1220,6 +1220,7 @@ int hex_to_rgb(const char* hex, int* color) | |||
1220 | valid_vals - if not NULL 1 is set in the bitplace if the item was read OK | 1220 | valid_vals - if not NULL 1 is set in the bitplace if the item was read OK |
1221 | 0 if not read. | 1221 | 0 if not read. |
1222 | first item is LSB, (max 32 items! ) | 1222 | first item is LSB, (max 32 items! ) |
1223 | Stops parseing if an item is invalid unless the item == '-' | ||
1223 | sep - list separator (e.g. ',' or '|') | 1224 | sep - list separator (e.g. ',' or '|') |
1224 | str - string to parse, must be terminated by 0 or sep | 1225 | str - string to parse, must be terminated by 0 or sep |
1225 | ... - pointers to store the parsed values | 1226 | ... - pointers to store the parsed values |
@@ -1262,14 +1263,14 @@ const char* parse_list(const char *fmt, unsigned int *valid_vals, | |||
1262 | *s = p; | 1263 | *s = p; |
1263 | while (*p && *p != sep) | 1264 | while (*p && *p != sep) |
1264 | p++; | 1265 | p++; |
1265 | valid = (*s[0]!=sep); | 1266 | valid = (*s[0]!='-') && (*s[1]!=sep) ; |
1266 | break; | 1267 | break; |
1267 | 1268 | ||
1268 | case 'd': /* int */ | 1269 | case 'd': /* int */ |
1269 | d = va_arg(ap, int*); | 1270 | d = va_arg(ap, int*); |
1270 | if (!isdigit(*p)) | 1271 | if (!isdigit(*p)) |
1271 | { | 1272 | { |
1272 | if (!valid_vals) | 1273 | if (!valid_vals || *p != '-') |
1273 | goto err; | 1274 | goto err; |
1274 | while (*p && *p != sep) | 1275 | while (*p && *p != sep) |
1275 | p++; | 1276 | p++; |
@@ -1290,7 +1291,7 @@ const char* parse_list(const char *fmt, unsigned int *valid_vals, | |||
1290 | 1291 | ||
1291 | if (hex_to_rgb(p, d) < 0) | 1292 | if (hex_to_rgb(p, d) < 0) |
1292 | { | 1293 | { |
1293 | if (!valid_vals) | 1294 | if (!valid_vals || *p != '-') |
1294 | goto err; | 1295 | goto err; |
1295 | while (*p && *p != sep) | 1296 | while (*p && *p != sep) |
1296 | p++; | 1297 | p++; |
@@ -1313,7 +1314,7 @@ const char* parse_list(const char *fmt, unsigned int *valid_vals, | |||
1313 | *d = *p++ - '0'; | 1314 | *d = *p++ - '0'; |
1314 | valid = true; | 1315 | valid = true; |
1315 | } | 1316 | } |
1316 | else if (!valid_vals) | 1317 | else if (!valid_vals || *p != '-') |
1317 | goto err; | 1318 | goto err; |
1318 | else | 1319 | else |
1319 | { | 1320 | { |