aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2004-09-15 21:36:58 +0000
committerH. Peter Anvin <hpa@zytor.com>2004-09-15 21:36:58 +0000
commit6797ec7ebec7267de0cdd3ea15ec4b80580f121b (patch)
tree5e78986f2acae1da0fbe8921b90edd6a8079a30e
parenta313e3e988b4a24753681f4faa181d020dedf6ce (diff)
downloadklibc-6797ec7ebec7267de0cdd3ea15ec4b80580f121b.tar.gz
Reinstate the __cdecl for now, and specify the first kernel versionklibc-0.176
(2.6.9-rc2) for which it's not needed.
-rw-r--r--ash/LINUX.DIFFS701
-rw-r--r--ash/README.Linux92
-rw-r--r--ash/builtins.in87
-rw-r--r--ash/dirent.c196
-rw-r--r--ash/mkinit.c547
-rw-r--r--ash/mknodes.c438
-rw-r--r--ash/trap.c4
7 files changed, 2 insertions, 2063 deletions
diff --git a/ash/LINUX.DIFFS b/ash/LINUX.DIFFS
deleted file mode 100644
index 32e3eb2cb4cbf..0000000000000
--- a/ash/LINUX.DIFFS
+++ /dev/null
@@ -1,701 +0,0 @@
-These are context diffs against the NetBSD-current version as of 93/09/18.
-Use "patch -p0 -s < LINUX.DIFFS" to patch the source code.
-
-
---- Makefile
-+++ Makefile 1993/10/04 18:48:13
-@@ -1,41 +1,59 @@
- # Makefile,v 1.7 1993/08/09 04:58:18 mycroft Exp
-
- PROG= sh
--SRCS= builtins.c cd.c dirent.c echo.c error.c eval.c exec.c expand.c \
-+SRCS= builtins.c cd.c dirent.c bltin/echo.c error.c eval.c exec.c expand.c \
- input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
- mystring.c nodes.c options.c parser.c redir.c show.c \
-- syntax.c trap.c output.c var.c
--OBJS+= init.o
--CFLAGS+=-DSHELL -I. -I${.CURDIR}
--.PATH: ${.CURDIR}/bltin
--CLEANFILES+=\
-+ syntax.c trap.c output.c var.c bltin/test.c
-+
-+OBJ1 = init.o
-+OBJ2 = builtins.o cd.o dirent.o bltin/echo.o error.o eval.o exec.o expand.o \
-+ input.o jobs.o mail.o main.o memalloc.o miscbltin.o \
-+ mystring.o nodes.o options.o parser.o redir.o show.o \
-+ syntax.o trap.o output.o var.o bltin/test.o
-+
-+OBJS = $(OBJ1) $(OBJ2)
-+
-+CFLAGS = -O2 -fomit-frame-pointer -m486 -DSHELL -I/usr/include/bsd -I.
-+LDFLAGS = -s -lbsd
-+
-+CLEANFILES =\
- builtins.c builtins.h init.c mkinit mknodes mksyntax \
- nodes.c nodes.h syntax.c syntax.h token.def
-
--.depend parser.o: token.def
-+all: $(OBJS)
-+ $(CC) -o $(PROG) $(OBJS) $(LDFLAGS)
-+
-+install: all
-+ install sh /bin/ash
-+ install -m 644 sh.1 /usr/man/man1/ash.1
-+
-+parser.o: token.def
- token.def: mktokens
-- sh ${.CURDIR}/mktokens
-+ sh ./mktokens
-
--builtins.h builtins.c: ${.CURDIR}/mkbuiltins ${.CURDIR}/builtins
-- cd ${.CURDIR}; sh mkbuiltins
-+builtins.h builtins.c: mkbuiltins builtins
-+ sh ./mkbuiltins
-
--init.c: mkinit ${SRCS}
-- ./mkinit '${CC} -c ${CFLAGS} init.c' ${.ALLSRC}
-- touch ${.TARGET}
-+init.c: mkinit $(SRCS)
-+ ./mkinit '${CC} -c $(CFLAGS) init.c' $(SRCS)
-+ touch init.c
-
--mkinit: ${.CURDIR}/mkinit.c
-- ${CC} ${CFLAGS} ${LDFLAGS} ${.CURDIR}/mkinit.c -o $@ ${LDADD}
-+mkinit: mkinit.c
-+ $(CC) $(CFLAGS) $(LDFLAGS) mkinit.c -o $@ $(LDADD)
-
--nodes.c nodes.h: mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
-- ./mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
-+nodes.c nodes.h: mknodes nodetypes nodes.c.pat
-+ ./mknodes nodetypes nodes.c.pat
-
--mknodes: ${.CURDIR}/mknodes.c
-- ${CC} ${CFLAGS} ${LDFLAGS} ${.CURDIR}/mknodes.c -o $@ ${LDADD}
-+mknodes: mknodes.c
-+ $(CC) $(CFLAGS) $(LDFLAGS) mknodes.c -o $@ $(LDADD)
-
- syntax.c syntax.h: mksyntax
- ./mksyntax
-
--mksyntax: ${.CURDIR}/mksyntax.c ${.CURDIR}/parser.h
-- ${CC} ${CFLAGS} ${LDFLAGS} ${.CURDIR}/mksyntax.c -o $@ ${LDADD}
-+mksyntax: mksyntax.c parser.h
-+ $(CC) $(CFLAGS) $(LDFLAGS) mksyntax.c -o $@ $(LDADD)
-+
-+clean:
-+ rm -f core $(CLEANFILES) $(PROG) $(OBJS)
-
--.include <bsd.prog.mk>
---- bltin/test.c
-+++ bltin/test.c 1993/10/04 18:48:13
-@@ -0,0 +1,390 @@
-+/*
-+ * test(1); version 7-like -- author Erik Baalbergen
-+ * modified by Eric Gisin to be used as built-in.
-+ * modified by Arnold Robbins to add SVR3 compatibility
-+ * (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
-+ */
-+
-+static char *RCSid = "$Id: LINUX.DIFFS,v 1.1.1.1 2002/08/17 01:36:06 hpa Exp $";
-+
-+#include <stddef.h>
-+/*#include <string.h>*/
-+#include <signal.h>
-+#include <errno.h>
-+#include <setjmp.h>
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include "bltin.h"
-+
-+/* test(1) accepts the following grammar:
-+ oexpr ::= aexpr | aexpr "-o" oexpr ;
-+ aexpr ::= nexpr | nexpr "-a" aexpr ;
-+ nexpr ::= primary ! "!" primary
-+ primary ::= unary-operator operand
-+ | operand binary-operator operand
-+ | operand
-+ | "(" oexpr ")"
-+ ;
-+ unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
-+ "-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
-+
-+ binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
-+ "-nt"|"-ot"|"-ef";
-+ operand ::= <any legal UNIX file name>
-+*/
-+
-+#define evaluate(x) getn(x)
-+#define errorf error
-+
-+#define EOI 0
-+#define FILRD 1
-+#define FILWR 2
-+#define FILREG 3
-+#define FILID 4
-+#define FILGZ 5
-+#define FILTT 6
-+#define STZER 7
-+#define STNZE 8
-+#define STEQL 9
-+#define STNEQ 10
-+#define INTEQ 11
-+#define INTNE 12
-+#define INTGE 13
-+#define INTGT 14
-+#define INTLE 15
-+#define INTLT 16
-+#define UNOT 17
-+#define BAND 18
-+#define BOR 19
-+#define LPAREN 20
-+#define RPAREN 21
-+#define OPERAND 22
-+#define FILEX 23
-+#define FILCDEV 24
-+#define FILBDEV 25
-+#define FILFIFO 26
-+#define FILSETU 27
-+#define FILSETG 28
-+#define FILSTCK 29
-+#define FILSYM 30
-+#define FILNT 31
-+#define FILOT 32
-+#define FILEQ 33
-+#define FILSOCK 34
-+#define FILUID 35
-+#define FILGID 36
-+#define OPTION 37
-+
-+#define UNOP 1
-+#define BINOP 2
-+#define BUNOP 3
-+#define BBINOP 4
-+#define PAREN 5
-+
-+struct t_op {
-+ char *op_text;
-+ short op_num, op_type;
-+} const ops [] = {
-+ {"-r", FILRD, UNOP},
-+ {"-w", FILWR, UNOP},
-+ {"-x", FILEX, UNOP},
-+ {"-f", FILREG, UNOP},
-+ {"-d", FILID, UNOP},
-+ {"-c", FILCDEV,UNOP},
-+ {"-b", FILBDEV,UNOP},
-+ {"-p", FILFIFO,UNOP},
-+ {"-u", FILSETU,UNOP},
-+ {"-g", FILSETG,UNOP},
-+ {"-k", FILSTCK,UNOP},
-+ {"-s", FILGZ, UNOP},
-+ {"-t", FILTT, UNOP},
-+ {"-z", STZER, UNOP},
-+ {"-n", STNZE, UNOP},
-+#if 0 /* conficts with binary -o */
-+ {"-o", OPTION, UNOP},
-+#endif
-+ {"-U", FILUID, UNOP},
-+ {"-G", FILGID, UNOP},
-+ {"-L", FILSYM, UNOP},
-+ {"-S", FILSOCK,UNOP},
-+ {"=", STEQL, BINOP},
-+ {"!=", STNEQ, BINOP},
-+ {"-eq", INTEQ, BINOP},
-+ {"-ne", INTNE, BINOP},
-+ {"-ge", INTGE, BINOP},
-+ {"-gt", INTGT, BINOP},
-+ {"-le", INTLE, BINOP},
-+ {"-lt", INTLT, BINOP},
-+ {"-nt", FILNT, BINOP},
-+ {"-ot", FILOT, BINOP},
-+ {"-ef", FILEQ, BINOP},
-+ {"!", UNOT, BUNOP},
-+ {"-a", BAND, BBINOP},
-+ {"-o", BOR, BBINOP},
-+ {"(", LPAREN, PAREN},
-+ {")", RPAREN, PAREN},
-+ {0, 0, 0}
-+};
-+
-+char **t_wp;
-+struct t_op const *t_wp_op;
-+
-+static void syntax();
-+
-+int
-+testcmd(argc, wp)
-+ char **wp;
-+{
-+ int res;
-+
-+ t_wp = wp+1;
-+ if (strcmp(wp[0], "[") == 0) {
-+ while (*wp != NULL)
-+ wp++;
-+ if (strcmp(*--wp, "]") != 0)
-+ errorf("[: missing ]");
-+ *wp = NULL;
-+ }
-+ res = *t_wp == NULL || !oexpr(t_lex(*t_wp));
-+
-+ if (*t_wp != NULL && *++t_wp != NULL)
-+ syntax(*t_wp, "unknown operand");
-+
-+ return res;
-+}
-+
-+static void
-+syntax(op, msg)
-+ char *op;
-+ char *msg;
-+{
-+ if (op && *op)
-+ errorf("%s: %s", op, msg);
-+ else
-+ errorf("%s", msg);
-+}
-+
-+oexpr(n)
-+{
-+ int res;
-+
-+ res = aexpr(n);
-+ if (t_lex(*++t_wp) == BOR)
-+ return oexpr(t_lex(*++t_wp)) || res;
-+ t_wp--;
-+ return res;
-+}
-+
-+aexpr(n)
-+{
-+ int res;
-+
-+ res = nexpr(n);
-+ if (t_lex(*++t_wp) == BAND)
-+ return aexpr(t_lex(*++t_wp)) && res;
-+ t_wp--;
-+ return res;
-+}
-+
-+nexpr(n)
-+ int n; /* token */
-+{
-+ if (n == UNOT)
-+ return !nexpr(t_lex(*++t_wp));
-+ return primary(n);
-+}
-+
-+primary(n)
-+ int n; /* token */
-+{
-+ register char *opnd1, *opnd2;
-+ int res;
-+
-+ if (n == EOI)
-+ syntax(NULL, "argument expected");
-+ if (n == LPAREN) {
-+ res = oexpr(t_lex(*++t_wp));
-+ if (t_lex(*++t_wp) != RPAREN)
-+ syntax(NULL, "closing paren expected");
-+ return res;
-+ }
-+ if (t_wp_op && t_wp_op->op_type == UNOP) {
-+ /* unary expression */
-+ if (*++t_wp == NULL && n != FILTT)
-+ syntax(t_wp_op->op_text, "argument expected");
-+ switch (n) {
-+ /**
-+ case OPTION:
-+ return flag[option(*t_wp)];
-+ **/
-+ case STZER:
-+ return strlen(*t_wp) == 0;
-+ case STNZE:
-+ return strlen(*t_wp) != 0;
-+ case FILTT:
-+ if (**t_wp < '0' || **t_wp > '9')
-+ return filstat("0", n);
-+ default: /* all other FIL* */
-+ return filstat(*t_wp, n);
-+ }
-+ }
-+ opnd1 = *t_wp;
-+ (void) t_lex(*++t_wp);
-+ if (t_wp_op && t_wp_op->op_type == BINOP) {
-+ struct t_op const *op = t_wp_op;
-+
-+ if ((opnd2 = *++t_wp) == (char *)0)
-+ syntax(op->op_text, "argument expected");
-+
-+ switch (op->op_num) {
-+ case STEQL:
-+ return strcmp(opnd1, opnd2) == 0;
-+ case STNEQ:
-+ return strcmp(opnd1, opnd2) != 0;
-+ case INTEQ:
-+ return evaluate(opnd1) == evaluate(opnd2);
-+ case INTNE:
-+ return evaluate(opnd1) != evaluate(opnd2);
-+ case INTGE:
-+ return evaluate(opnd1) >= evaluate(opnd2);
-+ case INTGT:
-+ return evaluate(opnd1) > evaluate(opnd2);
-+ case INTLE:
-+ return evaluate(opnd1) <= evaluate(opnd2);
-+ case INTLT:
-+ return evaluate(opnd1) < evaluate(opnd2);
-+ case FILNT:
-+ return newerf (opnd1, opnd2);
-+ case FILOT:
-+ return olderf (opnd1, opnd2);
-+ case FILEQ:
-+ return equalf (opnd1, opnd2);
-+ }
-+ }
-+ t_wp--;
-+ return strlen(opnd1) > 0;
-+}
-+
-+filstat(nm, mode)
-+ char *nm;
-+{
-+ struct stat s;
-+
-+ switch (mode) {
-+ case FILRD:
-+ return access(nm, 4) == 0;
-+ case FILWR:
-+ return access(nm, 2) == 0;
-+ case FILEX:
-+ return access(nm, 1) == 0;
-+ case FILREG:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFREG;
-+ case FILID:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFDIR;
-+ case FILCDEV:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFCHR;
-+ case FILBDEV:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFBLK;
-+ case FILFIFO:
-+#ifdef S_IFIFO
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFIFO;
-+#else
-+ return 0;
-+#endif
-+ case FILSETU:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_ISUID) == S_ISUID;
-+ case FILSETG:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_ISGID) == S_ISGID;
-+ case FILSTCK:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_ISVTX) == S_ISVTX;
-+ case FILGZ:
-+ return stat(nm, &s) == 0 && s.st_size > 0L;
-+ case FILTT:
-+ return isatty(getn(nm));
-+ case FILUID:
-+ return stat(nm, &s) == 0 && s.st_uid == geteuid();
-+ case FILGID:
-+ return stat(nm, &s) == 0 && s.st_gid == getegid();
-+#ifdef S_IFLNK
-+ case FILSYM:
-+ return lstat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFLNK;
-+#endif
-+#ifdef S_IFSOCK
-+ case FILSOCK:
-+ return stat(nm, &s) == 0 && (s.st_mode & S_IFMT) == S_IFSOCK;
-+#endif
-+ default:
-+ return 1;
-+ }
-+}
-+
-+int
-+t_lex(s)
-+ register char *s;
-+{
-+ register struct t_op const *op = ops;
-+
-+ if (s == 0) {
-+ t_wp_op = (struct t_op *)0;
-+ return EOI;
-+ }
-+ while (op->op_text) {
-+ if (strcmp(s, op->op_text) == 0) {
-+ t_wp_op = op;
-+ return op->op_num;
-+ }
-+ op++;
-+ }
-+ t_wp_op = (struct t_op *)0;
-+ return OPERAND;
-+}
-+
-+newerf (f1, f2)
-+char *f1, *f2;
-+{
-+ struct stat b1, b2;
-+
-+ return (stat (f1, &b1) == 0 &&
-+ stat (f2, &b2) == 0 &&
-+ b1.st_mtime > b2.st_mtime);
-+}
-+
-+olderf (f1, f2)
-+char *f1, *f2;
-+{
-+ struct stat b1, b2;
-+
-+ return (stat (f1, &b1) == 0 &&
-+ stat (f2, &b2) == 0 &&
-+ b1.st_mtime < b2.st_mtime);
-+}
-+
-+equalf (f1, f2)
-+char *f1, *f2;
-+{
-+ struct stat b1, b2;
-+
-+ return (stat (f1, &b1) == 0 &&
-+ stat (f2, &b2) == 0 &&
-+ b1.st_dev == b2.st_dev &&
-+ b1.st_ino == b2.st_ino);
-+}
-+
-+/* atoi with error detection */
-+
-+getn(as)
-+ char *as;
-+{
-+ register char *s;
-+ register int n;
-+
-+ s = as;
-+ if (*s == '-')
-+ s++;
-+ for (n = 0; *s >= '0' && *s <= '9'; s++)
-+ n = (n*10) + (*s-'0');
-+ if (*s)
-+ errorf("%s: bad number", as);
-+ return (*as == '-') ? -n : n;
-+}
-+
---- builtins
-+++ builtins 1993/10/04 18:48:13
-@@ -79,6 +79,7 @@
- setcmd set
- setvarcmd setvar
- shiftcmd shift
-+testcmd test [
- trapcmd trap
- truecmd : true
- umaskcmd umask
---- cd.c
-+++ cd.c 1993/10/04 18:48:13
-@@ -121,7 +121,7 @@
- print = 1;
- #endif
- INTOFF;
-- if (chdir(dest) < 0) {
-+ if (dest[0] != '\0' && chdir(dest) < 0) {
- INTON;
- return -1;
- }
-@@ -217,7 +217,7 @@
- STPUTC('\0', p);
- p = grabstackstr(p);
- INTOFF;
-- if (chdir(p) < 0) {
-+ if (p[0] != '\0' && chdir(p) < 0) {
- INTON;
- return -1;
- }
---- error.h
-+++ error.h 1993/10/04 18:48:13
-@@ -109,6 +109,8 @@
- */
-
- #ifdef BSD
-+#ifndef linux
- #define setjmp(jmploc) _setjmp(jmploc)
- #define longjmp(jmploc, val) _longjmp(jmploc, val)
-+#endif
- #endif
---- exec.c
-+++ exec.c 1993/10/04 18:48:14
-@@ -485,7 +485,10 @@
- stunalloc(fullname);
- goto success;
- }
-- if (statb.st_uid == geteuid()) {
-+ if (geteuid() == 0) {
-+ if ((statb.st_mode & 0111) == 0)
-+ goto loop;
-+ } else if (statb.st_uid == geteuid()) {
- if ((statb.st_mode & 0100) == 0)
- goto loop;
- } else if (statb.st_gid == getegid()) {
---- jobs.c
-+++ jobs.c 1993/10/04 18:48:14
-@@ -129,7 +129,9 @@
- continue;
- }
- } while (0);
-- if (ioctl(2, TIOCGETD, (char *)&ldisc) < 0 || ldisc != NTTYDISC) {
-+/* if (ioctl(2, TIOCGETD, (char *)&ldisc) < 0 || ldisc != NTTYDISC) {*/
-+ /* crude hack for linux */
-+ if (ioctl(2, TIOCGETD, (char *)&ldisc) < 0) {
- out2str("ash: need new tty driver to run job control; job control turned off\n");
- jflag = 0;
- return;
-@@ -578,6 +580,7 @@
- }
- return pid;
- }
-+#if JOBS
- if (rootshell && mode != FORK_NOJOB && jflag) {
- if (jp == NULL || jp->nprocs == 0)
- pgrp = pid;
-@@ -585,6 +588,7 @@
- pgrp = jp->ps[0].pid;
- setpgrp(pid, pgrp);
- }
-+#endif
- if (mode == FORK_BG)
- backgndpid = pid; /* set $! */
- if (jp) {
-@@ -634,8 +638,10 @@
- INTOFF;
- TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1));
- while (jp->state == 0) {
-- dowait(1, jp);
-+ if (dowait(1, jp) == -1 && errno == ECHILD) {
-+ error("waitforjob: no children");
- }
-+ }
- #if JOBS
- if (jp->jobctl) {
- if (ioctl(2, TIOCSPGRP, (char *)&mypgrp) < 0)
-@@ -657,8 +663,10 @@
- if (! JOBS || jp->state == JOBDONE)
- freejob(jp);
- CLEAR_PENDING_INT;
-+#if 0
- if ((status & 0x7F) == SIGINT)
- kill(getpid(), SIGINT);
-+#endif
- INTON;
- return st;
- }
---- main.c
-+++ main.c 1993/10/04 18:48:14
-@@ -104,6 +104,9 @@
- #if PROFILE
- monitor(4, etext, profile_buf, sizeof profile_buf, 50);
- #endif
-+#ifdef linux
-+ signal(SIGCHLD,SIG_DFL);
-+#endif /* linux */
- state = 0;
- if (setjmp(jmploc.loc)) {
- /*
-@@ -318,9 +321,9 @@
- /*
- * Should never be called.
- */
-+#endif
-
- void
- exit(exitstatus) {
- _exit(exitstatus);
- }
--#endif
---- miscbltin.c
-+++ miscbltin.c 1993/10/04 18:48:14
-@@ -207,12 +207,16 @@
- } while (*++ap != '\0');
- umask(mask);
- } else {
-+#ifndef __linux__
- void *set;
- if ((set = setmode (ap)) == 0)
-+#endif
- error("Illegal number: %s", ap);
-
-+#ifndef __linux__
- mask = getmode (set, ~mask & 0777);
- umask(~mask & 0777);
-+#endif
- }
- }
- return 0;
---- options.h
-+++ options.h 1993/10/04 18:48:14
-@@ -57,11 +57,12 @@
- #define xflag optval[7]
- #define zflag optval[8]
- #define vflag optval[9]
-+#define uflag optval[10]
-
--#define NOPTS 10
-+#define NOPTS 11
-
- #ifdef DEFINE_OPTIONS
--const char optchar[NOPTS+1] = "efIijnsxzv"; /* shell flags */
-+const char optchar[NOPTS+1] = "efIijnsxzvu"; /* shell flags */
- char optval[NOPTS+1]; /* values of option flags */
- #else
- extern const char optchar[NOPTS+1];
---- redir.c
-+++ redir.c 1993/10/04 18:48:14
-@@ -57,7 +57,7 @@
-
-
- #define EMPTY -2 /* marks an unused slot in redirtab */
--#define PIPESIZE 4096 /* amount of buffering in a pipe */
-+#define PIPESIZE 4095 /* amount of buffering in a pipe */
-
-
- MKINIT
---- shell.h
-+++ shell.h 1993/10/04 18:48:14
-@@ -55,13 +55,13 @@
- */
-
-
--#define JOBS 1
-+#define JOBS 0
- #define SYMLINKS 1
- #define DIRENT 1
- #define UDIR 0
- #define ATTY 0
- #define BSD
--#define DEBUG 1
-+/* #define DEBUG */
-
- #ifdef __STDC__
- typedef void *pointer;
---- var.c
-+++ var.c 1993/10/04 18:48:14
-@@ -235,7 +235,7 @@
- vp->flags &=~ (VTEXTFIXED|VSTACK|VUNSET);
- vp->flags |= flags;
- vp->text = s;
-- if (vp == &vmpath || (vp == &vmail && ! mpathset()))
-+ if (iflag && (vp == &vmpath || (vp == &vmail && ! mpathset())))
- chkmail(1);
- INTON;
- return;
-@@ -283,10 +283,12 @@
- for (v = *hashvar(name) ; v ; v = v->next) {
- if (varequal(v->text, name)) {
- if (v->flags & VUNSET)
-- return NULL;
-+ break;
- return strchr(v->text, '=') + 1;
- }
- }
-+ if (uflag)
-+ error("%.*s: variable not set", strchr(name, '=') - name, name);
- return NULL;
- }
-
diff --git a/ash/README.Linux b/ash/README.Linux
deleted file mode 100644
index 80a75ff150c9a..0000000000000
--- a/ash/README.Linux
+++ /dev/null
@@ -1,92 +0,0 @@
-NetBSD's ash (Almquist sh) for Linux
-====================================
-
-Version of this Linux port: 0.2
-This version can be found on ftp.sbusol.uni-sb.de(134.96.7.7) in the
-directory /pub/Linux/local/florian.
-
-I took from the NetBSD-current release as of 93/09/18 the source code
-of ash. Then I applied again the Linux patches. This will hopefully
-fix some bugs.
-
-ash is a Bourne compatible shell. It is without job control only 62K.
-The slackware distribution has shown, that such a small shell can be usefull
-for a good bootdisk. But I don't think, this shell is good for interactive
-use. Take other shells like bash, ksh or tcsh for that.
-Also bash 1.13 is now much better than 1.12...
-
-If you have problems and you can give me an exact bug report, I will have
-a look into ash. I will also keep a look at the NetBSD people.
-If someone else wants to do more work on ash, I could pass on all the email
-messages about ash I got from Arjan. Maybe this will help a little bit.
-
-
-Florian La Roche flla@stud.uni-sb.de or rzsfl@sbusol.uni-sb.de
-
-
-
-Known bugs in NetBSD's ash or the Linux ports.
-==============================================
-
-* There are bug reports, that 'ash' will hang, if invoked from 'cron' or
- in '/etc/rc'. I am not sure, if this is still true.
-
-* The following code from trn 3.2's Pnews script gives a non-empty
- $moderator variable for all newsgroups (even the non-moderated ones).
- bash gives an empty $moderator for non-moderated groups.
-
- ---------------------------------------------------------------------------
- for newsgroup in $*; do
- # the following screwy sed should prevent Eunice from hanging on no match
- moderator=`$sed <$lib/moderators \
- -e "/^$newsgroup[ ]/!s/.*//" \
- -e "s/^$newsgroup[ ]//"`
- case ${moderator}X in
- X) tryinews=yes
- ;;
- *)
- $echo Mailing to moderator $moderator
- ---------------------------------------------------------------------------
-
-
-
-History of NetBSD's ash for Linux
-=================================
-
-
-* Version 0.2 released by Florian La Roche
-
-- I took a newer version from NetBSD-current (93/09/18) and applied again the
- patches for Linux. Maybe this fixes some errors.
-
-
-* Version 0.1 released August 21, 1993 devet@adv.win.tue.nl
-
-- added builtin test command and -u flag for detecting unset variables
- (patches from Branko Lankester).
-
-- fixed `permission denied' errors when running as root and trying to execute
- executables not owned by root (Branko).
-
-- more fixes, additions and cleanups by Branko.
-
-
-* Version 0.0 released August 20, 1993 devet@adv.win.tue.nl
-
-- original sources fetched August 10
-
-- patches for Makefile and some other files by Sunando Sen
-
-- chdir() fixes in cd.c and an initial signal(SIGCHLD,SIG_DFL) in main.c
-
-
-The patches are based on Sunando Sen's <sens@fasecon.econ.nyu.edu>
-patches with further fixes suggested by Linus Torvalds, Branko Lankester
-and Alan Cox.
-
-
-Branko Lankester: branko@hacktic.nl
-Sunando Sen: sens@fasecon.econ.nyu.edu
-Arjan de Vet: devet@adv.win.tue.nl
-Florian La Roche: flla@stud.uni-sb.de or rzsfl@sbusol.uni-sb.de
-
diff --git a/ash/builtins.in b/ash/builtins.in
deleted file mode 100644
index cdef8778e2d34..0000000000000
--- a/ash/builtins.in
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 1991 The Regents of the University of California.
-# All rights reserved.
-#
-# This code is derived from software contributed to Berkeley by
-# Kenneth Almquist.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
-# This product includes software developed by the University of
-# California, Berkeley and its contributors.
-# 4. Neither the name of the University nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# @(#)builtins 5.1 (Berkeley) 3/7/91
-#
-# /b/source/CVS/src/bin/sh/builtins,v 1.4 1993/07/07 01:11:56 jtc Exp
-
-#
-# This file lists all the builtin commands. The first column is the name
-# of a C routine. The -j flag, if present, specifies that this command
-# is to be excluded from systems without job control. The rest of the line
-# specifies the command name or names used to run the command. The entry
-# for nullcmd, which is run when the user does not specify a command, must
-# come first.
-#
-# Copyright (C) 1989 by Kenneth Almquist. All rights reserved.
-# This file is part of ash, which is distributed under the terms specified
-# by the Ash General Public License. See the file named LICENSE.
-
-bltincmd command
-#alloccmd alloc
-bgcmd -j bg
-breakcmd break continue
-#catfcmd catf
-cdcmd cd chdir
-dotcmd .
-echocmd echo
-evalcmd eval
-execcmd exec
-exitcmd exit
-exportcmd export readonly
-#exprcmd expr test [
-falsecmd false
-fgcmd -j fg
-getoptscmd getopts
-hashcmd hash
-jobidcmd jobid
-jobscmd jobs
-lccmd lc
-#linecmd line
-localcmd local
-#nlechocmd nlecho
-pwdcmd pwd
-readcmd read
-returncmd return
-setcmd set
-setvarcmd setvar
-shiftcmd shift
-testcmd test [
-trapcmd trap
-truecmd : true
-umaskcmd umask
-unsetcmd unset
-waitcmd wait
diff --git a/ash/dirent.c b/ash/dirent.c
deleted file mode 100644
index b75cd67ca7c2b..0000000000000
--- a/ash/dirent.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Kenneth Almquist.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)dirent.c 5.1 (Berkeley) 3/7/91";*/
-static char rcsid[] = "dirent.c,v 1.4 1993/08/01 18:58:21 mycroft Exp";
-#endif /* not lint */
-
-#include "shell.h" /* definitions for pointer, NULL, DIRENT, and BSD */
-
-#if ! DIRENT
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#ifndef S_ISDIR /* macro to test for directory file */
-#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
-#endif
-
-#ifdef BSD
-
-#ifdef __STDC__
-int stat(char *, struct stat *);
-#else
-int stat();
-#endif
-
-
-/*
- * The BSD opendir routine doesn't check that what is being opened is a
- * directory, so we have to include the check in a wrapper routine.
- */
-
-#undef opendir
-
-DIR *
-myopendir(dirname)
- char *dirname; /* name of directory */
- {
- struct stat statb;
-
- if (stat(dirname, &statb) != 0 || ! S_ISDIR(statb.st_mode)) {
- errno = ENOTDIR;
- return NULL; /* not a directory */
- }
- return opendir(dirname);
-}
-
-#else /* not BSD */
-
-/*
- * Dirent routines for old style file systems.
- */
-
-#ifdef __STDC__
-pointer malloc(unsigned);
-void free(pointer);
-int open(char *, int, ...);
-int close(int);
-int fstat(int, struct stat *);
-#else
-pointer malloc();
-void free();
-int open();
-int close();
-int fstat();
-#endif
-
-
-DIR *
-opendir(dirname)
- char *dirname; /* name of directory */
- {
- register DIR *dirp; /* -> malloc'ed storage */
- register int fd; /* file descriptor for read */
- struct stat statb; /* result of fstat() */
-
-#ifdef O_NDELAY
- fd = open(dirname, O_RDONLY|O_NDELAY);
-#else
- fd = open(dirname, O_RDONLY);
-#endif
- if (fd < 0)
- return NULL; /* errno set by open() */
-
- if (fstat(fd, &statb) != 0 || !S_ISDIR(statb.st_mode)) {
- (void)close(fd);
- errno = ENOTDIR;
- return NULL; /* not a directory */
- }
-
- if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
- (void)close(fd);
- errno = ENOMEM;
- return NULL; /* not enough memory */
- }
-
- dirp->dd_fd = fd;
- dirp->dd_nleft = 0; /* refill needed */
-
- return dirp;
-}
-
-
-
-int
-closedir(dirp)
- register DIR *dirp; /* stream from opendir() */
- {
- register int fd;
-
- if (dirp == NULL) {
- errno = EFAULT;
- return -1; /* invalid pointer */
- }
-
- fd = dirp->dd_fd;
- free((pointer)dirp);
- return close(fd);
-}
-
-
-
-struct dirent *
-readdir(dirp)
- register DIR *dirp; /* stream from opendir() */
- {
- register struct direct *dp;
- register char *p, *q;
- register int i;
-
- do {
- if ((dirp->dd_nleft -= sizeof (struct direct)) < 0) {
- if ((i = read(dirp->dd_fd,
- (char *)dirp->dd_buf,
- DIRBUFENT*sizeof(struct direct))) <= 0) {
- if (i == 0)
- errno = 0; /* unnecessary */
- return NULL; /* EOF or error */
- }
- dirp->dd_loc = dirp->dd_buf;
- dirp->dd_nleft = i - sizeof (struct direct);
- }
- dp = dirp->dd_loc++;
- } while (dp->d_ino == 0);
- dirp->dd_entry.d_ino = dp->d_ino;
-
- /* now copy the name, nul terminating it */
- p = dp->d_name;
- q = dirp->dd_entry.d_name;
- i = DIRSIZ;
- while (--i >= 0 && *p != '\0')
- *q++ = *p++;
- *q = '\0';
- return &dirp->dd_entry;
-}
-
-#endif /* BSD */
-#endif /* DIRENT */
diff --git a/ash/mkinit.c b/ash/mkinit.c
deleted file mode 100644
index 9cc0804621f4a..0000000000000
--- a/ash/mkinit.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Kenneth Almquist.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1991 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)mkinit.c 5.3 (Berkeley) 3/13/91";*/
-static char rcsid[] = "mkinit.c,v 1.4 1993/08/01 18:58:09 mycroft Exp";
-#endif /* not lint */
-
-/*
- * This program scans all the source files for code to handle various
- * special events and combines this code into one file. This (allegedly)
- * improves the structure of the program since there is no need for
- * anyone outside of a module to know that that module performs special
- * operations on particular events. The command is executed iff init.c
- * is actually changed.
- *
- * Usage: mkinit command sourcefile...
- */
-
-
-#include <sys/cdefs.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-
-/*
- * 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.
- */
-
-#define OUTFILE "init.c"
-#define OUTTEMP "init.c.new"
-#define OUTOBJ "init.o"
-
-
-/*
- * A text structure is basicly just a string that grows as more characters
- * are added onto the end of it. It is implemented as a linked list of
- * blocks of characters. The routines addstr and addchar append a string
- * or a single character, respectively, to a text structure. Writetext
- * writes the contents of a text structure to a file.
- */
-
-#define BLOCKSIZE 512
-
-struct text {
- char *nextc;
- int nleft;
- struct block *start;
- struct block *last;
-};
-
-struct block {
- struct block *next;
- char text[BLOCKSIZE];
-};
-
-
-/*
- * There is one event structure for each event that mkinit handles.
- */
-
-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 */
-};
-
-
-char writer[] = "\
-/*\n\
- * This file was generated by the mkinit program.\n\
- */\n\
-\n";
-
-char init[] = "\
-/*\n\
- * Initialization code.\n\
- */\n";
-
-char reset[] = "\
-/*\n\
- * This routine is called when an error or an interrupt occurs in an\n\
- * interactive shell and control is returned to the main command loop.\n\
- */\n";
-
-char shellproc[] = "\
-/*\n\
- * This routine is called to initialize the shell to run a shell procedure.\n\
- */\n";
-
-
-struct event event[] = {
- {"INIT", "init", init},
- {"RESET", "reset", reset},
- {"SHELLPROC", "initshellproc", shellproc},
- {NULL, NULL}
-};
-
-
-char *curfile; /* current file */
-int linno; /* current line */
-char *header_files[200]; /* list of header files */
-struct text defines; /* #define statements */
-struct text decls; /* declarations */
-int amiddecls; /* for formatting */
-
-
-void readfile(), doevent(), doinclude(), dodecl(), output();
-void addstr(), addchar(), writetext();
-
-#define equal(s1, s2) (strcmp(s1, s2) == 0)
-
-FILE *ckfopen();
-char *savestr();
-void *ckmalloc __P((int));
-void error();
-
-main(argc, argv)
- char **argv;
- {
- char **ap;
- int fd;
- char c;
-
- if (argc < 2)
- error("Usage: mkinit command file...");
- header_files[0] = "\"shell.h\"";
- header_files[1] = "\"mystring.h\"";
- for (ap = argv + 2 ; *ap ; ap++)
- readfile(*ap);
- output();
- if (file_changed()) {
- unlink(OUTFILE);
- link(OUTTEMP, OUTFILE);
- unlink(OUTTEMP);
- } else {
- unlink(OUTTEMP);
- if (touch(OUTOBJ))
- exit(0); /* no compilation necessary */
- }
- printf("%s\n", argv[1]);
- execl("/bin/sh", "sh", "-c", argv[1], (char *)0);
- error("Can't exec shell");
-}
-
-
-/*
- * Parse an input file.
- */
-
-void
-readfile(fname)
- char *fname;
- {
- FILE *fp;
- char line[1024];
- struct event *ep;
-
- fp = ckfopen(fname, "r");
- curfile = fname;
- linno = 0;
- amiddecls = 0;
- while (fgets(line, sizeof line, fp) != NULL) {
- linno++;
- for (ep = event ; ep->name ; ep++) {
- if (line[0] == ep->name[0] && match(ep->name, line)) {
- doevent(ep, fp, fname);
- break;
- }
- }
- if (line[0] == 'I' && match("INCLUDE", line))
- doinclude(line);
- if (line[0] == 'M' && match("MKINIT", line))
- dodecl(line, fp);
- if (line[0] == '#' && gooddefine(line))
- addstr(line, &defines);
- }
- fclose(fp);
-}
-
-
-int
-match(name, line)
- char *name;
- char *line;
- {
- register char *p, *q;
-
- p = name, q = line;
- while (*p) {
- if (*p++ != *q++)
- return 0;
- }
- if (*q != '{' && *q != ' ' && *q != '\t' && *q != '\n')
- return 0;
- return 1;
-}
-
-
-int
-gooddefine(line)
- char *line;
- {
- register char *p;
-
- if (! match("#define", line))
- return 0; /* not a define */
- p = line + 7;
- while (*p == ' ' || *p == '\t')
- p++;
- while (*p != ' ' && *p != '\t') {
- if (*p == '(')
- return 0; /* macro definition */
- p++;
- }
- while (*p != '\n' && *p != '\0')
- p++;
- if (p[-1] == '\\')
- return 0; /* multi-line definition */
- return 1;
-}
-
-
-void
-doevent(ep, fp, fname)
- register struct event *ep;
- FILE *fp;
- char *fname;
- {
- char line[1024];
- int indent;
- char *p;
-
- sprintf(line, "\n /* from %s: */\n", fname);
- addstr(line, &ep->code);
- addstr(" {\n", &ep->code);
- for (;;) {
- linno++;
- if (fgets(line, sizeof line, fp) == NULL)
- error("Unexpected EOF");
- if (equal(line, "}\n"))
- break;
- indent = 6;
- for (p = line ; *p == '\t' ; p++)
- indent += 8;
- for ( ; *p == ' ' ; p++)
- indent++;
- if (*p == '\n' || *p == '#')
- indent = 0;
- while (indent >= 8) {
- addchar('\t', &ep->code);
- indent -= 8;
- }
- while (indent > 0) {
- addchar(' ', &ep->code);
- indent--;
- }
- addstr(p, &ep->code);
- }
- addstr(" }\n", &ep->code);
-}
-
-
-void
-doinclude(line)
- char *line;
- {
- register char *p;
- char *name;
- register char **pp;
-
- for (p = line ; *p != '"' && *p != '<' && *p != '\0' ; p++);
- if (*p == '\0')
- error("Expecting '\"' or '<'");
- name = p;
- while (*p != ' ' && *p != '\t' && *p != '\n')
- p++;
- if (p[-1] != '"' && p[-1] != '>')
- error("Missing terminator");
- *p = '\0';
-
- /* name now contains the name of the include file */
- for (pp = header_files ; *pp && ! equal(*pp, name) ; pp++);
- if (*pp == NULL)
- *pp = savestr(name);
-}
-
-
-void
-dodecl(line1, fp)
- char *line1;
- FILE *fp;
- {
- char line[1024];
- register char *p, *q;
-
- if (strcmp(line1, "MKINIT\n") == 0) { /* start of struct/union decl */
- addchar('\n', &decls);
- do {
- linno++;
- if (fgets(line, sizeof line, fp) == NULL)
- error("Unterminated structure declaration");
- addstr(line, &decls);
- } while (line[0] != '}');
- amiddecls = 0;
- } else {
- if (! amiddecls)
- addchar('\n', &decls);
- q = NULL;
- for (p = line1 + 6 ; *p && *p != '=' && *p != '/' ; p++);
- if (*p == '=') { /* eliminate initialization */
- for (q = p ; *q && *q != ';' ; q++);
- if (*q == '\0')
- q = NULL;
- else {
- while (p[-1] == ' ')
- p--;
- *p = '\0';
- }
- }
- addstr("extern", &decls);
- addstr(line1 + 6, &decls);
- if (q != NULL)
- addstr(q, &decls);
- amiddecls = 1;
- }
-}
-
-
-
-/*
- * Write the output to the file OUTTEMP.
- */
-
-void
-output() {
- FILE *fp;
- char **pp;
- struct event *ep;
-
- fp = ckfopen(OUTTEMP, "w");
- fputs(writer, fp);
- for (pp = header_files ; *pp ; pp++)
- fprintf(fp, "#include %s\n", *pp);
- fputs("\n\n\n", fp);
- writetext(&defines, fp);
- fputs("\n\n", fp);
- writetext(&decls, fp);
- for (ep = event ; ep->name ; ep++) {
- fputs("\n\n\n", fp);
- fputs(ep->comment, fp);
- fprintf(fp, "\nvoid\n%s() {\n", ep->routine);
- writetext(&ep->code, fp);
- fprintf(fp, "}\n");
- }
- fclose(fp);
-}
-
-
-/*
- * Return true if the new output file is different from the old one.
- */
-
-int
-file_changed() {
- register FILE *f1, *f2;
- register int c;
-
- if ((f1 = fopen(OUTFILE, "r")) == NULL
- || (f2 = fopen(OUTTEMP, "r")) == NULL)
- return 1;
- while ((c = getc(f1)) == getc(f2)) {
- if (c == EOF)
- return 0;
- }
- return 1;
-}
-
-
-/*
- * Touch a file. Returns 0 on failure, 1 on success.
- */
-
-int
-touch(file)
- char *file;
- {
- int fd;
- char c;
-
- if ((fd = open(file, O_RDWR)) < 0)
- return 0;
- if (read(fd, &c, 1) != 1) {
- close(fd);
- return 0;
- }
- lseek(fd, 0L, 0);
- write(fd, &c, 1);
- close(fd);
- return 1;
-}
-
-
-
-/*
- * A text structure is simply a block of text that is kept in memory.
- * Addstr appends a string to the text struct, and addchar appends a single
- * character.
- */
-
-void
-addstr(s, text)
- register char *s;
- register struct text *text;
- {
- while (*s) {
- if (--text->nleft < 0)
- addchar(*s++, text);
- else
- *text->nextc++ = *s++;
- }
-}
-
-
-void
-addchar(c, text)
- register struct text *text;
- {
- struct block *bp;
-
- if (--text->nleft < 0) {
- bp = ckmalloc(sizeof *bp);
- if (text->start == NULL)
- text->start = bp;
- else
- text->last->next = bp;
- text->last = bp;
- text->nextc = bp->text;
- text->nleft = BLOCKSIZE - 1;
- }
- *text->nextc++ = c;
-}
-
-/*
- * Write the contents of a text structure to a file.
- */
-void
-writetext(text, fp)
- struct text *text;
- FILE *fp;
- {
- struct block *bp;
-
- if (text->start != NULL) {
- for (bp = text->start ; bp != text->last ; bp = bp->next)
- fwrite(bp->text, sizeof (char), BLOCKSIZE, fp);
- fwrite(bp->text, sizeof (char), BLOCKSIZE - text->nleft, fp);
- }
-}
-
-FILE *
-ckfopen(file, mode)
- char *file;
- char *mode;
- {
- FILE *fp;
-
- if ((fp = fopen(file, mode)) == NULL) {
- fprintf(stderr, "Can't open %s\n", file);
- exit(2);
- }
- return fp;
-}
-
-void *
-ckmalloc(nbytes) {
- register char *p;
- char *malloc();
-
- if ((p = malloc(nbytes)) == NULL)
- error("Out of space");
- return p;
-}
-
-char *
-savestr(s)
- char *s;
- {
- register char *p;
-
- p = ckmalloc(strlen(s) + 1);
- strcpy(p, s);
- return p;
-}
-
-void
-error(msg)
- char *msg;
- {
- if (curfile != NULL)
- fprintf(stderr, "%s:%d: ", curfile, linno);
- fprintf(stderr, "%s\n", msg);
- exit(2);
-}
diff --git a/ash/mknodes.c b/ash/mknodes.c
deleted file mode 100644
index 88f632b0c59ca..0000000000000
--- a/ash/mknodes.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Kenneth Almquist.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1991 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)mknodes.c 5.1 (Berkeley) 3/7/91";*/
-static char rcsid[] = "mknodes.c,v 1.5 1993/09/05 17:32:07 mycroft Exp";
-#endif /* not lint */
-
-/*
- * This program reads the nodetypes file and nodes.c.pat file. It generates
- * the files nodes.h and nodes.c.
- */
-
-#include <stdio.h>
-
-
-#define MAXTYPES 50 /* max number of node types */
-#define MAXFIELDS 20 /* max fields in a structure */
-#define BUFLEN 100 /* size of character buffers */
-
-/* field types */
-#define T_NODE 1 /* union node *field */
-#define T_NODELIST 2 /* struct nodelist *field */
-#define T_STRING 3
-#define T_INT 4 /* int field */
-#define T_OTHER 5 /* other */
-#define T_TEMP 6 /* don't copy this field */
-
-
-struct field { /* a structure field */
- char *name; /* name of field */
- int type; /* type of field */
- char *decl; /* declaration of field */
-};
-
-
-struct str { /* struct representing a node structure */
- char *tag; /* structure tag */
- int nfields; /* number of fields in the structure */
- struct field field[MAXFIELDS]; /* the fields of the structure */
- int done; /* set if fully parsed */
-};
-
-
-int ntypes; /* number of node types */
-char *nodename[MAXTYPES]; /* names of the nodes */
-struct str *nodestr[MAXTYPES]; /* type of structure used by the node */
-int nstr; /* number of structures */
-struct str str[MAXTYPES]; /* the structures */
-struct str *curstr; /* current structure */
-
-
-FILE *infp;
-char line[1024];
-int linno;
-char *linep;
-
-
-char *savestr();
-#define equal(s1, s2) (strcmp(s1, s2) == 0)
-
-
-main(argc, argv)
- char **argv;
-{
- infp = stdin;
-
- if (argc != 3) {
- error("usage: mknodes file\n");
- return(1);
- }
- if ((infp = fopen(argv[1], "r")) == NULL) {
- error("Can't open %s", argv[1]);
- return(1);
- }
- while (readline()) {
- if (line[0] == ' ' || line[0] == '\t')
- parsefield();
- else if (line[0] != '\0')
- parsenode();
- }
- output(argv[2]);
- return(0);
-}
-
-
-
-parsenode() {
- char name[BUFLEN];
- char tag[BUFLEN];
- struct str *sp;
-
- if (curstr && curstr->nfields > 0)
- curstr->done = 1;
- nextfield(name);
- if (! nextfield(tag))
- error("Tag expected");
- if (*linep != '\0')
- error("Garbage at end of line");
- nodename[ntypes] = savestr(name);
- for (sp = str ; sp < str + nstr ; sp++) {
- if (equal(sp->tag, tag))
- break;
- }
- if (sp >= str + nstr) {
- sp->tag = savestr(tag);
- sp->nfields = 0;
- curstr = sp;
- nstr++;
- }
- nodestr[ntypes] = sp;
- ntypes++;
-}
-
-
-parsefield() {
- char name[BUFLEN];
- char type[BUFLEN];
- char decl[2 * BUFLEN];
- struct field *fp;
-
- if (curstr == NULL || curstr->done)
- error("No current structure to add field to");
- if (! nextfield(name))
- error("No field name");
- if (! nextfield(type))
- error("No field type");
- fp = &curstr->field[curstr->nfields];
- fp->name = savestr(name);
- if (equal(type, "nodeptr")) {
- fp->type = T_NODE;
- sprintf(decl, "union node *%s", name);
- } else if (equal(type, "nodelist")) {
- fp->type = T_NODELIST;
- sprintf(decl, "struct nodelist *%s", name);
- } else if (equal(type, "string")) {
- fp->type = T_STRING;
- sprintf(decl, "char *%s", name);
- } else if (equal(type, "int")) {
- fp->type = T_INT;
- sprintf(decl, "int %s", name);
- } else if (equal(type, "other")) {
- fp->type = T_OTHER;
- } else if (equal(type, "temp")) {
- fp->type = T_TEMP;
- } else {
- error("Unknown type %s", type);
- }
- if (fp->type == T_OTHER || fp->type == T_TEMP) {
- skipbl();
- fp->decl = savestr(linep);
- } else {
- if (*linep)
- error("Garbage at end of line");
- fp->decl = savestr(decl);
- }
- curstr->nfields++;
-}
-
-
-char writer[] = "\
-/*\n\
- * This file was generated by the mknodes program.\n\
- */\n\
-\n";
-
-output(file)
- char *file;
- {
- FILE *hfile;
- FILE *cfile;
- FILE *patfile;
- int i;
- struct str *sp;
- struct field *fp;
- char *p;
-
- if ((patfile = fopen(file, "r")) == NULL)
- error("Can't open %s", file);
- if ((hfile = fopen("nodes.h", "w")) == NULL)
- error("Can't create nodes.h");
- if ((cfile = fopen("nodes.c", "w")) == NULL)
- error("Can't create nodes.c");
- fputs(writer, hfile);
- for (i = 0 ; i < ntypes ; i++)
- fprintf(hfile, "#define %s %d\n", nodename[i], i);
- fputs("\n\n\n", hfile);
- for (sp = str ; sp < &str[nstr] ; sp++) {
- fprintf(hfile, "struct %s {\n", sp->tag);
- for (i = sp->nfields, fp = sp->field ; --i >= 0 ; fp++) {
- fprintf(hfile, " %s;\n", fp->decl);
- }
- fputs("};\n\n\n", hfile);
- }
- fputs("union node {\n", hfile);
- fprintf(hfile, " int type;\n");
- for (sp = str ; sp < &str[nstr] ; sp++) {
- fprintf(hfile, " struct %s %s;\n", sp->tag, sp->tag);
- }
- fputs("};\n\n\n", hfile);
- fputs("struct nodelist {\n", hfile);
- fputs("\tstruct nodelist *next;\n", hfile);
- fputs("\tunion node *n;\n", hfile);
- fputs("};\n\n\n", hfile);
- fputs("#ifdef __STDC__\n", hfile);
- fputs("union node *copyfunc(union node *);\n", hfile);
- fputs("void freefunc(union node *);\n", hfile);
- fputs("#else\n", hfile);
- fputs("union node *copyfunc();\n", hfile);
- fputs("void freefunc();\n", hfile);
- fputs("#endif\n", hfile);
-
- fputs(writer, cfile);
- while (fgets(line, sizeof line, patfile) != NULL) {
- for (p = line ; *p == ' ' || *p == '\t' ; p++);
- if (equal(p, "%SIZES\n"))
- outsizes(cfile);
- else if (equal(p, "%CALCSIZE\n"))
- outfunc(cfile, 1);
- else if (equal(p, "%COPY\n"))
- outfunc(cfile, 0);
- else
- fputs(line, cfile);
- }
-}
-
-
-
-outsizes(cfile)
- FILE *cfile;
- {
- int i;
-
- fprintf(cfile, "static const short nodesize[%d] = {\n", ntypes);
- for (i = 0 ; i < ntypes ; i++) {
- fprintf(cfile, " ALIGN(sizeof (struct %s)),\n", nodestr[i]->tag);
- }
- fprintf(cfile, "};\n");
-}
-
-
-outfunc(cfile, calcsize)
- FILE *cfile;
- {
- struct str *sp;
- struct field *fp;
- int i;
-
- fputs(" if (n == NULL)\n", cfile);
- if (calcsize)
- fputs(" return;\n", cfile);
- else
- fputs(" return NULL;\n", cfile);
- if (calcsize)
- fputs(" funcblocksize += nodesize[n->type];\n", cfile);
- else {
- fputs(" new = funcblock;\n", cfile);
- fputs(" funcblock += nodesize[n->type];\n", cfile);
- }
- fputs(" switch (n->type) {\n", cfile);
- for (sp = str ; sp < &str[nstr] ; sp++) {
- for (i = 0 ; i < ntypes ; i++) {
- if (nodestr[i] == sp)
- fprintf(cfile, " case %s:\n", nodename[i]);
- }
- for (i = sp->nfields ; --i >= 1 ; ) {
- fp = &sp->field[i];
- switch (fp->type) {
- case T_NODE:
- if (calcsize) {
- indent(12, cfile);
- fprintf(cfile, "calcsize(n->%s.%s);\n",
- sp->tag, fp->name);
- } else {
- indent(12, cfile);
- fprintf(cfile, "new->%s.%s = copynode(n->%s.%s);\n",
- sp->tag, fp->name, sp->tag, fp->name);
- }
- break;
- case T_NODELIST:
- if (calcsize) {
- indent(12, cfile);
- fprintf(cfile, "sizenodelist(n->%s.%s);\n",
- sp->tag, fp->name);
- } else {
- indent(12, cfile);
- fprintf(cfile, "new->%s.%s = copynodelist(n->%s.%s);\n",
- sp->tag, fp->name, sp->tag, fp->name);
- }
- break;
- case T_STRING:
- if (calcsize) {
- indent(12, cfile);
- fprintf(cfile, "funcstringsize += strlen(n->%s.%s) + 1;\n",
- sp->tag, fp->name);
- } else {
- indent(12, cfile);
- fprintf(cfile, "new->%s.%s = nodesavestr(n->%s.%s);\n",
- sp->tag, fp->name, sp->tag, fp->name);
- }
- break;
- case T_INT:
- case T_OTHER:
- if (! calcsize) {
- indent(12, cfile);
- fprintf(cfile, "new->%s.%s = n->%s.%s;\n",
- sp->tag, fp->name, sp->tag, fp->name);
- }
- break;
- }
- }
- indent(12, cfile);
- fputs("break;\n", cfile);
- }
- fputs(" };\n", cfile);
- if (! calcsize)
- fputs(" new->type = n->type;\n", cfile);
-}
-
-
-indent(amount, fp)
- FILE *fp;
- {
- while (amount >= 8) {
- putc('\t', fp);
- amount -= 8;
- }
- while (--amount >= 0) {
- putc(' ', fp);
- }
-}
-
-
-int
-nextfield(buf)
- char *buf;
- {
- register char *p, *q;
-
- p = linep;
- while (*p == ' ' || *p == '\t')
- p++;
- q = buf;
- while (*p != ' ' && *p != '\t' && *p != '\0')
- *q++ = *p++;
- *q = '\0';
- linep = p;
- return (q > buf);
-}
-
-
-skipbl() {
- while (*linep == ' ' || *linep == '\t')
- linep++;
-}
-
-
-int
-readline() {
- register char *p;
-
- if (fgets(line, 1024, infp) == NULL)
- return 0;
- for (p = line ; *p != '#' && *p != '\n' && *p != '\0' ; p++);
- while (p > line && (p[-1] == ' ' || p[-1] == '\t'))
- p--;
- *p = '\0';
- linep = line;
- linno++;
- if (p - line > BUFLEN)
- error("Line too long");
- return 1;
-}
-
-
-
-error(msg, a1, a2, a3, a4, a5, a6)
- char *msg;
- {
- fprintf(stderr, "line %d: ", linno);
- fprintf(stderr, msg, a1, a2, a3, a4, a5, a6);
- putc('\n', stderr);
- exit(2);
-}
-
-
-
-char *
-savestr(s)
- char *s;
- {
- register char *p;
- char *malloc();
-
- if ((p = malloc(strlen(s) + 1)) == NULL)
- error("Out of space");
- strcpy(p, s);
- return p;
-}
diff --git a/ash/trap.c b/ash/trap.c
index 3496404851f16..bf254af9d3c45 100644
--- a/ash/trap.c
+++ b/ash/trap.c
@@ -391,9 +391,9 @@ SHELLPROC {
* Signal handler.
*
* The __cdecl is to work around the fact that the Linux/i386 kernel prior
- * to 2.6.9(?) didn't pass the proper arguments to regparm'd signal handlers.
+ * to 2.6.9-rc2 didn't pass the proper arguments to regparm'd signal handlers.
*/
-/*__cdecl*/ void
+__cdecl void
onsig(int signo)
{
bsd_signal(signo, onsig);