From: Simon Kampe Date: Thu, 7 Apr 2011 10:58:45 +0000 (+0200) Subject: Parsing workspace name so if the first part is a number, the workspace will get this... X-Git-Tag: 4.1~243^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=837bb50826d97b9d5c9cf5a39e486e384762629b;p=i3%2Fi3 Parsing workspace name so if the first part is a number, the workspace will get this number. If no number is found it will default to -1. --- diff --git a/src/workspace.c b/src/workspace.c index 2fe96304..d3d2a8e2 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -49,12 +49,11 @@ Con *workspace_get(const char *num, bool *created) { workspace->name = sstrdup(num); /* We set ->num to the number if this workspace’s name consists only of * a positive number. Otherwise it’s a named ws and num will be -1. */ - char *end; - long parsed_num = strtol(num, &end, 10); + + long parsed_num = strtol(num, NULL, 10); if (parsed_num == LONG_MIN || parsed_num == LONG_MAX || - parsed_num < 0 || - (end && *end != '\0')) + parsed_num <= 0) workspace->num = -1; else workspace->num = parsed_num; LOG("num = %d\n", workspace->num);