You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/13 13:39:22 UTC
[incubator-nuttx] branch master updated: tools/nxstyle: Add the suffix white list
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 317cc6c174 tools/nxstyle: Add the suffix white list
317cc6c174 is described below
commit 317cc6c174619d533c75aa473d51c9feb901b41f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 13 10:46:52 2022 +0800
tools/nxstyle: Add the suffix white list
and initialize it to "kHz", "Mbps", and "us"
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
tools/nxstyle.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 0ddfb4bda1..0c19c5e0b1 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,23 +723,42 @@ 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;
}
}
- for (pptr = g_white_list;
+ len2 = strlen(ident);
+ while (!isalnum(ident[len2]))
+ {
+ len2--;
+ }
+
+ for (pptr = g_white_suffix;
(str = *pptr) != NULL;
pptr++)
{
- size_t len = strlen(str);
+ len = strlen(str);
+ if (len2 >= len && strncmp(ident + len2 - len, str, len) == 0)
+ {
+ return true;
+ }
+ }
+ for (pptr = g_white_list;
+ (str = *pptr) != NULL;
+ pptr++)
+ {
+ len = strlen(str);
if (strncmp(ident, str, len) == 0 &&
isalnum(ident[len]) == 0)
{