This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b3b8ec35a6 tools/nxstyle: can use ',' in the string when declaring it
b3b8ec35a6 is described below
commit b3b8ec35a6a6717c162c0639bd8914c2ed5aff60
Author: yangjian11 <[email protected]>
AuthorDate: Fri Jan 26 15:06:23 2024 +0800
tools/nxstyle: can use ',' in the string when declaring it
Signed-off-by: yangjian11 <[email protected]>
---
tools/nxstyle.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index bce1c63255..d2d2b976ce 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -1860,6 +1860,7 @@ int main(int argc, char **argv, char **envp)
if (pnest == 0)
{
int tmppnest;
+ bool tmpbstring;
/* Note, we have not yet parsed each character on the line so
* a comma have have been be preceded by '(' on the same
line.
@@ -1867,11 +1868,11 @@ int main(int argc, char **argv, char **envp)
* case.
*/
- for (i = indent, tmppnest = 0;
+ for (i = indent, tmppnest = 0, tmpbstring = false;
line[i] != '\n' && line[i] != '\0';
i++)
{
- if (tmppnest == 0 && line[i] == ',')
+ if (tmppnest == 0 && !tmpbstring && line[i] == ',')
{
ERROR("Multiple data definitions", lineno, i + 1);
break;
@@ -1891,6 +1892,10 @@ int main(int argc, char **argv, char **envp)
tmppnest--;
}
+ else if (line[i] == '"')
+ {
+ tmpbstring = !tmpbstring;
+ }
else if (line[i] == ';')
{
/* Break out if the semicolon terminates the