summaryrefslogtreecommitdiffstats
path: root/hack/makedefs.c
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2001-03-25 20:43:58 +0000
committerjsm <jsm@NetBSD.org>2001-03-25 20:43:58 +0000
commit00b8e31689c6400d8ad915067f021b8e246df989 (patch)
treeeb00203724cf2a378ca54c9419738dd06661f34c /hack/makedefs.c
parent57d9770b2eb590f5cad0b445cdbb91acb168736f (diff)
downloadbsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.tar.gz
bsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.tar.zst
bsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.zip
Make mostly gcc -W clean, and other cleanup:
Use const. Add __noreturn__ attributes. Add a __format__ attribute. Add __unused__ attributes. Use symbolic constants for open() and lseek(). Declare types of all function parameters; convert some function definitions to ISO C form. Ensure standard file descriptors are open on startup. Check for errors writing output of makedefs. Avoid duplicate definitions of variables.
Diffstat (limited to 'hack/makedefs.c')
-rw-r--r--hack/makedefs.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/hack/makedefs.c b/hack/makedefs.c
index 3aa621c6..fd19fa84 100644
--- a/hack/makedefs.c
+++ b/hack/makedefs.c
@@ -1,15 +1,16 @@
-/* $NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $ */
+/* $NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $ */
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
*/
#ifndef lint
-static char rcsid[] =
- "$NetBSD: makedefs.c,v 1.6 2000/07/31 11:35:03 simonb Exp $";
+static const char rcsid[] =
+ "$NetBSD: makedefs.c,v 1.7 2001/03/25 20:44:04 jsm Exp $";
#endif /* not lint */
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
@@ -23,7 +24,7 @@ char string[STRSZ];
static void readline(void);
static char nextchar(void);
-static int skipuntil(char *);
+static int skipuntil(const char *);
static int getentry(void);
static void capitalize(char *);
static int letter(int);
@@ -43,7 +44,7 @@ main(argc, argv)
(void) fprintf(stderr, "usage: makedefs file\n");
exit(1);
}
- if ((fd = open(argv[1], 0)) < 0) {
+ if ((fd = open(argv[1], O_RDONLY)) < 0) {
perror(argv[1]);
exit(1);
}
@@ -74,6 +75,11 @@ main(argc, argv)
printf("#define LAST_GEM (JADE+1)\n");
printf("#define LAST_RING %d\n", propct);
printf("#define NROFOBJECTS %d\n", i - 1);
+ fflush(stdout);
+ if (ferror(stdout)) {
+ perror("standard output");
+ exit(1);
+ }
exit(0);
}
@@ -105,9 +111,10 @@ nextchar()
static int
skipuntil(s)
- char *s;
+ const char *s;
{
- char *sp0, *sp1;
+ const char *sp0;
+ char *sp1;
loop:
while (*s != nextchar())
if (eof) {