You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/03/07 14:31:46 UTC

[incubator-nuttx] branch master updated: nxstyle:nxstyle should pass nxstyle checks!

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 c5b4d9b  nxstyle:nxstyle should pass nxstyle checks!
c5b4d9b is described below

commit c5b4d9b628d466ac3cbebba6772afdb9f735ac97
Author: David Sidrane <Da...@NscDg.com>
AuthorDate: Sat Mar 7 05:35:08 2020 -0800

    nxstyle:nxstyle should pass nxstyle checks!
---
 tools/nxstyle.c | 93 ++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 52 insertions(+), 41 deletions(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 0ac395c..12834b1 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -1,4 +1,4 @@
-/****************************************************************************
+/********************************************************************************
  * tools/nxstyle.c
  *
  *   Copyright (C) 2015, 2018-2020 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- ****************************************************************************/
+ ********************************************************************************/
 
-/****************************************************************************
+/********************************************************************************
  * Included Files
- ****************************************************************************/
+ ********************************************************************************/
 
 #include <stdlib.h>
 #include <stdbool.h>
@@ -48,9 +48,9 @@
 #include <unistd.h>
 #include <libgen.h>
 
-/****************************************************************************
+/********************************************************************************
  * Pre-processor Definitions
- ****************************************************************************/
+ ********************************************************************************/
 
 #define NXSTYLE_VERSION "0.01"
 
@@ -69,9 +69,9 @@
 #define INFO(m, l, o)  message(INFO, (m), (l), (o))
 #define INFOFL(m, s)   message(INFO, (m), -1, -1)
 
-/****************************************************************************
+/********************************************************************************
  * Private types
- ****************************************************************************/
+ ********************************************************************************/
 
 enum class_e
 {
@@ -118,9 +118,9 @@ struct file_section_s
   uint8_t     ftype;  /* File type where section found */
 };
 
-/****************************************************************************
+/********************************************************************************
  * Private data
- ****************************************************************************/
+ ********************************************************************************/
 
 static char *g_file_name        = "";
 static enum file_e g_file_type  = UNKNOWN;
@@ -184,16 +184,16 @@ static const struct file_section_s g_section_info[] =
   }
 };
 
-/****************************************************************************
+/********************************************************************************
  * Private Functions
- ****************************************************************************/
+ ********************************************************************************/
 
-/****************************************************************************
+/********************************************************************************
  * Name: show_usage
  *
  * Description:
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static void show_usage(char *progname, int exitcode, char *what)
 {
@@ -203,22 +203,24 @@ static void show_usage(char *progname, int exitcode, char *what)
       fprintf(stderr, "%s\n", what);
     }
 
-  fprintf(stderr, "Usage:  %s [-m <excess>] [-v <level>] [-r <start,count>] <filename>\n",
+  fprintf(stderr, "Usage:  %s [-m <excess>] [-v <level>] "
+                  "[-r <start,count>] <filename>\n",
           basename(progname));
   fprintf(stderr, "        %s -h this help\n", basename(progname));
-  fprintf(stderr, "        %s -v <level> where level is\n", basename(progname));
+  fprintf(stderr, "        %s -v <level> where level is\n",
+          basename(progname));
   fprintf(stderr, "                   0 - no output\n");
   fprintf(stderr, "                   1 - PASS/FAIL\n");
   fprintf(stderr, "                   2 - output each line (default)\n");
   exit(exitcode);
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: skip
  *
  * Description:
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static int skip(int lineno)
 {
@@ -226,7 +228,8 @@ static int skip(int lineno)
 
   for (i = 0; i < g_rangenumber; i++)
     {
-      if (lineno >= g_rangestart[i] && lineno < g_rangestart[i] + g_rangecount[i])
+      if (lineno >= g_rangestart[i] && lineno < g_rangestart[i] +
+          g_rangecount[i])
         {
           return 0;
         }
@@ -235,12 +238,12 @@ static int skip(int lineno)
   return g_rangenumber != 0;
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: message
  *
  * Description:
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static int message(enum class_e class, const char *text, int lineno, int ndx)
 {
@@ -273,12 +276,12 @@ static int message(enum class_e class, const char *text, int lineno, int ndx)
   return g_status;
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: check_spaces_left
  *
  * Description:
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static void check_spaces_left(char *line, int lineno, int ndx)
 {
@@ -294,12 +297,12 @@ static void check_spaces_left(char *line, int lineno, int ndx)
     }
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: check_spaces_leftright
  *
  * Description:
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static void check_spaces_leftright(char *line, int lineno, int ndx1, int ndx2)
 {
@@ -316,13 +319,13 @@ static void check_spaces_leftright(char *line, int lineno, int ndx1, int ndx2)
     }
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: block_comment_width
  *
  * Description:
  *   Get the width of a block comment
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static int block_comment_width(char *line)
 {
@@ -393,13 +396,13 @@ static int block_comment_width(char *line)
   return 0;
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name: get_line_width
  *
  * Description:
  *   Get the maximum line width by examining the width of the block comments.
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static int get_line_width(FILE *instream)
 {
@@ -446,13 +449,13 @@ static int get_line_width(FILE *instream)
   return min;
 }
 
-/****************************************************************************
+/********************************************************************************
  * Name:  check_section_header
  *
  * Description:
  *   Check if the current line holds a section header
  *
- ****************************************************************************/
+ ********************************************************************************/
 
 static bool check_section_header(const char *line, int lineno)
 {
@@ -480,9 +483,9 @@ static bool check_section_header(const char *line, int lineno)
   return false;
 }
 
-/****************************************************************************
+/********************************************************************************
  * Public Functions
- ****************************************************************************/
+ ********************************************************************************/
 
 int main(int argc, char **argv, char **envp)
 {
@@ -623,7 +626,8 @@ int main(int argc, char **argv, char **envp)
   ppline         = false; /* True: Continuation of a pre-processor line */
   bexternc       = false; /* True: Within 'extern "C"' */
   brhcomment     = false; /* True: Comment to the right of code */
-  prevbrhcmt     = false; /* True: Previous line had comment to the right of code */
+  prevbrhcmt     = false; /* True: Previous line had comment to the right
+                           * of code */
   lineno         = 0;     /* Current line number */
   ncomment       = 0;     /* Comment nesting level on this line */
   bnest          = 0;     /* Brace nesting level on this line */
@@ -643,12 +647,16 @@ int main(int argc, char **argv, char **envp)
       lineno++;
       indent       = 0;
       prevbnest    = bnest;    /* Brace nesting level on the previous line */
-      prevdnest    = dnest;    /* Data declaration nesting level on the previous line */
+      prevdnest    = dnest;    /* Data declaration nesting level on the
+                                * previous line */
       prevncomment = ncomment; /* Comment nesting level on the previous line */
-      bstatm       = false;    /* True: This line is beginning of a statement */
+      bstatm       = false;    /* True: This line is beginning of a
+                                * statement */
       bfor         = false;    /* REVISIT: Implies for() is all on one line */
 
-      /* If we are not in a comment, then this certainly is not a right-hand comment. */
+      /* If we are not in a comment, then this certainly is not a right-hand
+       * comment.
+       */
 
       prevbrhcmt   = brhcomment;
       if (ncomment <= 0)
@@ -934,7 +942,9 @@ int main(int argc, char **argv, char **envp)
                   noblank_lineno != lineno - 1 &&
                   !brhcomment)
                 {
-                  /* TODO:  This generates a false alarm if preceded by a label. */
+                  /* TODO:  This generates a false alarm if preceded
+                   * by a label.
+                   */
 
                    ERROR("Missing blank line before comment found", lineno, 1);
                 }
@@ -2224,10 +2234,11 @@ int main(int argc, char **argv, char **envp)
                 {
                   /* REVISIT: Generates false alarms on comments at the end of
                    * the line if there is nothing preceding (such as the aligned
-                   * comments with a structure field definition).  So disabled for
-                   * comments before beginning of function definitions.
+                   * comments with a structure field definition).  So disabled
+                   * for comments before beginning of function definitions.
                    *
-                   * Suppress this error if this is a comment to the right of code.
+                   * Suppress this error if this is a comment to the right of
+                   * code.
                    * Those may be unaligned.
                    */