rewrite model_bin_match(), rename --> model_name_match()

This commit is contained in:
rlar
2014-08-09 18:17:34 +02:00
parent a7dd20f5ca
commit b663731379
4 changed files with 49 additions and 81 deletions
+39
View File
@@ -680,3 +680,42 @@ get_comma_separated_values( char *values[], char *str ) {
values[count++] = strdup(str);
return count;
}
/*
check if the given token matches a model name
either exact
or
modulo a trailing model binning extension '\.[0-9]+'
*/
bool
model_name_match(const char *token, const char *model_name)
{
const char *p;
size_t token_len = strlen(token);
if (strncmp(token, model_name, token_len) != 0)
return FALSE;
p = model_name + token_len;
// exact match
if (*p == '\0')
return TRUE;
// check for .
if (*p++ != '.')
return FALSE;
// minimum one trailing char
if (*p == '\0')
return FALSE;
// all of them digits
for (; *p; p++)
if (!isdigit(*p))
return FALSE;
return TRUE;
}