diff --git a/usr.sbin/config/Makefile.boot b/usr.sbin/config/Makefile.boot new file mode 100644 index 000000000000..3f7830db8db9 --- /dev/null +++ b/usr.sbin/config/Makefile.boot @@ -0,0 +1,50 @@ +# $NetBSD: Makefile.boot,v 1.1 1996/11/07 22:59:39 gwr Exp $ +# from: @(#)Makefile 8.2 (Berkeley) 4/19/94 +# +# a very simple makefile... +# +# You only want to use this if you aren't running NetBSD. +# +CC=gcc -O +CFLAGS= -I. -DMAKE_BOOTSTRAP + +# Uncomment this if your system does not have strtoul (i.e. SunOS) +STRTOUL= -Dstrtoul=strtol + +# Note: The scanner here uses features specific to "flex" so +# do not bother even trying to make lex build the scanner. +# If you do not have flex, the source can be found in: +# src/usr.bin/lex (See Makefile.boot) +LEX=flex -l + +YACC=yacc + +OBJS= files.o hash.o main.o mkheaders.o mkioconf.o mkmakefile.o \ + mkswap.o pack.o sem.o util.o y.tab.o lex.yy.o strerror.o + +config: ${OBJS} + ${CC} -o $@ ${OBJS} + +y.tab.o : y.tab.c + ${CC} ${CFLAGS} -c y.tab.c + +y.tab.c y.tab.h : gram.y + ${YACC} -d gram.y + +lex.yy.o : lex.yy.c + ${CC} ${CFLAGS} ${STRTOUL} -c lex.yy.c + +lex.yy.c : scan.l + ${LEX} scan.l + +${OBJS} : config.h + +y.tab.o mkmakefile.o mkswap.o sem.o : sem.h +lex.yy.o : y.tab.h + +.c.o: + ${CC} ${CFLAGS} -c $< + +clean: + rm -f *.o config lex.yy.c y.tab.[ch] + diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 64d24e6c0558..ad49cad4d3ee 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.26 1996/08/31 21:15:05 mycroft Exp $ */ +/* $NetBSD: config.h,v 1.27 1996/11/07 22:59:40 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -44,6 +44,38 @@ * from: @(#)config.h 8.1 (Berkeley) 6/6/93 */ +/* + * config.h: Global definitions for "config" + */ + +#include +#include + +#if !defined(MAKE_BOOTSTRAP) && defined(BSD) +#include +#include +#else /* ...BSD */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#else /* ...STDC */ +#define __P(protos) () /* traditional C preprocessor */ +#endif /* ...STDC */ +#endif /* ...BSD */ + +#if __STDC__ +#include +#include +#endif + +/* These are really for MAKE_BOOTSTRAP but harmless. */ +#ifndef __dead +#define __dead +#endif +#ifndef _PATH_DEVNULL +#define _PATH_DEVNULL "/dev/null" +#endif + + /* * Name/value lists. Values can be strings or pointers and/or can carry * integers. The names can be NULL, resulting in simple value lists. @@ -203,7 +235,7 @@ struct files { u_char fi_flags; /* as below */ char fi_lastc; /* last char from path */ const char *fi_path; /* full file path */ - const char *fi_tail; /* name, i.e., rindex(fi_path, '/') + 1 */ + const char *fi_tail; /* name, i.e., strrchr(fi_path, '/') + 1 */ const char *fi_base; /* tail minus ".c" (or whatever) */ struct nvlist *fi_optx;/* options expression */ struct nvlist *fi_optf;/* flattened version of above, if needed */ @@ -308,6 +340,7 @@ void pack __P((void)); /* scan.l */ int currentline __P((void)); +int include __P((const char *, int)); /* sem.c, other than for yacc actions */ void initsem __P((void)); diff --git a/usr.sbin/config/files.c b/usr.sbin/config/files.c index 3acfddbd5c48..9bc7b7a11c06 100644 --- a/usr.sbin/config/files.c +++ b/usr.sbin/config/files.c @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.6 1996/03/17 13:18:17 cgd Exp $ */ +/* $NetBSD: files.c,v 1.7 1996/11/07 22:59:41 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -120,12 +120,12 @@ addfile(path, optx, flags, rule) } /* find last part of pathname, and same without trailing suffix */ - tail = rindex(path, '/'); + tail = strrchr(path, '/'); if (tail == NULL) tail = path; else tail++; - dotp = rindex(tail, '.'); + dotp = strrchr(tail, '.'); if (dotp == NULL || dotp[1] == 0 || (baselen = dotp - tail) >= sizeof(base)) { error("invalid pathname `%s'", path); diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y index 6f2c270ae668..55d706d2af02 100644 --- a/usr.sbin/config/gram.y +++ b/usr.sbin/config/gram.y @@ -1,5 +1,5 @@ %{ -/* $NetBSD: gram.y,v 1.10 1996/11/02 01:00:14 cgd Exp $ */ +/* $NetBSD: gram.y,v 1.11 1996/11/07 22:59:42 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/usr.sbin/config/hash.c b/usr.sbin/config/hash.c index d65a683b1d1d..acbd7e8d1e59 100644 --- a/usr.sbin/config/hash.c +++ b/usr.sbin/config/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.3 1996/03/17 13:18:20 cgd Exp $ */ +/* $NetBSD: hash.c,v 1.4 1996/11/07 22:59:43 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,6 +49,17 @@ #include #include "config.h" +/* + * These are really for MAKE_BOOTSTRAP but harmless. + * XXX - Why not just use malloc in here, anyway? + */ +#ifndef ALIGNBYTES +#define ALIGNBYTES 3 +#endif +#ifndef ALIGN +#define ALIGN(p) (((long)(p) + ALIGNBYTES) &~ ALIGNBYTES) +#endif + /* * Interned strings are kept in a hash table. By making each string * unique, the program can compare strings by comparing pointers. diff --git a/usr.sbin/config/scan.l b/usr.sbin/config/scan.l index d05f4a1c8896..49925f662e97 100644 --- a/usr.sbin/config/scan.l +++ b/usr.sbin/config/scan.l @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.7 1996/08/31 21:15:13 mycroft Exp $ */ +/* $NetBSD: scan.l,v 1.8 1996/11/07 22:59:44 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -58,8 +58,6 @@ int yyline; const char *yyfile; const char *lastfile; -int include __P((const char *, int)); - /* * Data for returning to previous files from include files. */ diff --git a/usr.sbin/config/strerror.c b/usr.sbin/config/strerror.c new file mode 100644 index 000000000000..2d3eb60068b1 --- /dev/null +++ b/usr.sbin/config/strerror.c @@ -0,0 +1,19 @@ +/* + * strerror() - for those systems that don't have it yet. + */ + +/* These are part of the C library. (See perror.3) */ +extern char *sys_errlist[]; +extern int sys_nerr; + +static char errmsg[80]; + +char *strerror(en) + int en; +{ + if ((0 <= en) && (en < sys_nerr)) + return sys_errlist[en]; + + sprintf(errmsg, "Error %d", en); + return errmsg; +}