This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 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 981d44f446a tools/nxstyle: allow a macro taking a block to span 
several lines
981d44f446a is described below

commit 981d44f446ab6ccfcb9ef29e637f6855a3840579
Author: raiden00pl <[email protected]>
AuthorDate: Mon Jul 27 12:20:13 2026 +0200

    tools/nxstyle: allow a macro taking a block to span several lines
    
    The brace was compared against the line before it rather than the line
    the statement began on, so a macro broken over two lines was reported.
    
    Signed-off-by: raiden00pl <[email protected]>
    Assisted-by: Claude Code
---
 tools/nxstyle.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 94970292cd0..60856b30b46 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -1452,6 +1452,7 @@ int main(int argc, char **argv, char **envp)
   char lastcode;        /* Last code character seen on this line */
   char prevlastcode;    /* Last code character on the preceding line */
   int prevcodeindent;   /* Indentation of the preceding line of code */
+  int stmt_lineindent;  /* Indentation of the line starting that statement */
   bool bfuncbody;       /* True: The outermost brace opened a function body */
   int stmt_indent;      /* Expected indentation of a statement, or -1 */
   int case_indent;      /* Expected indentation of a 'case' label, or -1 */
@@ -1582,6 +1583,7 @@ int main(int argc, char **argv, char **envp)
   lastcode       = '\0';        /* Last code character seen on this line */
   prevlastcode   = '\0';        /* Last code character on the preceding line */
   prevcodeindent = 0;           /* Indentation of the preceding line of code */
+  stmt_lineindent = 0;          /* Indentation where that statement began */
   bfuncbody      = false;       /* True: Inside the body of a function */
   stmt_indent    = 0;           /* Expected indentation of a statement */
   case_indent    = -1;          /* Expected indentation of a 'case' label */
@@ -4041,7 +4043,9 @@ int main(int argc, char **argv, char **envp)
                * that way.
                */
 
-              else if (prevlastcode == ')' && indent == prevcodeindent + 2)
+              else if (prevlastcode == ')' &&
+                       (indent == prevcodeindent + 2 ||
+                        indent == stmt_lineindent + 2))
                 {
                 }
               else if (indent > 0 && dnest == 0 &&
@@ -4134,6 +4138,11 @@ int main(int argc, char **argv, char **envp)
         {
           prevlastcode   = lastcode;
           prevcodeindent = indent;
+
+          if (bstmtstart)
+            {
+              stmt_lineindent = indent;
+            }
         }
     }
 

Reply via email to