pedansee
Pedansee checks C source files for compliance with a particular programming style. The style is currently defined by the pedansee source code in the form of functions which walk each source file’s syntax tree. You can modify some aspects of this style through the use of regular expressions.
For example, given the following silly program stored at silly.c:
#include <stdio.h>
#include <glib.h>
float pi = 3.14;
static void foo(void)
{
}
int main(int argc, char *argv)
{
foo();
g_print("Hello, world!\n");
}
you could run pedansee in the following way, producing the indicated effect:
$ pedansee silly.c -- -I/usr/include/glib-2.0/ -I/usr/lib64/glib-2.0/include/
silly.c:4:7 id pi does not start with silly_
silly.c:6:13 static id silly does not start with '_'
silly.c:6:13 function silly name not on column one
silly.c:10:5 function main name not on column one
Pedansee prefers that silly.c instead contain:
#include <stdio.h>
#include <glib.h>
float silly_pi = 3.14;
static void
_foo(void)
{
}
int
main(int argc, char *argv)
{
_foo();
g_print("Hello, world!\n");
}
Pedansee supports configuration files which allow you to configure some aspects of its style. For example, the following pedansee.conf defines the form static, constant, and exported symbols must follow:
[regex]
const = [A-Za-z_]*
static = _[A-Za-z_]*
exported = [^_][A-Za-z_]*
The pedansee project is also available as a Git repository. To clone the repository, execute
git clone https://www.flyn.org/git/pedansee