if (strncmp(var->name, "packed:", 7) != 0)
return false;
- const char *token = var->name + 7;
+ char *list = strdup(var->name + 7);
+ assert(list);
+
+ bool found = false;
+ char *saveptr;
+ char *token = strtok_r(list, ",", &saveptr);
while (token) {
- const char *next_token = strchr(list, ' ');
- if (next_token) {
- len = token - next_token;
- next_token++;
- } else {
- len = strlen(token);
+ if (strcmp(token, name) == 0) {
+ found = true;
+ break;
}
- if (strncmp(token, name, MAX2(len, strlen(name)) == 0)
- return true;
-
- token = next_token;
+ token = strtok_r(NULL, ",", &saveptr);
}
- return false;
+ free(list);
+ return found;
}
/**