summaryrefslogtreecommitdiff
path: root/db/test/scr005/chk.nl
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-10-15 03:47:21 +0000
committerjbj <devnull@localhost>2001-10-15 03:47:21 +0000
commitdb7110722d3317cc81dd11c104dd45ac8c328e20 (patch)
treeacc2fe412f5d1f7e3d3fd35993fd3fd5cc20a7f3 /db/test/scr005/chk.nl
parent033e2a186a797374caeb2295a00dee5eef202ffc (diff)
downloadlibrpm-tizen-db7110722d3317cc81dd11c104dd45ac8c328e20.tar.gz
librpm-tizen-db7110722d3317cc81dd11c104dd45ac8c328e20.tar.bz2
librpm-tizen-db7110722d3317cc81dd11c104dd45ac8c328e20.zip
Initial revision
CVS patchset: 5110 CVS date: 2001/10/15 03:47:21
Diffstat (limited to 'db/test/scr005/chk.nl')
-rw-r--r--db/test/scr005/chk.nl100
1 files changed, 100 insertions, 0 deletions
diff --git a/db/test/scr005/chk.nl b/db/test/scr005/chk.nl
new file mode 100644
index 000000000..876be2f94
--- /dev/null
+++ b/db/test/scr005/chk.nl
@@ -0,0 +1,100 @@
+#!/bin/sh -
+#
+# Id: chk.nl,v 1.5 2001/10/12 17:55:33 bostic Exp
+#
+# Check to make sure that there are no trailing newlines in __db_err calls.
+
+d=../..
+
+[ -f $d/README ] || {
+ echo "FAIL: chk.nl can't find the source directory."
+ exit 1
+}
+
+cat << END_OF_CODE > t.c
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+int chk(FILE *, char *);
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ FILE *fp;
+ int exitv;
+
+ for (exitv = 0; *++argv != NULL;) {
+ if ((fp = fopen(*argv, "r")) == NULL) {
+ fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
+ return (1);
+ }
+ if (chk(fp, *argv))
+ exitv = 1;
+ (void)fclose(fp);
+ }
+ return (exitv);
+}
+
+int
+chk(fp, name)
+ FILE *fp;
+ char *name;
+{
+ int ch, exitv, line, q;
+
+ exitv = 0;
+ for (ch = 'a', line = 1;;) {
+ if ((ch = getc(fp)) == EOF)
+ return (exitv);
+ if (ch == '\n') {
+ ++line;
+ continue;
+ }
+ if (ch != '_') continue;
+ if ((ch = getc(fp)) != '_') continue;
+ if ((ch = getc(fp)) != 'd') continue;
+ if ((ch = getc(fp)) != 'b') continue;
+ if ((ch = getc(fp)) != '_') continue;
+ if ((ch = getc(fp)) != 'e') continue;
+ if ((ch = getc(fp)) != 'r') continue;
+ if ((ch = getc(fp)) != 'r') continue;
+ while ((ch = getc(fp)) != '"') {
+ if (ch == EOF)
+ return (exitv);
+ if (ch == '\n')
+ ++line;
+ }
+ while ((ch = getc(fp)) != '"') {
+ if (ch == EOF)
+ return (exitv);
+ if (ch == '\n')
+ ++line;
+ if (ch == '\\\\')
+ if ((ch = getc(fp)) != 'n')
+ ungetc(ch, fp);
+ else if ((ch = getc(fp)) != '"')
+ ungetc(ch, fp);
+ else {
+ fprintf(stderr,
+ "%s: <newline> at line %d\n", name, line);
+ exitv = 1;
+ }
+ }
+ }
+ return (exitv);
+}
+END_OF_CODE
+
+cc t.c -o t
+if ./t $d/*/*.[ch] $d/*/*.cpp $d/*/*.in ; then
+ :
+else
+ echo "FAIL: found __db_err calls with newline strings."
+ exit 1
+fi
+
+exit 0