summaryrefslogtreecommitdiff
path: root/usr.bin/mkstr/mkstr.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-07-05 23:11:13 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-07-05 23:11:13 +0000
commit686477f99071a9cc6b2fa8452e96a763516e63f1 (patch)
treebcbed8e9aff533473dd218cee53d073e93b250cd /usr.bin/mkstr/mkstr.c
parent956925327d748007220ea9c1930f2807cbdac246 (diff)
Wall
Diffstat (limited to 'usr.bin/mkstr/mkstr.c')
-rw-r--r--usr.bin/mkstr/mkstr.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/usr.bin/mkstr/mkstr.c b/usr.bin/mkstr/mkstr.c
index 213fa6f221c..f23f5908b5b 100644
--- a/usr.bin/mkstr/mkstr.c
+++ b/usr.bin/mkstr/mkstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkstr.c,v 1.2 1996/06/26 05:37:13 deraadt Exp $ */
+/* $OpenBSD: mkstr.c,v 1.3 1997/07/05 23:11:12 deraadt Exp $ */
/* $NetBSD: mkstr.c,v 1.4 1995/09/28 06:22:20 tls Exp $ */
/*
@@ -44,10 +44,12 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mkstr.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: mkstr.c,v 1.2 1996/06/26 05:37:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mkstr.c,v 1.3 1997/07/05 23:11:12 deraadt Exp $";
#endif
#endif /* not lint */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -86,6 +88,15 @@ char *progname;
char usagestr[] = "usage: %s [ - ] mesgfile prefix file ...\n";
char name[100], *np;
+void inithash __P((void));
+void process __P((void));
+int match __P((char *));
+void copystr __P((void));
+int octdigit __P((char));
+unsigned hashit __P((char *, char, unsigned));
+int fgetNUL __P((char *, int, FILE *));
+
+int
main(argc, argv)
int argc;
char *argv[];
@@ -117,12 +128,12 @@ main(argc, argv)
process();
argc--, argv++;
} while (argc > 0);
- exit(0);
+ return 0;
}
+void
process()
{
- register char *cp;
register c;
for (;;) {
@@ -144,6 +155,7 @@ process()
}
}
+int
match(ocp)
char *ocp;
{
@@ -162,6 +174,7 @@ match(ocp)
return (1);
}
+void
copystr()
{
register c, ch;
@@ -222,9 +235,10 @@ copystr()
}
out:
*cp = 0;
- printf("%d", hashit(buf, 1, NULL));
+ printf("%d", hashit(buf, 1, 0));
}
+int
octdigit(c)
char c;
{
@@ -232,13 +246,14 @@ octdigit(c)
return (c >= '0' && c <= '7');
}
+void
inithash()
{
char buf[512];
int mesgpt = 0;
rewind(mesgread);
- while (fgetNUL(buf, sizeof buf, mesgread) != NULL) {
+ while (fgetNUL(buf, sizeof buf, mesgread) != 0) {
hashit(buf, 0, mesgpt);
mesgpt += strlen(buf) + 2;
}
@@ -252,6 +267,7 @@ struct hash {
struct hash *hnext;
} *bucket[NBUCKETS];
+unsigned
hashit(str, really, fakept)
char *str;
char really;
@@ -298,9 +314,7 @@ hashit(str, really, fakept)
return (hp->hpt);
}
-#include <sys/types.h>
-#include <sys/stat.h>
-
+int
fgetNUL(obuf, rmdr, file)
char *obuf;
register int rmdr;
@@ -313,5 +327,5 @@ fgetNUL(obuf, rmdr, file)
*buf++ = c;
*buf++ = 0;
getc(file);
- return ((feof(file) || ferror(file)) ? NULL : 1);
+ return ((feof(file) || ferror(file)) ? 0 : 1);
}