#DEBUG=-ggdb
CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline $(DEBUG)
-all: bin/box bin/iwrapper bin/md5crypt
+all: bin/box bin/iwrapper bin/md5crypt bin/pedant
bin/%: src/%.o
$(CC) $(LDFLAGS) -o $@ $^
bin/box: src/box.o
bin/iwrapper: src/iwrapper.o
bin/md5crypt: src/md5crypt.o src/md5.o
+bin/pedant: src/pedant.o
clean:
rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core`
--- /dev/null
+/*
+ * A Pedantic Check of Text Input/Output File Syntax
+ *
+ * (c) 2005 Martin Mares <mj@ucw.cz>
+ */
+
+#include <stdio.h>
+
+int main(void)
+{
+ int line = 1;
+ int pos = 0;
+ int maxlen = 0;
+ int lastlen = -1;
+ int space = 0;
+ int c;
+ while ((c = getchar()) >= 0)
+ {
+ if (c == '\n')
+ {
+ if (space)
+ printf("Line %d: Trailing spaces\n", line);
+ if (line == 1 && !pos)
+ printf("Line %d: Leading empty line\n", line);
+ if (maxlen < pos)
+ maxlen = pos;
+ if (!lastlen && !pos)
+ printf("Line %d: Consecutive empty lines\n", line);
+ lastlen = pos;
+ line++;
+ pos = space = 0;
+ }
+ else
+ {
+ if (c == ' ')
+ {
+ if (!pos)
+ printf("Line %d: Leading spaces\n", line);
+ if (space)
+ printf("Line %d: Consecutive spaces\n", line);
+ space = 1;
+ }
+ else
+ {
+ space = 0;
+ if (c < ' ' || c >= 0x7f)
+ printf("Line %d: Invalid character 0x%02x\n", line, c);
+ }
+ pos++;
+ }
+ }
+ if (pos)
+ printf("Line %d: Incomplete line at the end of file\n", line);
+ else if (!lastlen)
+ printf("Line %d: Trailing empty line\n", line-1);
+ printf("Found %d lines, the longest has %d chars\n", line-1, maxlen);
+ return 0;
+}