diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 0ddfb4bda1d..0c19c5e0b19 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -209,6 +209,14 @@ static const char *g_white_prefix[] = NULL }; +static const char *g_white_suffix[] = +{ + "kHz", + "Mbps", + "us", + NULL +}; + static const char *g_white_list[] = { /* Ref: gnu_unwind_find_exidx.c */ @@ -715,12 +723,32 @@ static bool white_list(const char *ident, int lineno) { const char **pptr; const char *str; + size_t len2; + size_t len; for (pptr = g_white_prefix; (str = *pptr) != NULL; pptr++) { - if (strncmp(ident, str, strlen(str)) == 0) + len = strlen(str); + if (strncmp(ident, str, len) == 0) + { + return true; + } + } + + len2 = strlen(ident); + while (!isalnum(ident[len2])) + { + len2--; + } + + for (pptr = g_white_suffix; + (str = *pptr) != NULL; + pptr++) + { + len = strlen(str); + if (len2 >= len && strncmp(ident + len2 - len, str, len) == 0) { return true; } @@ -730,8 +758,7 @@ static bool white_list(const char *ident, int lineno) (str = *pptr) != NULL; pptr++) { - size_t len = strlen(str); - + len = strlen(str); if (strncmp(ident, str, len) == 0 && isalnum(ident[len]) == 0) {