c39ba47f61
live in scr050) and brought them up to date, some minor fixes along the way. A few tests don't work properly, I've noted those in the TODO file for some other time.
86 lines
1.3 KiB
Bash
86 lines
1.3 KiB
Bash
#!/bin/sh -
|
|
#
|
|
# Look for trailing commas in declarations. Some compilers can't handle:
|
|
# enum {
|
|
# foo,
|
|
# bar,
|
|
# };
|
|
|
|
# Top-level directory.
|
|
d=../..
|
|
|
|
# Path names are from a top-level directory.
|
|
[ -f $d/README ] || {
|
|
echo 'FAIL: cannot find source distribution directory.'
|
|
exit 1
|
|
}
|
|
|
|
trap 'rm -f t t.c' 0 1 2 3 13 15
|
|
|
|
cat << END_OF_CODE > t.c
|
|
#include <sys/types.h>
|
|
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
extern int isblank(int c);
|
|
|
|
int
|
|
chk(f)
|
|
char *f;
|
|
{
|
|
int ch, l, r;
|
|
|
|
if (freopen(f, "r", stdin) == NULL) {
|
|
fprintf(stderr, "%s: %s\n", f, strerror(errno));
|
|
exit (1);
|
|
}
|
|
for (l = 1, r = 0; (ch = getchar()) != EOF;) {
|
|
if (ch != ',')
|
|
goto next;
|
|
do { ch = getchar(); } while (isblank(ch));
|
|
if (ch != '\n')
|
|
goto next;
|
|
++l;
|
|
do { ch = getchar(); } while (isblank(ch));
|
|
if (ch != '}')
|
|
goto next;
|
|
r = 1;
|
|
printf("%s: line %d\n", f, l);
|
|
|
|
next: if (ch == '\n')
|
|
++l;
|
|
}
|
|
return (r);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
int r;
|
|
|
|
for (r = 0; *++argv != NULL;)
|
|
if (chk(*argv))
|
|
r = 1;
|
|
return (r);
|
|
}
|
|
END_OF_CODE
|
|
|
|
if cc -g -Wall -I.. t.c -o t; then
|
|
:
|
|
else
|
|
echo "FAIL: unable to compile test program t.c"
|
|
exit 1
|
|
fi
|
|
|
|
if ./t `find $d -name '*.[ch]' -o -name '*.in'` ; then
|
|
:
|
|
else
|
|
echo "FAIL: test program failed, it found trailing commas"
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|