Add toosl/nxstyle.c

This commit is contained in:
Gregory Nutt
2015-10-08 12:48:40 -06:00
parent e91f82b0f8
commit cc35c0c49d
5 changed files with 1027 additions and 3 deletions
+2
View File
@@ -11015,4 +11015,6 @@
From Pierre-noel Bouteville (2015-10-07).
* fs/tmpfs: Created a directory that will eventually hold a trivial
temporary RAM file file system (2015-10-0i8).
* tools/: Add crappy style checking tool nxstyle.c. See thee tools/
README file for more info (2015-10-08).
+1
View File
@@ -36,6 +36,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
+13 -3
View File
@@ -1,7 +1,7 @@
############################################################################
# Makefile.host
#
# Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2007, 2008, 2011-2012, 2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@@ -61,8 +61,9 @@ endif
# Targets
all: b16$(HOSTEXEEXT) bdf-converter$(HOSTEXEEXT) cmpconfig$(HOSTEXEEXT) \
configure$(HOSTEXEEXT) mkconfig$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT) mksymtab$(HOSTEXEEXT) \
mksyscall$(HOSTEXEEXT) mkversion$(HOSTEXEEXT)
configure$(HOSTEXEEXT) mkconfig$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT) \
mksymtab$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkversion$(HOSTEXEEXT) \
nxstyle$(HOSTEXEEXT)
default: mkconfig$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT)
ifdef HOSTEXEEXT
@@ -152,6 +153,15 @@ ifdef HOSTEXEEXT
bdf-converter: bdf-converter$(HOSTEXEEXT)
endif
# nxsytle - Check a file for compliance to NuttX coding style
nxstyle$(HOSTEXEEXT): nxstyle.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o nxstyle$(HOSTEXEEXT) nxstyle.c
ifdef HOSTEXEEXT
nxstyle: nxstyle$(HOSTEXEEXT)
endif
# Create dependencies for a list of files
mkdeps$(HOSTEXEEXT): mkdeps.c csvparser.c
+24
View File
@@ -210,6 +210,30 @@ mkctags.sh
A script for creating ctags from Ken Pettit. See http://en.wikipedia.org/wiki/Ctags
and http://ctags.sourceforge.net/
nxstyle.c
---------
I am embarassed that this is here. This program is a complete hack
but, unfortunately, it has become so useful to me that I need to keep
it here.
A little background: I have tinkered with pretty printers for some
time and have not been happy with the results. An alternative that
occurred to me would be just a standard checker that examines a C
file that gives warnings for violations of the coding standard.
This turns out to be more difficult that you might think. A pretty
printer understands C syntax: They break the file up into its C
components then reassembles the output in the format. But parsing the
C loses the original file layout and so it not useful in this case.
This program instead, uses a collection of heuristics (i.e., hacks and
bandaids) to examine the C file for obvious violations of the coding
standard. This program is completely ignorant of C syntax; it simply
performs crude pattern matching to check the file.
Usage: nxstyle <path-to-file-to-check>
pic32mx
-------
+987
View File
File diff suppressed because it is too large Load Diff