diff options
author | steve <steve@FreeBSD.org> | 1996-12-14 06:20:03 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1996-12-14 06:20:03 +0000 |
commit | c58aca035e2c61510b619368861598623eb95e52 (patch) | |
tree | 049d84189a59de29d49254b609a318b17ee59387 /bin/sh/mkinit.c | |
parent | a958416f1b4a022c358b94db0b8e6bcc6cb54ee0 (diff) | |
download | FreeBSD-src-c58aca035e2c61510b619368861598623eb95e52.zip FreeBSD-src-c58aca035e2c61510b619368861598623eb95e52.tar.gz |
Merge in NetBSD mods and -Wall cleaning.
Obtained from: NetBSD, me
Diffstat (limited to 'bin/sh/mkinit.c')
-rw-r--r-- | bin/sh/mkinit.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/bin/sh/mkinit.c b/bin/sh/mkinit.c index 6afe601..d27a251 100644 --- a/bin/sh/mkinit.c +++ b/bin/sh/mkinit.c @@ -33,17 +33,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mkinit.c,v 1.5 1995/10/01 15:13:31 joerg Exp $ + * $Id: mkinit.c,v 1.6 1996/09/01 10:20:50 peter Exp $ */ #ifndef lint -static char copyright[] = +static char const copyright[] = "@(#) Copyright (c) 1991, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95"; +static char const sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ /* @@ -68,8 +68,7 @@ static char sccsid[] = "@(#)mkinit.c 8.2 (Berkeley) 5/4/95"; /* * OUTFILE is the name of the output file. Output is initially written - * to the file OUTTEMP, which is then moved to OUTFILE if OUTTEMP and - * OUTFILE are different. + * to the file OUTTEMP, which is then moved to OUTFILE. */ #define OUTFILE "init.c" @@ -107,7 +106,7 @@ struct event { char *name; /* name of event (e.g. INIT) */ char *routine; /* name of routine called on event */ char *comment; /* comment describing routine */ - struct text code; /* code for handling event */ + struct text code; /* code for handling event */ }; @@ -162,8 +161,8 @@ void addchar __P((int, struct text *)); void writetext __P((struct text *, FILE *)); FILE *ckfopen __P((char *, char *)); void *ckmalloc __P((int)); -char *savestr __P((char *)); -void error __P((char *)); +char *savestr __P((char *)); +void error __P((char *)); #define equal(s1, s2) (strcmp(s1, s2) == 0) @@ -174,16 +173,12 @@ main(argc, argv) { char **ap; - if (argc < 2) - error("Usage: mkinit file..."); header_files[0] = "\"shell.h\""; header_files[1] = "\"mystring.h\""; for (ap = argv + 1 ; *ap ; ap++) readfile(*ap); output(); - unlink(OUTFILE); - link(OUTTEMP, OUTFILE); - unlink(OUTTEMP); + rename(OUTTEMP, OUTFILE); exit(0); } @@ -197,7 +192,7 @@ readfile(fname) char *fname; { FILE *fp; - char line[1024], line2[1024]; + char line[1024]; struct event *ep; fp = ckfopen(fname, "r"); @@ -218,14 +213,16 @@ readfile(fname) dodecl(line, fp); if (line[0] == '#' && gooddefine(line)) { char *cp; + char line2[1024]; + static const char undef[] = "#undef "; strcpy(line2, line); - memcpy(line2, "#undef ", strlen("#undef ")); - cp = line2 + strlen("#undef "); + memcpy(line2, undef, sizeof(undef) - 1); + cp = line2 + sizeof(undef) - 1; while(*cp && (*cp == ' ' || *cp == '\t')) - cp++; + cp++; while(*cp && *cp != ' ' && *cp != '\t' && *cp != '\n') - cp++; + cp++; *cp++ = '\n'; *cp = '\0'; addstr(line2, &defines); addstr(line, &defines); @@ -363,7 +360,8 @@ dodecl(line1, fp) if (! amiddecls) addchar('\n', &decls); q = NULL; - for (p = line1 + 6 ; *p != '\0' && *p != '=' && *p != '/' && *p != '\n'; p++); + for (p = line1 + 6 ; *p && strchr("=/\n", *p) == NULL; p++) + continue; if (*p == '=') { /* eliminate initialization */ for (q = p ; *q && *q != ';' ; q++); if (*q == '\0') @@ -485,7 +483,7 @@ ckfopen(file, mode) } void * -ckmalloc(nbytes) +ckmalloc(nbytes) int nbytes; { register char *p; |