Greg,  I'll finish the nxstyle & check script these days firstly and then
take time to handle the two issues you mentioned if allowed. I wish I could
be competent to take over full responsibility for nxstyle.c.

I think it would be great if you took over primary responsibility for nxstyle.  With regard to the additional features I was planning to add, I do have a design in mind for the automatic line width detection.

For auto-detecting the line width, I was thinking of adding two additional passes through the file (frewind-ing to the beginning of the file after each pass).

The first pass would check the width of all block comments. Perhaps a function called block_comment_width() could be called for each line.  It would return zero if the line is not the first or last line of a block comment and the position of the final '*' + 1  if is it is a block comment.

The first pass would call block_comment_width() to find the minimum and maximum line width.  If the minimum != maximum, then there is a problem

The second pass would only be necessary if minimum != maximum and would just call block_comment_width() again to list the block comments that have the inconsistent line width.

I would also re-interpret the -m option.  I would make this be the number of bytes that I would permit the line to extend beyond the last '*' in the block comment.  So if the line width is 78, the -m 86 with the old tool would be equivalent to -m 8 with the modified tool.


We probabaly should talk about how to test nxstyle as well. There are two possible errors:  (1) False negative:  When nxstyle failes to detect an error in the file. and (2) flase positive: When nystyle complains about error when there is no error.

For (1) false negatives, I just create a few simple test files and verify that nxstyle detects the error. Pretty easy.

For (2) false positives, it is a little more difficult.  I use nuttx/sched to do these because it probably follows the coding standard the best.  I use a little script like (let's call it schedtest.sh:

   #!/bin/bash

   FILELIST=`find sched -name "*.c"`

   make -C tools -f Makefile.host nxstyle

   for file in $FILELIST; do
      tools/nxstyle -m 86 $file
   done

The -m 86 is just so I won't be bothered by lines that are a little too long.

Then I use the script this way:

   $ git stash
   $ ./schedtest.sh 1>before.log 2>&1
   $ git stash pop
   $ ./schedtest.sh 1>after.log 2>&1

Then compare before.log and after.log.  They should be identical UNLESS the new version of nxstyle detects a new coding standard violation.

Greg


Reply via email to