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.

This commit is contained in:
Simon Kampe 2011-04-07 12:58:45 +02:00 committed by Michael Stapelberg
parent 0330e868bc
commit 837bb50826

View File

@ -49,12 +49,11 @@ Con *workspace_get(const char *num, bool *created) {
workspace->name = sstrdup(num); workspace->name = sstrdup(num);
/* We set ->num to the number if this workspaces name consists only of /* We set ->num to the number if this workspaces name consists only of
* a positive number. Otherwise its a named ws and num will be -1. */ * a positive number. Otherwise its 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 || if (parsed_num == LONG_MIN ||
parsed_num == LONG_MAX || parsed_num == LONG_MAX ||
parsed_num < 0 || parsed_num <= 0)
(end && *end != '\0'))
workspace->num = -1; workspace->num = -1;
else workspace->num = parsed_num; else workspace->num = parsed_num;
LOG("num = %d\n", workspace->num); LOG("num = %d\n", workspace->num);