nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gn...@apache.org
Subject [incubator-nuttx] branch master updated: Handling of struct initializers changed. Break conditionals with || at the end.
Date Fri, 13 Mar 2020 13:59:00 GMT
This is an automated email from the ASF dual-hosted git repository.

gnutt 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 645cf6d  Handling of struct initializers changed. Break conditionals with || at the
end.
645cf6d is described below

commit 645cf6d547cba8694c8598828037181f612b8231
Author: Johanne Schock <johannes.schock@nivus.com>
AuthorDate: Thu Mar 12 21:11:12 2020 +0100

    Handling of struct initializers changed.
    Break conditionals with || at the end.
---
 tools/nxstyle.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index f379724..da536f8 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -751,7 +751,8 @@ int main(int argc, char **argv, char **envp)
                * another right brace, or a pre-processor directive like #endif
                */
 
-              if (strchr(line, '}') == NULL && line[n] != '#' &&
+              if (dnest == 0 &&
+                  strchr(line, '}') == NULL && line[n] != '#' &&
                   strncmp(&line[n], "else", 4) != 0 &&
                   strncmp(&line[n], "while", 5) != 0 &&
                   strncmp(&line[n], "break", 5) != 0)
@@ -967,8 +968,8 @@ int main(int argc, char **argv, char **envp)
 
                   rhcomment = -1;
 
-                  if (ncomment > 0 && (!strncmp(&line[ii], "if", 2)
-                      || !strncmp(&line[ii], "el", 2)))
+                  if (ncomment > 0 && (strncmp(&line[ii], "if", 2) == 0 ||
+                      strncmp(&line[ii], "el", 2) == 0))
                     {
                       /* in #if...  and #el.. */
 
@@ -1608,7 +1609,7 @@ int main(int argc, char **argv, char **envp)
                       {
                         /* REVISIT: dnest is always > 0 here if bfunctions == false */
 
-                        if (dnest == 0 || !bfunctions)
+                        if (dnest == 0 || !bfunctions || lineno == rbrace_lineno)
                           {
                              ERROR("Left bracket not on separate line", lineno,
                                    n);
@@ -1754,6 +1755,13 @@ int main(int argc, char **argv, char **envp)
                                            lineno, endx);
                                   }
                               }
+                            else if (line[endx] == '=')
+                              {
+                                /* There's a struct initialization following */
+
+                                check_spaces_leftright(line, lineno, endx, endx);
+                                dnest = 1;
+                              }
                             else
                               {
                                  ERROR("Garbage follows right bracket",


Mime
View raw message