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

acassis pushed a commit to branch pr173
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/pr173 by this push:
     new 94483cf  tools/nxstyle.c:  Add logic to detect check for left brace in 
first column, but preceded by a blank line.  That should never happen for the 
outermost opening branch (but could happen with internal compound statements).
94483cf is described below

commit 94483cf400199f81dc7a4a8f80b0560fba790e03
Author: Gregory Nutt <[email protected]>
AuthorDate: Tue Jan 28 09:17:49 2020 -0600

    tools/nxstyle.c:  Add logic to detect check for left brace in first column, 
but preceded by a blank line.  That should never happen for the outermost 
opening branch (but could happen with internal compound statements).
    
    Consider junk.c for example:
    
        
/****************************************************************************
         * xx
         
****************************************************************************/
    
        
/****************************************************************************
         * Private Types
         
****************************************************************************/
    
        struct foo_s
    
        {
          int bar;
        };
    
        
/****************************************************************************
         * Public Functions
         
****************************************************************************/
    
        int dofoo(int barin)
    
        {
          barout = barin;
          return barout;
        }
    
    nxstyle not detects these problems:
    
        $ tools/nxstyle.exe junk.c
        junk.c:11:0: error: Blank line before opening left brace
        junk.c:21:0: error: Blank line before opening left brace
---
 tools/nxstyle.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 9592382..b2bb33f 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -2269,12 +2269,22 @@ int main(int argc, char **argv, char **envp)
             }
           else if (line[indent] == '{')
             {
+              /* Check for left brace in first column, but preceded by a
+               * blank line.  Should never happen (but could happen with
+               * internal compound statements).
+               */
+
+              if (indent == 0 && lineno == blank_lineno + 1)
+                {
+                  ERROR("Blank line before opening left brace", lineno, 
indent);
+                }
+
               /* REVISIT:  Possible false alarms in compound statements
                * without a preceding conditional.  That usage often violates
                * the coding standard.
                */
 
-              if (!bfunctions && (indent & 1) != 0)
+              else if (!bfunctions && (indent & 1) != 0)
                 {
                   ERROR("Bad left brace alignment", lineno, indent);
                 }

Reply via email to