rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit b87bfedf65c289bf0ee5338c9e10492b70b1e8e0
parent 5556dde4d3ad4e34267320b1411fc090b18a24b0
Author: Toby Goodwin <tgoodwin@cygnus.co.uk>
Date:   Mon,  7 Jul 1997 00:00:01 +0100

beta: rc-1.5b2

Diffstat:
MCHANGES | 15+++++++++++++++
DMakefile | 65-----------------------------------------------------------------
AMakefile.in | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME | 236++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Mbuiltins.c | 44+++++++++++++++++++-------------------------
Dconfig.h-dist | 204-------------------------------------------------------------------------------
Aconfig.h.in | 44++++++++++++++++++++++++++++++++++++++++++++
Aconfigure | 2541+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aconfigure.in | 287+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mexec.c | 12+++++++-----
Mfn.c | 4++--
Mfootobar.c | 6+++---
Mglob.c | 38+++++++++++++++++++++++---------------
Mglom.c | 97++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Agroup.h | 9+++++++++
Mhash.c | 4++--
Mheredoc.c | 8++++----
Dhistory/Makefile | 6------
Minput.c | 25+++++++++++++------------
Ainstall-sh | 250+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mjbwrap.h | 5++---
Mlex.c | 8++++----
Mlist.c | 6+++---
Mmain.c | 2+-
Mmksignal | 3++-
Mnalloc.c | 22+++++++++++-----------
Mopen.c | 4----
Mprint.c | 50+++++++++++++++++++++++++++++++++-----------------
Mproto.h | 82++++++++++++++++++++-----------------------------------------------------------
Mrc.h | 78+++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Arlimit.h | 42++++++++++++++++++++++++++++++++++++++++++
Msignal.c | 9++++++++-
Mstatus.c | 8++++----
Mtree.c | 4++--
Mutils.c | 4++--
Mvar.c | 2+-
Mversion.c | 2+-
Mwait.c | 18+++++++++++-------
Mwalk.c | 4++--
Mwhich.c | 35+++++++++++++++++++++--------------
Ay.tab.c | 1070+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ay.tab.h | 33+++++++++++++++++++++++++++++++++
42 files changed, 4838 insertions(+), 628 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -261,3 +261,18 @@ wait.c: Got rid of memory leak in rc_fork, renamed SIGCHK to sigchk. walk.c: Fixed pre-redirection bug, removed spurious setsigdefaults(), renamed SIGCHK to sigchk. + + +Changes since rc-1.5beta1 + + Configuration: rc now uses GNU autoconf. + + Portability: mksignal works on HPUX 10. + + Portability: resources can be (quad_t). + + Bug: if rc was started with SIGCLD == SIG_IGN (e.g. by Solaris's + rshd) it would loop. Fixed by resetting SIGCLD to SIG_DFL if it + was SIG_IGN when rc was started. + + Portability: POSIXish systems don't have NGROUPS. diff --git a/Makefile b/Makefile @@ -1,65 +0,0 @@ -# Makefile for rc. - -# Please check the configuration parameters in config.h (and if you want -# to make sure, the definitions in proto.h) to make sure they are correct -# for your system. - -SHELL=/bin/sh - -# Uncomment this line if you have defined the NOEXECVE macro in config.h -#EXECVE=execve.o - -# Define this macro if you wish to extend rc via locally-defined builtins. -# An interface is provided in addon.[ch]. Note that the author does not -# endorse any such extensions, rather hopes that this way rc will become -# useful to more people. -#ADDON=addon.o - -# Use an ANSI compiler (or at least one that groks prototypes and void *): -CC=gcc -g -O -CFLAGS= -LDFLAGS= - -# You may substitute "bison -y" for yacc. (You want to choose the one that -# makes a smaller y.tab.c. Also see the README about Sun's yacc.) -YACC=yacc - -OBJS=$(ADDON) builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o \ - glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \ - nalloc.o open.o print.o redir.o sigmsgs.o signal.o status.o tree.o \ - utils.o var.o version.o wait.o walk.o which.o y.tab.o - -# If rc is compiled with READLINE defined, you must supply the correct -# arguments to ld on this line. Typically this would be something like: -# -# $(CC) -o $@ $(OBJS) -lreadline -ltermcap - -rc: $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) - -sigmsgs.c: mksignal - sh mksignal /usr/include/sys/signal.h - -y.tab.c: parse.y - $(YACC) -d parse.y - -config.h: config.h-dist - cp config.h-dist config.h - -trip: rc - ./rc -p < trip.rc - -clean: force - rm -f *.o *.tab.* sigmsgs.* - -history: force - cd history; make CC="$(CC)" $(HISTORYMAKEFLAGS) - -force: - -# dependencies: - -$(OBJS): config.h -sigmsgs.h: sigmsgs.c -lex.o y.tab.o: y.tab.c -builtins.c fn.c status.c hash.c: sigmsgs.h diff --git a/Makefile.in b/Makefile.in @@ -0,0 +1,80 @@ +# Makefile.in for rc. + +SHELL=/bin/sh + +bindir=@bindir@ +exec_prefix=@exec_prefix@ +mandir=@mandir@ +prefix=@prefix@ + +CC=@CC@ +CFLAGS=@CFLAGS@ +LDFLAGS=@CFLAGS@ +LIBS=@LIBS@ + +INSTALL=@INSTALL@ +INSTALL_DATA=@INSTALL_DATA@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +LN=@LN@ +YACC=@YACC@ + +HISTORY=@HISTORY@ + +OBJS=@ADDON@ builtins.o except.o exec.o @EXECVE@ fn.o footobar.o getopt.o \ + glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \ + nalloc.o open.o print.o redir.o sigmsgs.o signal.o status.o tree.o \ + utils.o var.o version.o wait.o walk.o which.o y.tab.o + +all: rc $(HISTORY) + +rc: $(OBJS) + $(CC) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) + +sigmsgs.c: mksignal + sh mksignal @SIGNAL_H@ + +y.tab.c: parse.y + $(YACC) -d parse.y + +trip: rc + ./rc -p < trip.rc + +clean: force + rm -f rc $(HISTORY) - *.o *.tab.* sigmsgs.* config.cache config.log + +cleaner: clean + rm -f config.status config.h Makefile + +cleanest: cleaner + rm -f configure + +history: force + cd history; make CC="$(CC)" $(HISTORYMAKEFLAGS) + +install: all + $(INSTALL_PROGRAM) rc $(bindir) + $(INSTALL_DATA) rc.1 $(mandir)/man1/rc.1 + case "x$(HISTORY)" in \ + x) \ + ;; \ + *) \ + $(LN) $(HISTORY) - ;\ + $(INSTALL_PROGRAM) - $(bindir) ;\ + $(LN) $(bindir)/- $(bindir)/-- ;\ + $(LN) $(bindir)/- $(bindir)/-p ;\ + $(LN) $(bindir)/- $(bindir)/--p ;\ + $(INSTALL_DATA) history/history.1 $(mandir)/man1/history.1 \ + ;; \ + esac + +force: + +# dependencies: + +$(OBJS): config.h proto.h rc.h +sigmsgs.h: sigmsgs.c +lex.o y.tab.o: y.tab.c + +builtins.o except.o exec.o input.o signal.o utils.o wait.o walk.o: jbwrap.h +builtins.o: rlimit.h +builtins.o fn.o hash.o signal.o status.o: sigmsgs.h diff --git a/README b/README @@ -1,111 +1,197 @@ -This is release 1.5 of rc. +This is release 1.5b2 of rc. -Read COPYRIGHT for copying information. All files are +Read COPYRIGHT for copying information. All files are -Copyright 1991, Byron Rakitzis. + Copyright 1991, 1997 Byron Rakitzis. COMPILING -rc was written in portable ANSI C. If you don't have an ANSI compiler +rc was written in portable ANSI C. If you don't have an ANSI compiler like gcc or something close (e.g., sgi's cc) read further down on how to convert rc's source to old C. -Please read the Makefile, and copy config.h-dist to config.h and -examine the parameters in there; they let you customize rc to your -Unix. For example, some Unices support /dev/fd, or some have FIFOs. -If you do not perform this step then the Makefile will automatically -copy config.h-dist to config.h and proceed assuming that everything -is ok. Note that config.h-dist supplies default parameter configurations -for SunOS, NeXT-OS, Irix, Ultrix and some others. Finally, if you're -having trouble you may want to look at proto.h and see if everything -in there jibes with your system. +The following commands are all you need to configure, build, +test, and install rc. -After you've built rc, you may wish to run it through a test script -to see that everything is ok. Type "make trip" for this. This will -produce some output, and end with "trip is complete". If the trip -ends with "trip took a wrong turn..." then drop me a line. + $ sh configure + $ make + $ make trip + # make install + +There are lots of options you can give to configure to modify rc's +behaviour. You can also select a command line history library to link +against. For a summary of all options, run `sh configure --help'. + +You can specify Makefile variables by setting the corresponding +environment variables. For example, you might want to set `CC=cc', to +prevent configure looking for gcc, or set an initial value for `LIBS', +as in the example below. + +Here are the configure options you may want to use, in approximately +descending order of usefulness. + + --with-editline + + This option tells rc to use Simmule Turner's and Rich $alz's editline + package, which you can get from the following location. This is + essentially a lightweight version of GNU readline, providing EMACS + style command line editing and history. + + ftp://ftp.pipex.net/people/tim/editline.tar.gz + + If the editline library is not installed in a standard place, you + can tell configure where to find it by setting the environment + variable LIBS. For example, the maintainer builds rc by copying + libedit.a into the rc directory and then running this configure + command. + + LIBS=-L. sh configure --with-editline + + --with-readline + + This option tells rc to use the GNU readline package, which is similar + to editline, but has many more features. The readline package is over + 6 times the size of editline (whether you count lines of code, or the + library itself). You probably need to tell the compiler to link with + the termcap library if you're using readline. For example, here is + the configure command the maintainer uses to build rc with readline. + + LIBS=-ltermcap sh configure --with-readline + + --enable-history + + Use this option if you want to build and install the programs that + support a crude history mechanism. + +You can't use `--with-editline' and `--with-readline' together, of course, +and if you have either of those you probably don't want to bother with +`--enable-history'. -To compile the history program, go into the history subdirectory -and type "make". This will create a binary called "history". However, -in order for it to work as advertised it must be installed into -your bin as four files named -, --, -p and --p. (these can be soft -or hard links to the same file) + --prefix=/path -rc may also be linked with either GNU readline (10,000+ lines of -code!) or a supplied readline-like system by Simmule Turner (1,000+ -lines of code). See the Makefile on how to do this. + By default, `prefix' is /usr/local, which means that `make install' + installs rc (and possibly the history programs) in /usr/local/bin, and + man pages in /usr/local/man/man1. Use this option to change where + `make install' puts things. + + --disable-builtin-echo + + By default, the `echo' command is builtin to rc for efficiency reasons. + It is the only builtin which is not essential, and purists may wish + to omit it. + + --disable-def-interp + --enable-def-interp=/bin/foo + + By default, a program that fails with "Exec format error" is handed to + /bin/sh. This does the Right Thing for scripts that start with `:' to + indicate that they are sh scripts. You can disable this behaviour + entirely, or specify a different default interpreter. + + --disable-def-path + --enable-def-path="/usr/local/bin","/usr/bin" + + By default, if rc is started with no PATH, it uses a default path. + The default path is constructed at configure time, and consists + of each of the following directories that exist, in order. + + /usr/local/bin /usr/bin /usr/ucb /bin . + + You can disable this, or specify a different default path. Note + that the quote marks (") must be seen by configure; you will + probably need to quote them to your shell. (Not if it's already + rc, but then you will need to quote the `='.) + + --disable-job + + By default, rc puts backgrounded processes into a new process group, + as though it were a job control shell (it isn't). This is usually + needed to work around bugs in application programs which install + signal handlers for the keyboard signals without checking whether the + signal was being ignored. This option disables the default behaviour, + making rc behave like a traditional sh. You are unlikely to want this + option on any Unix system. + + --disable-protect-env + + By default, rc encodes special characters in environment variables. + This is necessary on all known Unix systems to prevent sh either + dying or discarding the variables. This option disables the default + behaviour. You are unlikely to want this option on any Unix system. + +After you've built rc, you may wish to run it through a test script +to see that everything is ok. Type `make trip' for this. This will +produce some output, and end with "trip is complete". If the trip ends +with "trip took a wrong turn..." please contact the maintainer. (If +you've built in either of the command line history libraries, the trip +will fail near the end with `trip took a wrong turn: dot -i'.) BUGS -Send bug reports to byron@archone.tamu.edu. If a core dump is -generated, sending me a backtrace will help me out a great deal. You -can get a backtrace like this: +Send bug reports to <tim@uk.uu.net> (<tgoodwin@cygnus.co.uk> after +1997-07-27). If a core dump is generated, sending a backtrace will +help a great deal. You can get a backtrace like this. ; gdb rc core (gdb) where <<<BACKTRACE INFO>>> (gdb) -Also, always report the machine, compiler and OS used to make rc. It's -possible I may have access to a machine of that type, in which case it -becomes much easier for me to track the bug down. - -If you are using gcc, please make sure that you have a recent version of -the compiler (1.39 and up) before you send me a note; I have found that -older versions of gcc choke over rc and generate bad code on several -architectures. (this is especially relevant for the the MIPS architecture) +Also, always report the machine, OS (`uname -a'), and compiler used to +make rc; this information is extremely valuable. FEEPING CREATURISM See the end of the man page, under "INCOMPATABILITIES" for (known?) -differences from the "real" rc. Most of these changes were necessary -to get rc to work in a reasonable fashion on a real (i.e., commercial, -non-Labs) UNIX system; a few were changes motivated by concern -about some inadequacies in the original design. +differences from the "real" rc. Most of these changes were necessary +to get rc to work in a reasonable fashion on a real (i.e. commercial, +non-Labs) Unix system; a few were changes motivated by concern about +some inadequacies in the original design. YACC The yacc that Sun ships with SunOS 4.1.1 calls malloc() to allocate -space for the state stack, and requires a call to YYACCEPT or YYABORT -to free this memory. This means that if rc takes an interrupt while -parsing a command (say, if ^C is typed), yacc will leak away this -memory. The solution is to use a yacc which statically allocates -this array, such as the yacc in the BSD distribution. Berkeley yacc- -generated y.tab.c and y.tab.h are shipped with rc in case you cannot -get hold of Berkeley yacc. +space for the state stack, and requires a call to YYACCEPT or YYABORT to +free this memory. This means that if rc takes an interrupt while parsing +a command (say, if ^C is typed), yacc will leak away this memory. The +solution is to use a yacc which statically allocates this array, such +as the yacc in the BSD distribution. Berkeley yacc-generated y.tab.c +and y.tab.h are shipped with rc in case you cannot get hold of Berkeley +yacc. OLD C If you need to convert rc's source into K&R C, you need to run the source through a filter called "unproto", posted in comp.sources.misc. -A sample "cpp" shell script that I used to run unproto under SunOS -is supplied with rc. +A sample "cpp" shell script that I used to run unproto under SunOS is +supplied with rc. CREDITS -This shell was written by me, Byron Rakitzis, but kudos go to Paul -Haahr for letting me know what a shell should do and for contributing -certain bits and pieces to rc (notably the limits code, print.c, -most of which.c and the backquote redirection code), and to Hugh -Redelmeier for running rc through his fussy ANSI compiler and -thereby provoking interesting discussions about portability, and -also for providing many valuable suggestions for improving rc's -code in general. Finally, many thanks go to David Sanderson, for -reworking the man page to format well with troff, and for providing -many suggestions both for rc and its man page. - -Thanks to Boyd Roberts for the original history.c, and to Hugh -again for re-working parts of that code. - -Of course, without Tom Duff's design of the original rc, I could -not have written this shell (though I probably would have written -*a* shell). Almost of all of the features, with minor exceptions, -have been implemented as described in the Unix v10 manuals. Hats -off to td for designing a C-like, minimal but very useful shell. - -Tom Duff has kindly given permission for the paper he wrote for -UKUUG to be distributed with this version of rc (called "plan9.ps" -in the same ftp directory as the shell). Please read this paper -bearing in mind that it describes a program that was written at -AT&T and that the version of rc presented here differs in some -respects. +This shell was written by me, Byron Rakitzis, but kudos go to Paul Haahr +for letting me know what a shell should do and for contributing certain +bits and pieces to rc (notably the limits code, print.c, most of which.c +and the backquote redirection code), and to Hugh Redelmeier for running +rc through his fussy ANSI compiler and thereby provoking interesting +discussions about portability, and also for providing many valuable +suggestions for improving rc's code in general. Finally, many thanks +go to David Sanderson, for reworking the man page to format well with +troff, and for providing many suggestions both for rc and its man page. + +Thanks to Boyd Roberts for the original history.c, and to Hugh again for +re-working parts of that code. + +Of course, without Tom Duff's design of the original rc, I could not +have written this shell (though I probably would have written *a* +shell). Almost of all of the features, with minor exceptions, have been +implemented as described in the Unix v10 manuals. Hats off to td for +designing a C-like, minimal but very useful shell. + +Tom Duff has kindly given permission for the paper he wrote for UKUUG to +be distributed with this version of rc (called "plan9.ps" in the same +ftp directory as the shell). Please read this paper bearing in mind that +it describes a program that was written at AT&T and that the version of +rc presented here differs in some respects. + +The current maintainer of rc is Tim Goodwin, <tim@uk.uu.net> +(<tgoodwin@cygnus.co.uk> after 1997-07-27). diff --git a/builtins.c b/builtins.c @@ -7,17 +7,16 @@ because of a bad umask. */ +#include "rc.h" + #include <sys/ioctl.h> #include <setjmp.h> #include <errno.h> -#include "rc.h" + #include "jbwrap.h" #include "sigmsgs.h" -#ifndef NOLIMITS -#include <sys/time.h> -#include <sys/resource.h> -#endif #include "addon.h" +#include "rlimit.h" extern int umask(int); @@ -25,10 +24,11 @@ static void b_break(char **), b_cd(char **), b_eval(char **), b_exit(char **), b_newpgrp(char **), b_return(char **), b_shift(char **), b_umask(char **), b_wait(char **), b_whatis(char **); -#ifndef NOLIMITS +#if HAVE_SETRLIMIT static void b_limit(char **); #endif -#ifndef NOECHO + +#if RC_ECHO static void b_echo(char **); #endif @@ -39,13 +39,13 @@ static struct { { b_break, "break" }, { b_builtin, "builtin" }, { b_cd, "cd" }, -#ifndef NOECHO +#if RC_ECHO { b_echo, "echo" }, #endif { b_eval, "eval" }, { b_exec, "exec" }, { b_exit, "exit" }, -#ifndef NOLIMITS +#if HAVE_SETRLIMIT { b_limit, "limit" }, #endif { b_newpgrp, "newpgrp" }, @@ -100,7 +100,7 @@ static void badnum(char *num) { extern void b_exec(char **av) { } -#ifndef NOECHO +#if RC_ECHO /* echo -n omits a newline. echo -- -n echos '-n' */ static void b_echo(char **av) { @@ -121,7 +121,7 @@ static void b_echo(char **av) { static void b_cd(char **av) { List *s, nil; char *path = NULL; - SIZE_T t, pathlen = 0; + size_t t, pathlen = 0; if (*++av == NULL) { s = varlookup("home"); *av = (s == NULL) ? "/" : s->w; @@ -250,7 +250,8 @@ extern void b_builtin(char **av) { /* wait for a given process, or all outstanding processes */ static void b_wait(char **av) { - int stat, pid; + int stat; + pid_t pid; if (av[1] == NULL) { waitforall(); return; @@ -414,15 +415,13 @@ static void b_newpgrp(char **av) { arg_count("newpgrp"); return; } - setpgrp(rc_pid, rc_pid); -#ifdef TIOCSPGRP - ioctl(2, TIOCSPGRP, &rc_pid); -#endif + setpgid(rc_pid, rc_pid); /* XXX check return value */ + tcsetpgrp(2, rc_pid); /* XXX check return value */ } /* Berkeley limit support was cleaned up by Paul Haahr. */ -#ifndef NOLIMITS +#if HAVE_SETRLIMIT typedef struct Suffix Suffix; struct Suffix { const Suffix *next; @@ -464,14 +463,9 @@ static const Limit limits[] = { { NULL, 0, NULL } }; -#ifndef SYSVR4 -extern int getrlimit(int, struct rlimit *); -extern int setrlimit(int, struct rlimit *); -#endif - static void printlimit(const Limit *limit, bool hard) { struct rlimit rlim; - long lim; + rlim_t lim; getrlimit(limit->flag, &rlim); if (hard) lim = rlim.rlim_max; @@ -486,11 +480,11 @@ static void printlimit(const Limit *limit, bool hard) { lim /= suf->amount; break; } - fprint(1, "%s \t%d%s\n", limit->name, lim, (suf == NULL || lim == 0) ? "" : suf->name); + fprint(1, RLIM_FMT, limit->name, (RLIM_CONV)lim, (suf == NULL || lim == 0) ? "" : suf->name); } } -static long parselimit(const Limit *limit, char *s) { +static rlim_t parselimit(const Limit *limit, char *s) { char *t; int len = strlen(s); long lim = 1; diff --git a/config.h-dist b/config.h-dist @@ -1,204 +0,0 @@ -/* Copy config.h-dist to config.h and edit config.h, don't edit this file */ - -/* - * Configuration parameters for rc. Suggested defaults are at the bottom - * of this file (you should probably look at those first to see if your - * system matches one of them; you can search for the beginning of the - * defaults section by looking for the string "#ifndef CUSTOM"). If you - * want to override the suggested defaults, define the macro CUSTOM. -#define CUSTOM - */ - -/* - * (Note that certain default settings redefine this macro) - * DEFAULTPATH the default search path that rc uses when it is started - * without either a $PATH or $path environment variable. You must pick - * something sensible for your system if you don't like the path shown - * below. - */ -#define DEFAULTPATH "/usr/ucb", "/usr/bin", "/bin", "." - -/* - * Define the macro NODIRENT if your system has <sys/dir.h> but not - * <dirent.h>. (e.g., NeXT-OS and RISCos) -#define NODIRENT - */ - -/* - * Define the macro SVSIGS if your system has System V signal semantics, - * i.e., if "slow" system calls are interrupted rather than resumed - * after returning from an interrupt handler. (If you are not sure what - * this means, see the man page for signal(2). In any case, it is probably - * safe to leave this macro undefined.) -#define SVSIGS - */ - -/* - * Define the macro NOCMDARG if you do not have /dev/fd or fifos on your - * system. You may also want to define this if you have broken fifos. -#define NOCMDARG - */ - -/* - * Define TMPDIR if you need to have rc create its fifos in a directory - * other than /tmp. For example, if you have a Sun with /tmp mounted - * as a ramdisk (type "tmpfs") then you cannot use fifos in /tmp (sigh). -#define TMPDIR "/var/tmp" - */ - -/* - * Define the macro DEVFD if your system supports /dev/fd. -#define DEVFD - */ - -/* - * Define the macro NOLIMITS if your system does not support Berkeley - * limits. -#define NOLIMITS - */ - -/* - * Define the macro NOSIGCLD if your system uses SIGCLD in the System - * V way. (e.g., sgi's Irix) -#define NOSIGCLD - */ - -/* - * Define the macro READLINE if you want rc to call GNU readline - * instead of read(2) on interactive shells. -#define READLINE - */ - -/* - * Define the macro NOEXECVE if your Unix does not interpret #! in the - * kernel, and uncomment the EXECVE variable in the Makefile. -#define NOEXECVE - */ - -/* - * If you want rc to default to some interpreter for files which don't - * have a legal #! on the first line, define the macro DEFAULTINTERP. -#define DEFAULTINTERP "/bin/sh" - */ - -/* - * If your /bin/sh (or another program you care about) rejects environment - * variables with special characters in them (such as ':' or '-'), rc can - * put out ugly variable names using [_0-9a-zA-Z] that encode the real name; - * define PROTECT_ENV for this hack. (Known offenders: every sh I have tried; - * SunOS (silently discards), NeXT (aborts with error), SGI (aborts with - * error), Ultrix (sh seems to work, sh5 aborts with error)) -#define PROTECT_ENV - */ - -/* - * Define the macro NOECHO if you wish to omit rc's echo builtin from the - * compile. -#define NOECHO - */ - -/* - * Define the NOJOB if you do *not* wish rc to perform backgrounding - * as if it were a job-control shell; that is, if you do *not* wish - * it to put a command spawned in the background into a new process - * group. Since most systems support job control and since there are - * many broken programs that do not behave correctly when backgrounded - * in a v7 non-job-control fashion, rc by default performs a job- - * control-like backgrounding. -#define NOJOB - */ - -/* Beginning of defaults section: */ - -#ifndef CUSTOM - -/* - * Suggested settings for Sun, NeXT and sgi (machines here at TAMU): - */ - -#ifdef NeXT /* Used on NextOS 2.1 */ -#define NODIRENT -#define PROTECT_ENV -#define NOCMDARG -#endif - -#ifdef sgi /* Used on Irix 3.3.[12] */ -#define SVSIGS -#define NOSIGCLD -#define PROTECT_ENV -#undef DEFAULTPATH -#define DEFAULTPATH "/usr/bsd", "/usr/sbin", "/usr/bin", "/bin", "." -#endif - -#ifdef sun /* Used on SunOS 4.1.1 */ -#define PROTECT_ENV -#undef DEFAULTPATH -#define DEFAULTPATH "/usr/ucb", "/usr/bin", "." -#endif - -/* - * Suggested settings for HP300 running 4.3BSD-utah (DWS): - */ - -#if defined(hp300) && !defined(hpux) -#define NODIRENT -#define NOCMDARG -#define DEFAULTINTERP "/bin/sh" -#define PROTECT_ENV -#endif - -/* - * Suggested settings for Ultrix - */ - -#ifdef ultrix -#define PROTECT_ENV -#define DEFAULTINTERP "/bin/sh" /* so /bin/true can work */ -#endif - -/* - * Suggested settings for RISCos 4.52 - */ - -/* - This doesn't work without interfering with other MIPS-based - systems' configuration. Please do it by hand. -*/ - -#if defined(host_mips) && defined(MIPSEB) && defined(SYSTYPE_BSD43) -#define NODIRENT -#define PROTECT_ENV -#endif - -/* - * Suggested settings for AIX - */ - -#ifdef _AIX -#define PROTECT_ENV -#endif - -/* - * Suggested settings for OSF/1 1.0 - */ - -#ifdef OSF1 -#define PROTECT_ENV -#endif - -/* - * Suggested settings for Unicos XXX - */ - -#ifdef cray -#define PROTECT_ENV -#define NOLIMITS -#define word _word -#define DEFAULTINTERP "/bin/sh" -#endif - -#endif /* CUSTOM */ - -#ifndef TMPDIR -#define TMPDIR "/tmp" -#endif diff --git a/config.h.in b/config.h.in @@ -0,0 +1,44 @@ +/* Header files */ +#undef STDC_HEADERS + +#undef HAVE_SYS_RESOURCE_H +#undef RLIMIT_NEEDS_KERNEL +#undef HAVE_SYS_TIME_H +#undef HAVE_UNISTD_H + +#undef HAVE_DIRENT_H +#undef HAVE_SYS_NDIR_H +#undef HAVE_SYS_DIR_H +#undef HAVE_NDIR_H + +/* Functions */ +#undef HAVE_GETGROUPS +#undef HAVE_SETPGRP +#undef HAVE_SETRLIMIT + +/* Types */ +#undef HAVE_GID_T +#undef HAVE_RLIM_T +#undef HAVE_QUAD_T +#undef RLIM_T_IS_QUAD_T +#undef GETGROUPS_T +#undef gid_t +#undef pid_t +#undef size_t +#undef uid_t + +/* OS features */ +#undef HASH_BANG +#undef HAVE_DEV_FD +#undef HAVE_FIFO +#undef HAVE_PROC_SELF_FD +#undef HAVE_RESTARTABLE_SYSCALLS +#undef SETPGRP_VOID + +/* rc features */ +#undef DEFAULTINTERP +#undef DEFAULTPATH +#undef RC_ECHO +#undef RC_JOB +#undef PROTECT_ENV +#undef READLINE diff --git a/configure b/configure @@ -0,0 +1,2541 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --disable-builtin-echo Don't include \`echo' as a builtin" +ac_help="$ac_help + --disable-job Don't do job-control-style backgrounding" +ac_help="$ac_help + --disable-protect-env Don't protect environment names" +ac_help="$ac_help + --enable-def-interp=/bin/foo + Use /bin/foo as default interpreter [/bin/sh]" +ac_help="$ac_help + --enable-def-path=\"/usr/local/bin/\",\"/usr/bin\" + Default path [All of these that exist + (/usr/local/bin /usr/bin /usr/ucb /bin .)]" +ac_help="$ac_help + --enable-history Build history subprograms" +ac_help="$ac_help + --with-addon Extra builtins, from addon.c " +ac_help="$ac_help + --with-editline Simmule Turner's line editing" +ac_help="$ac_help + --with-readline Bloated GNU line editing" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.12" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=rc.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:549: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:578: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:626: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <<EOF +#line 636 "configure" +#include "confdefs.h" +main(){return(0);} +EOF +if { (eval echo configure:640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:660: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:665: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:674: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:689: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +case "x$GCC" in +xyes) + CFLAGS="-Wall $CFLAGS" + ;; +esac + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:752: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +for ac_prog in 'bison -y' byacc +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:806: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_YACC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +YACC="$ac_cv_prog_YACC" +if test -n "$YACC"; then + echo "$ac_t""$YACC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +for ac_prog in ln cp +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:840: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LN"; then + ac_cv_prog_LN="$LN" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LN="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +LN="$ac_cv_prog_LN" +if test -n "$LN"; then + echo "$ac_t""$LN" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$LN" && break +done + + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:870: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 885 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:891: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 902 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in sys/resource.h sys/time.h sys/types.h unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:934: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 939 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:944: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:975: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 980 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + ac_header_dirent=$ac_hdr; break +else + echo "$ac_t""no" 1>&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:1013: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <<EOF +#line 1021 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:1032: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:1054: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <<EOF +#line 1062 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:1073: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1096: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1101 "configure" +#include "confdefs.h" +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1109: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1126 "configure" +#include "confdefs.h" +#include <string.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext <<EOF +#line 1144 "configure" +#include "confdefs.h" +#include <stdlib.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext <<EOF +#line 1165 "configure" +#include "confdefs.h" +#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1176: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + +echo $ac_n "checking for signal names in <sys/signal.h>""... $ac_c" 1>&6 +echo "configure:1201: checking for signal names in <sys/signal.h>" >&5 +if eval "test \"`echo '$''{'rc_cv_sys_signal_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if grep SIGINT /usr/include/sys/signal.h >/dev/null 2>&1; then + rc_cv_sys_signal_h=yes + else + rc_cv_sys_signal_h=no + fi +fi + +echo "$ac_t""$rc_cv_sys_signal_h" 1>&6 + +case "x$rc_cv_sys_signal_h" in +xyes) + SIGNAL_H=/usr/include/sys/signal.h + ;; +xno) + echo $ac_n "checking for signal names in <asm/signal.h>""... $ac_c" 1>&6 +echo "configure:1220: checking for signal names in <asm/signal.h>" >&5 +if eval "test \"`echo '$''{'rc_cv_asm_signal_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if grep SIGINT /usr/include/asm/signal.h >/dev/null 2>&1; then + rc_cv_asm_signal_h=yes + else + rc_cv_asm_signal_h=no + fi +fi + +echo "$ac_t""$rc_cv_asm_signal_h" 1>&6 + + case "x$rc_cv_asm_signal_h" in + xyes) + SIGNAL_H=/usr/include/asm/signal.h + ;; + xno) + { echo "configure: error: Can't find signal names in <sys/signal.h> or <asm/signal.h>" 1>&2; exit 1; } + ;; + esac + ;; +esac + + +echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 +echo "configure:1246: checking for uid_t in sys/types.h" >&5 +if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1251 "configure" +#include "confdefs.h" +#include <sys/types.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "uid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_uid_t=yes +else + rm -rf conftest* + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_type_uid_t" 1>&6 +if test $ac_cv_type_uid_t = no; then + cat >> confdefs.h <<\EOF +#define uid_t int +EOF + + cat >> confdefs.h <<\EOF +#define gid_t int +EOF + +fi + +echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6 +echo "configure:1280: checking type of array argument to getgroups" >&5 +if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_type_getgroups=cross +else + cat > conftest.$ac_ext <<EOF +#line 1288 "configure" +#include "confdefs.h" + +/* Thanks to Mike Rendell for this test. */ +#include <sys/types.h> +#define NGID 256 +#undef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +main() +{ + gid_t gidset[NGID]; + int i, n; + union { gid_t gval; long lval; } val; + + val.lval = -1; + for (i = 0; i < NGID; i++) + gidset[i] = val.gval; + n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, + gidset); + /* Exit non-zero if getgroups seems to require an array of ints. This + happens when gid_t is short but getgroups modifies an array of ints. */ + exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0); +} + +EOF +if { (eval echo configure:1313: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_type_getgroups=gid_t +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_type_getgroups=int +fi +rm -fr conftest* +fi + +if test $ac_cv_type_getgroups = cross; then + cat > conftest.$ac_ext <<EOF +#line 1327 "configure" +#include "confdefs.h" +#include <unistd.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "getgroups.*int.*gid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_getgroups=gid_t +else + rm -rf conftest* + ac_cv_type_getgroups=int +fi +rm -f conftest* + +fi +fi + +echo "$ac_t""$ac_cv_type_getgroups" 1>&6 +cat >> confdefs.h <<EOF +#define GETGROUPS_T $ac_cv_type_getgroups +EOF + + +echo $ac_n "checking for pid_t""... $ac_c" 1>&6 +echo "configure:1351: checking for pid_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1356 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_pid_t=yes +else + rm -rf conftest* + ac_cv_type_pid_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_pid_t" 1>&6 +if test $ac_cv_type_pid_t = no; then + cat >> confdefs.h <<\EOF +#define pid_t int +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:1384: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1389 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#include <stddef.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 +echo "configure:1417: checking for uid_t in sys/types.h" >&5 +if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1422 "configure" +#include "confdefs.h" +#include <sys/types.h> +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "uid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_uid_t=yes +else + rm -rf conftest* + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_type_uid_t" 1>&6 +if test $ac_cv_type_uid_t = no; then + cat >> confdefs.h <<\EOF +#define uid_t int +EOF + + cat >> confdefs.h <<\EOF +#define gid_t int +EOF + +fi + + +for ac_func in getgroups setpgrp setrlimit +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1454: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1459 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1482: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + + +echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 +echo "configure:1508: checking whether setpgrp takes no argument" >&5 +if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <<EOF +#line 1516 "configure" +#include "confdefs.h" + +/* + * If this system has a BSD-style setpgrp, which takes arguments, exit + * successfully. + */ +main() +{ + if (setpgrp(1,1) == -1) + exit(0); + else + exit(1); +} + +EOF +if { (eval echo configure:1532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_func_setpgrp_void=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_setpgrp_void=yes +fi +rm -fr conftest* +fi + + +fi + +echo "$ac_t""$ac_cv_func_setpgrp_void" 1>&6 +if test $ac_cv_func_setpgrp_void = yes; then + cat >> confdefs.h <<\EOF +#define SETPGRP_VOID 1 +EOF + +fi + + +echo $ac_n "checking if _KERNEL is required for RLIMIT defines""... $ac_c" 1>&6 +echo "configure:1557: checking if _KERNEL is required for RLIMIT defines" >&5 +if eval "test \"`echo '$''{'rc_cv_kernel_rlimit'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1562 "configure" +#include "confdefs.h" + +#include <sys/types.h> +#include <sys/resource.h> + +int main() { + +int f; +f = RLIMIT_DATA; + +; return 0; } +EOF +if { (eval echo configure:1575: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + rc_cv_kernel_rlimit=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + cat > conftest.$ac_ext <<EOF +#line 1583 "configure" +#include "confdefs.h" + +#include <sys/types.h> +#define _KERNEL +#include <sys/resource.h> +#undef _KERNEL + +int main() { + +int f; +f = RLIMIT_DATA; + +; return 0; } +EOF +if { (eval echo configure:1598: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + rc_cv_kernel_rlimit=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + rc_cv_kernel_rlimit=no +fi +rm -f conftest* +fi +rm -f conftest* +fi + +echo "$ac_t""$rc_cv_kernel_rlimit" 1>&6 +case "x$rc_cv_kernel_rlimit" in +xyes) + cat >> confdefs.h <<\EOF +#define RLIMIT_NEEDS_KERNEL 1 +EOF + + ;; +esac + +echo $ac_n "checking for rlim_t""... $ac_c" 1>&6 +echo "configure:1623: checking for rlim_t" >&5 +if eval "test \"`echo '$''{'rc_cv_have_rlim_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1628 "configure" +#include "confdefs.h" + +#include <sys/types.h> +#if RLIMIT_NEEDS_KERNEL +#define _KERNEL +#endif +#include <sys/resource.h> + +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "rlim_t" >/dev/null 2>&1; then + rm -rf conftest* + rc_cv_have_rlim_t=yes +else + rm -rf conftest* + rc_cv_have_rlim_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$rc_cv_have_rlim_t" 1>&6 + +case "x$rc_cv_have_rlim_t" in +xyes) + cat >> confdefs.h <<\EOF +#define HAVE_RLIM_T 1 +EOF + + ;; +xno) + echo $ac_n "checking for native quad_t""... $ac_c" 1>&6 +echo "configure:1661: checking for native quad_t" >&5 +if eval "test \"`echo '$''{'rc_cv_have_quad_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <<EOF +#line 1669 "configure" +#include "confdefs.h" + +#include <sys/types.h> +main() { + quad_t q; + q = 0; + exit((int) q); +} + +EOF +if { (eval echo configure:1680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + rc_cv_have_quad_t=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + rc_cv_have_quad_t=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$rc_cv_have_quad_t" 1>&6 + + case "x$rc_cv_have_quad_t" in + xyes) + cat >> confdefs.h <<\EOF +#define HAVE_QUAD_T 1 +EOF + + + echo $ac_n "checking if rlimit values are quad_t""... $ac_c" 1>&6 +echo "configure:1704: checking if rlimit values are quad_t" >&5 +if eval "test \"`echo '$''{'rc_cv_rlim_t_is_quad_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + $ac_cv_type_quad_t +else + cat > conftest.$ac_ext <<EOF +#line 1712 "configure" +#include "confdefs.h" + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/types.h> +#if RLIMIT_NEEDS_KERNEL +#define _KERNEL +#endif +#include <sys/resource.h> +#if RLIMIT_NEEDS_KERNEL +#undef _KERNEL +#endif +main(){ + struct rlimit rl; + exit(sizeof rl.rlim_cur != sizeof(quad_t)); +} + +EOF +if { (eval echo configure:1731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + rc_cv_rlim_t_is_quad_t=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + rc_cv_rlim_t_is_quad_t=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$rc_cv_rlim_t_is_quad_t" 1>&6 + + case "x$rc_cv_rlim_t_is_quad_t" in + xyes) + cat >> confdefs.h <<\EOF +#define RLIM_T_IS_QUAD_T 1 +EOF + + ;; + esac + ;; + esac + ;; +esac + +echo $ac_n "checking for restartable system calls""... $ac_c" 1>&6 +echo "configure:1761: checking for restartable system calls" >&5 +if eval "test \"`echo '$''{'ac_cv_sys_restartable_syscalls'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext <<EOF +#line 1769 "configure" +#include "confdefs.h" +/* Exit 0 (true) if wait returns something other than -1, + i.e. the pid of the child, which means that wait was restarted + after getting the signal. */ +#include <sys/types.h> +#include <signal.h> +ucatch (isig) { } +main () { + int i = fork (), status; + if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } + signal (SIGINT, ucatch); + status = wait(&i); + if (status == -1) wait(&i); + exit (status == -1); +} + +EOF +if { (eval echo configure:1787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_sys_restartable_syscalls=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sys_restartable_syscalls=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_sys_restartable_syscalls" 1>&6 +if test $ac_cv_sys_restartable_syscalls = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_RESTARTABLE_SYSCALLS 1 +EOF + +fi + + +# Pull the hash mark out of the macro call to avoid m4 problems. +ac_msg="whether #! works in shell scripts" +echo $ac_n "checking $ac_msg""... $ac_c" 1>&6 +echo "configure:1813: checking $ac_msg" >&5 +if eval "test \"`echo '$''{'ac_cv_sys_interpreter'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo '#! /bin/cat +exit 69 +' > conftest +chmod u+x conftest +(SHELL=/bin/sh; export SHELL; ./conftest >/dev/null) +if test $? -ne 69; then + ac_cv_sys_interpreter=yes +else + ac_cv_sys_interpreter=no +fi +rm -f conftest +fi + +echo "$ac_t""$ac_cv_sys_interpreter" 1>&6 + +case "x$ac_cv_sys_interpreter" in +xyes) + cat >> confdefs.h <<\EOF +#define HASH_BANG 1 +EOF + + EXECVE='' + ;; +xno) + EXECVE=execve.o +esac + + +echo $ac_n "checking for /dev/fd""... $ac_c" 1>&6 +echo "configure:1846: checking for /dev/fd" >&5 +if eval "test \"`echo '$''{'rc_cv_sys_dev_fd'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -d /dev/fd && test -r /dev/fd/0; then + rc_cv_sys_dev_fd=yes + elif test -d /proc/self/fd && test -r /proc/self/fd/0; then + rc_cv_sys_dev_fd=odd + else + rc_cv_sys_dev_fd=no + fi +fi + +echo "$ac_t""$rc_cv_sys_dev_fd" 1>&6 + +case "x$rc_cv_sys_dev_fd" in +xyes) + cat >> confdefs.h <<\EOF +#define HAVE_DEV_FD 1 +EOF + + ;; +xodd) + cat >> confdefs.h <<\EOF +#define HAVE_PROC_SELF_FD 1 +EOF + + ;; +xno) + echo $ac_n "checking for named pipes""... $ac_c" 1>&6 +echo "configure:1876: checking for named pipes" >&5 +if eval "test \"`echo '$''{'rc_cv_sys_fifo'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat >> confdefs.h <<EOF +#define TMPNAM "/tmp/rc$$.0" +EOF + + if test "$cross_compiling" = yes; then + rc_cv_sys_fifo=no +else + cat > conftest.$ac_ext <<EOF +#line 1888 "configure" +#include "confdefs.h" + +#include <sys/types.h> +#include <sys/stat.h> + +main() { + exit(mknod(TMPNAM, S_IFIFO | 0666, 0) != 0); +} + +EOF +if { (eval echo configure:1899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + rc_cv_sys_fifo=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + rc_cv_sys_fifo=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$rc_cv_sys_fifo" 1>&6 + case "x$rc_cv_sys_fifo" in + xyes) + cat >> confdefs.h <<\EOF +#define HAVE_FIFO 1 +EOF + + ;; + esac +esac + +# Check whether --enable-builtin-echo or --disable-builtin-echo was given. +if test "${enable_builtin_echo+set}" = set; then + enableval="$enable_builtin_echo" + test "x$enableval" != "xno" && cat >> confdefs.h <<\EOF +#define RC_ECHO 1 +EOF + +else + cat >> confdefs.h <<\EOF +#define RC_ECHO 1 +EOF + +fi + + +# Check whether --enable-job or --disable-job was given. +if test "${enable_job+set}" = set; then + enableval="$enable_job" + test "x$enableval" != "xno" && cat >> confdefs.h <<\EOF +#define RC_JOB 1 +EOF + +else + cat >> confdefs.h <<\EOF +#define RC_JOB 1 +EOF + +fi + + +# Check whether --enable-protect-env or --disable-protect-env was given. +if test "${enable_protect_env+set}" = set; then + enableval="$enable_protect_env" + test "x$enableval" != "xno" && cat >> confdefs.h <<\EOF +#define PROTECT_ENV 1 +EOF + +else + cat >> confdefs.h <<\EOF +#define PROTECT_ENV 1 +EOF + +fi + + +# Check whether --enable-def-interp or --disable-def-interp was given. +if test "${enable_def_interp+set}" = set; then + enableval="$enable_def_interp" + + case "x$enableval" in + xno) + ;; + xyes) + cat >> confdefs.h <<\EOF +#define DEFAULTINTERP "/bin/sh" +EOF + + ;; + *) + cat >> confdefs.h <<EOF +#define DEFAULTINTERP "$enableval" +EOF + + esac + +else + cat >> confdefs.h <<\EOF +#define DEFAULTINTERP "/bin/sh" +EOF + +fi + + +# Check whether --enable-def-path or --disable-def-path was given. +if test "${enable_def_path+set}" = set; then + enableval="$enable_def_path" + + case "x$enableval" in + xno|xyes) + ;; + *) + cat >> confdefs.h <<EOF +#define DEFAULTPATH $enableval +EOF + + esac + +else + enable_def_path=yes +fi + + +case "x$enable_def_path" in +xyes) + echo $ac_n "checking extant directories for default path""... $ac_c" 1>&6 +echo "configure:2019: checking extant directories for default path" >&5 +if eval "test \"`echo '$''{'rc_cv_def_path'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + rc_cv_def_path='' + for i in /usr/local/bin /usr/bin /usr/ucb /bin .; do + if test -d $i; then + case "x$rc_cv_def_path" in + x) + rc_cv_def_path=\"$i\" + ;; + *) + rc_cv_def_path=$rc_cv_def_path,\"$i\" + ;; + esac + fi + done + cat >> confdefs.h <<EOF +#define DEFAULTPATH $rc_cv_def_path +EOF + + +fi + +echo "$ac_t""$rc_cv_def_path" 1>&6 + ;; +esac + +# Check whether --enable-history or --disable-history was given. +if test "${enable_history+set}" = set; then + enableval="$enable_history" + test "x$enableval" != "xno" && rc_history=yes +else + rc_history=no +fi + +case "x$rc_history" in +xyes) + HISTORY=history/history + ;; +esac + + +# Check whether --with-addon or --without-addon was given. +if test "${with_addon+set}" = set; then + withval="$with_addon" + + case "x$withval" in + xyes) + ADDON=addon.o + ;; + xno) + ADDON='' + ;; + *) + ADDON=$withval + ;; + esac + +fi + + + +# Check whether --with-editline or --without-editline was given. +if test "${with_editline+set}" = set; then + withval="$with_editline" + echo $ac_n "checking for readline in -ledit""... $ac_c" 1>&6 +echo "configure:2087: checking for readline in -ledit" >&5 +ac_lib_var=`echo edit'_'readline | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ledit $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2095 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char readline(); + +int main() { +readline() +; return 0; } +EOF +if { (eval echo configure:2106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define READLINE 1 +EOF + LIBS="$LIBS -ledit" +else + echo "$ac_t""no" 1>&6 +echo "configure: warning: editline library not found" 1>&2 +fi + +fi + + +# Check whether --with-readline or --without-readline was given. +if test "${with_readline+set}" = set; then + withval="$with_readline" + echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 +echo "configure:2137: checking for readline in -lreadline" >&5 +ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lreadline $LIBS" +cat > conftest.$ac_ext <<EOF +#line 2145 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char readline(); + +int main() { +readline() +; return 0; } +EOF +if { (eval echo configure:2156: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define READLINE 1 +EOF + LIBS="$LIBS -lreadline -ltermcap" +else + echo "$ac_t""no" 1>&6 +echo "configure: warning: readline library not found" 1>&2 +fi + +fi + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.12" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@YACC@%$YACC%g +s%@LN@%$LN%g +s%@CPP@%$CPP%g +s%@SIGNAL_H@%$SIGNAL_H%g +s%@EXECVE@%$EXECVE%g +s%@HISTORY@%$HISTORY%g +s%@ADDON@%$ADDON%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <<EOF + CONFIG_HEADERS="config.h" +EOF +cat >> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/configure.in b/configure.in @@ -0,0 +1,287 @@ +AC_INIT(rc.h) + +AC_CONFIG_HEADER(config.h) + +AC_PROG_CC +case "x$GCC" in +xyes) + CFLAGS="-Wall $CFLAGS" + ;; +esac + +AC_PROG_INSTALL +AC_PROG_YACC +AC_CHECK_PROGS(LN, ln cp) + +AC_CHECK_HEADERS(sys/resource.h sys/time.h sys/types.h unistd.h) +AC_HEADER_DIRENT +AC_HEADER_STDC + +dnl Linux puts real signal names in /usr/include/asm/signal.h. +AC_CACHE_CHECK(for signal names in <sys/signal.h>, rc_cv_sys_signal_h, + if grep SIGINT /usr/include/sys/signal.h >/dev/null 2>&1; then + rc_cv_sys_signal_h=yes + else + rc_cv_sys_signal_h=no + fi) + +case "x$rc_cv_sys_signal_h" in +xyes) + SIGNAL_H=/usr/include/sys/signal.h + ;; +xno) + AC_CACHE_CHECK(for signal names in <asm/signal.h>, rc_cv_asm_signal_h, + if grep SIGINT /usr/include/asm/signal.h >/dev/null 2>&1; then + rc_cv_asm_signal_h=yes + else + rc_cv_asm_signal_h=no + fi) + + case "x$rc_cv_asm_signal_h" in + xyes) + SIGNAL_H=/usr/include/asm/signal.h + ;; + xno) + AC_MSG_ERROR(Can't find signal names in <sys/signal.h> or <asm/signal.h>) + ;; + esac + ;; +esac +AC_SUBST(SIGNAL_H) + +AC_TYPE_GETGROUPS +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_UID_T + +AC_CHECK_FUNCS(getgroups setpgrp setrlimit) + +AC_FUNC_SETPGRP + +dnl HPUX needs _KERNEL defined to pick up RLIMIT_foo defines. (Why?) +AC_CACHE_CHECK(if _KERNEL is required for RLIMIT defines, rc_cv_kernel_rlimit, + AC_TRY_COMPILE([ +#include <sys/types.h> +#include <sys/resource.h> + ], [ +int f; +f = RLIMIT_DATA; + ], rc_cv_kernel_rlimit=no, [ AC_TRY_COMPILE([ +#include <sys/types.h> +#define _KERNEL +#include <sys/resource.h> +#undef _KERNEL + ], [ +int f; +f = RLIMIT_DATA; + ], rc_cv_kernel_rlimit=yes, rc_cv_kernel_rlimit=no)])) +case "x$rc_cv_kernel_rlimit" in +xyes) + AC_DEFINE(RLIMIT_NEEDS_KERNEL) + ;; +esac + +dnl Look for rlim_t in sys/types.h and sys/resource.h +AC_CACHE_CHECK(for rlim_t, rc_cv_have_rlim_t, + AC_EGREP_CPP(rlim_t, [ +#include <sys/types.h> +#if RLIMIT_NEEDS_KERNEL +#define _KERNEL +#endif +#include <sys/resource.h> + ], rc_cv_have_rlim_t=yes, rc_cv_have_rlim_t=no)) + +case "x$rc_cv_have_rlim_t" in +xyes) + AC_DEFINE(HAVE_RLIM_T) + ;; +xno) + AC_CACHE_CHECK(for native quad_t, rc_cv_have_quad_t, + AC_TRY_RUN([ +#include <sys/types.h> +main() { + quad_t q; + q = 0; + exit((int) q); +} + ], rc_cv_have_quad_t=yes, rc_cv_have_quad_t=no)) + + case "x$rc_cv_have_quad_t" in + xyes) + AC_DEFINE(HAVE_QUAD_T) + + AC_CACHE_CHECK(if rlimit values are quad_t, rc_cv_rlim_t_is_quad_t, + AC_TRY_RUN([ +#include <sys/types.h> +#include <sys/time.h> +#include <sys/types.h> +#if RLIMIT_NEEDS_KERNEL +#define _KERNEL +#endif +#include <sys/resource.h> +#if RLIMIT_NEEDS_KERNEL +#undef _KERNEL +#endif +main(){ + struct rlimit rl; + exit(sizeof rl.rlim_cur != sizeof(quad_t)); +} + ], rc_cv_rlim_t_is_quad_t=yes, rc_cv_rlim_t_is_quad_t=no, $ac_cv_type_quad_t)) + + case "x$rc_cv_rlim_t_is_quad_t" in + xyes) + AC_DEFINE(RLIM_T_IS_QUAD_T) + ;; + esac + ;; + esac + ;; +esac + +AC_SYS_RESTARTABLE_SYSCALLS + +dnl Does the kernel handle `#! /interpreter'? +AC_SYS_INTERPRETER +case "x$ac_cv_sys_interpreter" in +xyes) + AC_DEFINE(HASH_BANG) + EXECVE='' + ;; +xno) + EXECVE=execve.o +esac +AC_SUBST(EXECVE) + +AC_CACHE_CHECK(for /dev/fd, rc_cv_sys_dev_fd, + if test -d /dev/fd && test -r /dev/fd/0; then + rc_cv_sys_dev_fd=yes + elif test -d /proc/self/fd && test -r /proc/self/fd/0; then + rc_cv_sys_dev_fd=odd + else + rc_cv_sys_dev_fd=no + fi) + +case "x$rc_cv_sys_dev_fd" in +xyes) + AC_DEFINE(HAVE_DEV_FD) + ;; +xodd) + AC_DEFINE(HAVE_PROC_SELF_FD) + ;; +xno) + AC_CACHE_CHECK(for named pipes, rc_cv_sys_fifo, + AC_DEFINE_UNQUOTED(TMPNAM, "/tmp/rc$$.0") + AC_TRY_RUN([ +#include <sys/types.h> +#include <sys/stat.h> + +main() { + exit(mknod(TMPNAM, S_IFIFO | 0666, 0) != 0); +} + ], rc_cv_sys_fifo=yes, rc_cv_sys_fifo=no, rc_cv_sys_fifo=no)) + case "x$rc_cv_sys_fifo" in + xyes) + AC_DEFINE(HAVE_FIFO) + ;; + esac +esac + +AC_ARG_ENABLE(builtin-echo, [ --disable-builtin-echo Don't include \`echo' as a builtin], + test "x$enableval" != "xno" && AC_DEFINE(RC_ECHO), + AC_DEFINE(RC_ECHO)) + +AC_ARG_ENABLE(job, [ --disable-job Don't do job-control-style backgrounding], + test "x$enableval" != "xno" && AC_DEFINE(RC_JOB), + AC_DEFINE(RC_JOB)) + +AC_ARG_ENABLE(protect-env, [ --disable-protect-env Don't protect environment names], + test "x$enableval" != "xno" && AC_DEFINE(PROTECT_ENV), + AC_DEFINE(PROTECT_ENV)) + +AC_ARG_ENABLE(def-interp, +[ --enable-def-interp=/bin/foo + Use /bin/foo as default interpreter [/bin/sh]], +[ + case "x$enableval" in + xno) + ;; + xyes) + AC_DEFINE(DEFAULTINTERP, "/bin/sh") + ;; + *) + AC_DEFINE_UNQUOTED(DEFAULTINTERP, "$enableval") + esac +], + AC_DEFINE(DEFAULTINTERP, "/bin/sh")) + +AC_ARG_ENABLE(def-path, +[ --enable-def-path=\"/usr/local/bin/\",\"/usr/bin\" + Default path [All of these that exist + (/usr/local/bin /usr/bin /usr/ucb /bin .)]], +[ + case "x$enableval" in + xno|xyes) + ;; + *) + AC_DEFINE_UNQUOTED(DEFAULTPATH, $enableval) + esac +], + enable_def_path=yes) + +case "x$enable_def_path" in +xyes) + AC_CACHE_CHECK(extant directories for default path, rc_cv_def_path,[ + rc_cv_def_path='' + for i in /usr/local/bin /usr/bin /usr/ucb /bin .; do + if test -d $i; then + case "x$rc_cv_def_path" in + x) + rc_cv_def_path=\"$i\" + ;; + *) + rc_cv_def_path=$rc_cv_def_path,\"$i\" + ;; + esac + fi + done + AC_DEFINE_UNQUOTED(DEFAULTPATH, $rc_cv_def_path) + ]) + ;; +esac + +AC_ARG_ENABLE(history, [ --enable-history Build history subprograms], + test "x$enableval" != "xno" && rc_history=yes, + rc_history=no) +case "x$rc_history" in +xyes) + HISTORY=history/history + ;; +esac +AC_SUBST(HISTORY) + +AC_ARG_WITH(addon, [ --with-addon Extra builtins, from addon.c ],[ + case "x$withval" in + xyes) + ADDON=addon.o + ;; + xno) + ADDON='' + ;; + *) + ADDON=$withval + ;; + esac + ]) +AC_SUBST(ADDON) + +AC_ARG_WITH(editline, [ --with-editline Simmule Turner's line editing], + AC_CHECK_LIB(edit, readline, + AC_DEFINE(READLINE) LIBS="$LIBS -ledit", + AC_MSG_WARN(editline library not found))) + +AC_ARG_WITH(readline, [ --with-readline Bloated GNU line editing], + AC_CHECK_LIB(readline, readline, + AC_DEFINE(READLINE) LIBS="$LIBS -lreadline -ltermcap", + AC_MSG_WARN(readline library not found))) + +AC_OUTPUT(Makefile) diff --git a/exec.c b/exec.c @@ -12,7 +12,8 @@ extern void exec(List *s, bool parent) { char **av, **ev = NULL; - int pid, stat; + int stat; + pid_t pid; builtin_t *b; char *path = NULL; bool didfork, returning, saw_exec, saw_builtin; @@ -91,16 +92,17 @@ extern void exec(List *s, bool parent) { return; rc_exit(getstatus()); } -#ifdef NOEXECVE - my_execve(path, (const char **) av, (const char **) ev); /* bogus, huh? */ +#if HASH_BANG + execve(path, (char * const *) av, (char * const *) ev); #else - execve(path, (const char **) av, (const char **) ev); + my_execve(path, (char * const *) av, (char * const *) ev); /* bogus, huh? */ #endif + #ifdef DEFAULTINTERP if (errno == ENOEXEC) { *av = path; *--av = DEFAULTINTERP; - execve(*av, (const char **) av, (const char **) ev); + execve(*av, (char * const *) av, (char * const *) ev); } #endif uerror(*av); diff --git a/fn.c b/fn.c @@ -26,7 +26,7 @@ extern void inithandler() { null.type = nBody; null.u[0].p = null.u[1].p = NULL; for (i = 1; i < NUMOFSIGNALS; i++) -#ifdef NOSIGCLD +#ifndef HAVE_RESTARTABLE_SYSCALLS if (i != SIGCLD) #endif if (sighandlers[i] == SIG_IGN) @@ -148,7 +148,7 @@ extern void fnassign(char *name, Node *def) { new->def = newdef; new->extdef = NULL; if (strncmp(name, "sig", conststrlen("sig")) == 0) { /* slight optimization */ -#ifdef NOSIGCLD /* System V machines treat SIGCLD very specially */ +#ifndef HAVE_RESTARTABLE_SYSCALLS /* System V machines treat SIGCLD very specially */ if (streq(name, "sigcld")) rc_error("can't trap SIGCLD"); #endif diff --git a/footobar.c b/footobar.c @@ -7,7 +7,7 @@ /* protect an exported name from brain-dead shells */ -#ifdef PROTECT_ENV +#if PROTECT_ENV static bool Fconv(Format *f, int ignore) { unsigned const char *s = va_arg(f->args, unsigned const char *); int c; @@ -192,7 +192,7 @@ extern char *get_name(char *s) { case '=': *r++ = '\0'; return result; -#ifdef PROTECT_ENV +#if PROTECT_ENV case '_': if (*s == '_') { static const char hexchar[] = "0123456789abcdef"; @@ -329,7 +329,7 @@ void initprint(void) { fmtinstall('S', Sconv); fmtinstall('T', Tconv); fmtinstall('D', Dconv); -#ifdef PROTECT_ENV +#if PROTECT_ENV fmtinstall('F', Fconv); #else fmtinstall('F', fmtinstall('s', NULL)); diff --git a/glob.c b/glob.c @@ -3,16 +3,28 @@ #include <sys/types.h> #include <sys/stat.h> #include "rc.h" -#ifdef NODIRENT -#include <sys/dir.h> -#define dirent direct /* need to get the struct declaraction right */ + +/* Lifted from autoconf documentation.*/ +#if HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) #else -#include <dirent.h> +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif #endif static List *dmatch(char *, char *, char *); static List *doglob(char *, char *); -static List *lglob(List *, char *, char *, SIZE_T); +static List *lglob(List *, char *, char *, size_t); static List *sort(List *); /* @@ -90,10 +102,6 @@ static List *dmatch(char *d, char *p, char *m) { static DIR *dirp; static struct dirent *dp; static struct stat s; - /* prototypes for XXXdir functions. comment out if necessary */ - extern DIR *opendir(const char *); - extern struct dirent *readdir(DIR *); - /*extern int closedir(DIR *);*/ int i; /* @@ -151,11 +159,11 @@ static List *dmatch(char *d, char *p, char *m) { matched name. e.g., for matching ////tmp/////foo* */ -static List *lglob(List *s, char *p, char *m, SIZE_T slashcount) { +static List *lglob(List *s, char *p, char *m, size_t slashcount) { List *q, *r, *top, foo; static struct { List l; - SIZE_T size; + size_t size; } slash; if (slashcount+1 > slash.size) { slash.size = 2*(slashcount+1); @@ -191,9 +199,9 @@ static List *lglob(List *s, char *p, char *m, SIZE_T slashcount) { static List *doglob(char *w, char *m) { static char *dir = NULL, *pattern = NULL, *metadir = NULL, *metapattern = NULL; - static SIZE_T dsize = 0; + static size_t dsize = 0; char *d, *p, *md, *mp; - SIZE_T psize; + size_t psize; char *s = w; List firstdir; List *matched; @@ -238,7 +246,7 @@ static List *doglob(char *w, char *m) { matched = dmatch(".", dir, metadir); } do { - SIZE_T slashcount; + size_t slashcount; sigchk(); for (slashcount = 0; *s == '/'; s++, m++) slashcount++; /* skip slashes */ @@ -258,7 +266,7 @@ end: if (matched == NULL) { } static List *sort(List *s) { - SIZE_T nel = listnel(s); + size_t nel = listnel(s); if (nel > 1) { char **a; List *t; diff --git a/glom.c b/glom.c @@ -5,9 +5,6 @@ #include <signal.h> #include <errno.h> #include "rc.h" -#if !defined(S_IFIFO) && !defined(DEVFD) -#define NOCMDARG -#endif static List *backq(Node *, Node *); static List *bqinput(List *, int); @@ -58,9 +55,9 @@ extern List *concat(List *s1, List *s2) { if ((n1 = listnel(s1)) != (n2 = listnel(s2)) && n1 != 1 && n2 != 1) rc_error("bad concatenation"); for (r = top = nnew(List); 1; r = r->n = nnew(List)) { - SIZE_T x = strlen(s1->w); - SIZE_T y = strlen(s2->w); - SIZE_T z = x + y + 1; + size_t x = strlen(s1->w); + size_t y = strlen(s2->w); + size_t z = x + y + 1; r->w = nalloc(z); strcpy(r->w, s1->w); strcat(r->w, s2->w); @@ -115,7 +112,7 @@ extern List *varsub(List *var, List *subs) { extern List *flatten(List *s) { List *r; - SIZE_T step; + size_t step; char *f; if (s == NULL || s->n == NULL) return s; @@ -175,12 +172,12 @@ extern void assign(List *s1, List *s2, bool stack) { who could not stand the incompetence of my own backquote implementation. */ -#define BUFSIZE ((SIZE_T) 1000) +#define BUFSIZE ((size_t) 1000) static List *bqinput(List *ifs, int fd) { char *end, *bufend, *s; List *r, *top, *prev; - SIZE_T remain, bufsize; + size_t remain, bufsize; char isifs[256]; int n, state; /* a simple FSA is used to read in data */ @@ -197,7 +194,7 @@ static List *bqinput(List *ifs, int fd) { while (1) { if (remain == 0) { /* is the string bigger than the buffer? */ - SIZE_T m = end - r->w; + size_t m = end - r->w; char *buf; while (bufsize < m + BUFSIZE) bufsize *= 2; @@ -249,7 +246,8 @@ static List *bqinput(List *ifs, int fd) { } static List *backq(Node *ifs, Node *n) { - int p[2], pid, sp; + int p[2], sp; + pid_t pid; List *bq; if (n == NULL) return NULL; @@ -288,13 +286,44 @@ extern void qredir(Node *n) { next->n = NULL; } -#ifdef NOCMDARG +#if HAVE_DEV_FD || HAVE_PROC_SELF_FD static List *mkcmdarg(Node *n) { - rc_error("named pipes are not supported"); - return NULL; -} + char *name; + List *ret = nnew(List); + Estack *e = nnew(Estack); + Edata efd; + int p[2]; + if (pipe(p) < 0) { + uerror("pipe"); + return NULL; + } + if (rc_fork() == 0) { + setsigdefaults(FALSE); + if (mvfd(p[n->u[0].i == rFrom], n->u[0].i == rFrom) < 0) /* stupid hack */ + exit(1); + close(p[n->u[0].i != rFrom]); + redirq = NULL; + walk(n->u[2].p, FALSE); + exit(getstatus()); + } + +#if HAVE_DEV_FD + name = nprint("/dev/fd/%d", p[n->u[0].i != rFrom]); #else -#ifndef DEVFD + name = nprint("/proc/self/fd/%d", p[n->u[0].i != rFrom]); +#endif + + efd.fd = p[n->u[0].i != rFrom]; + except(eFd, efd, e); + close(p[n->u[0].i == rFrom]); + ret->w = name; + ret->m = NULL; + ret->n = NULL; + return ret; +} + +#elif HAVE_FIFO + static List *mkcmdarg(Node *n) { int fd; char *name; @@ -302,7 +331,7 @@ static List *mkcmdarg(Node *n) { Estack *e = enew(Estack); List *ret = nnew(List); static int fifonumber = 0; - name = nprint("%s/rc%d.%d", TMPDIR, getpid(), fifonumber++); + name = nprint("/tmp/rc%d.%d", getpid(), fifonumber++); if (mknod(name, S_IFIFO | 0666, 0) < 0) { uerror("mknod"); return NULL; @@ -327,37 +356,15 @@ static List *mkcmdarg(Node *n) { ret->n = NULL; return ret; } + #else + static List *mkcmdarg(Node *n) { - char *name; - List *ret = nnew(List); - Estack *e = nnew(Estack); - Edata efd; - int p[2]; - if (pipe(p) < 0) { - uerror("pipe"); - return NULL; - } - if (rc_fork() == 0) { - setsigdefaults(FALSE); - if (mvfd(p[n->u[0].i == rFrom], n->u[0].i == rFrom) < 0) /* stupid hack */ - exit(1); - close(p[n->u[0].i != rFrom]); - redirq = NULL; - walk(n->u[2].p, FALSE); - exit(getstatus()); - } - name = nprint("/dev/fd/%d", p[n->u[0].i != rFrom]); - efd.fd = p[n->u[0].i != rFrom]; - except(eFd, efd, e); - close(p[n->u[0].i == rFrom]); - ret->w = name; - ret->m = NULL; - ret->n = NULL; - return ret; + rc_error("named pipes are not supported"); + return NULL; } -#endif /* DEVFD */ -#endif /* !NOCMDARG */ + +#endif extern List *glom(Node *n) { List *v, *head, *tail; diff --git a/group.h b/group.h @@ -0,0 +1,9 @@ +/* Solaris / `gcc -ansi' only defines NGROUPS_MAX in <limits.h> if +_POSIX_C_SOURCE is defined. */ +#define _POSIX_C_SOURCE 1 +#include <limits.h> +#undef _POSIX_C_SOURCE + +#if defined(NGROUPS) && !defined(NGROUPS_MAX) +#define NGROUPS_MAX NGROUPS +#endif diff --git a/hash.c b/hash.c @@ -275,7 +275,7 @@ extern char **makeenv() { env[ep++] = fnlookup_string(fp[i].name); } env[ep] = NULL; - qsort(env, (SIZE_T) ep, sizeof(char *), starstrcmp); + qsort(env, (size_t) ep, sizeof(char *), starstrcmp); return env; } @@ -294,7 +294,7 @@ extern void whatare_all_vars(bool showfn, bool showvar) { /* fake getenv() for readline() follows: */ -#ifdef READLINE +#if READLINE extern char *getenv(const char *name) { List *s; if (name == NULL || vp == NULL || (s = varlookup((char *) name)) == NULL) diff --git a/heredoc.c b/heredoc.c @@ -26,7 +26,7 @@ static char *readheredoc(char *eof) { int c; char *t, *buf, *bufend; unsigned char *s; - SIZE_T bufsize; + size_t bufsize; t = buf = nalloc(bufsize = 512); bufend = &buf[bufsize]; dead = FALSE; @@ -34,7 +34,7 @@ static char *readheredoc(char *eof) { char *nbuf; \ bufsize = bufsize * 2 + extra; \ nbuf = nalloc(bufsize); \ - memcpy(nbuf, buf, (SIZE_T) (t - buf)); \ + memcpy(nbuf, buf, (size_t) (t - buf)); \ t = nbuf + (t - buf); \ buf = nbuf; \ bufend = &buf[bufsize]; \ @@ -48,7 +48,7 @@ static char *readheredoc(char *eof) { return buf; } if (s != (unsigned char *) eof) { - SIZE_T len = s - (unsigned char *) eof; + size_t len = s - (unsigned char *) eof; if (t + len >= bufend) RESIZE(len); memcpy(t, eof, len); @@ -92,7 +92,7 @@ static Node *parseheredoc(char *s) { node = mk(nQword, "$", NULL); c = *s; } else { - SIZE_T len = 0; + size_t len = 0; do len++; while (!dnw[c = *(unsigned char *) s++]); diff --git a/history/Makefile b/history/Makefile @@ -1,6 +0,0 @@ -CC=gcc -g -O - -history: history.c - $(CC) -o history history.c - @echo 'Now install "history" as -, --, -p and --p in your bin directory' - @echo '(for example, by making them links to the same file)' diff --git a/input.c b/input.c @@ -18,9 +18,9 @@ typedef struct Input { bool saved, eofread; } Input; -#define BUFSIZE ((SIZE_T) 256) +#define BUFSIZE ((size_t) 256) -#ifdef READLINE +#if READLINE extern char *readline(char *); extern void add_history(char *); static char *rlinebuf; @@ -37,7 +37,7 @@ static void ugdead(int); static void pushcommon(void); static char *inbuf; -static SIZE_T istacksize, chars_out, chars_in; +static size_t istacksize, chars_out, chars_in; static bool eofread = FALSE, save_lineno = TRUE; static Input *istack, *itop; @@ -87,8 +87,8 @@ static int stringgchar() { /* signal-safe readline wrapper */ -#ifdef READLINE -#ifndef SVSIGS +#if READLINE +#ifndef HAVE_RESTARTABLE_SYSCALLS static char *rc_readline(char *prompt) { char *r; interrupt_happened = FALSE; @@ -108,7 +108,7 @@ static char *rc_readline(char *prompt) { } #else #define rc_readline readline -#endif /* SVSIGS */ +#endif /* HAVE_RESTARTABLE_SYSCALLS */ #endif /* READLINE */ /* @@ -119,9 +119,9 @@ static char *rc_readline(char *prompt) { static int fdgchar() { if (chars_out >= chars_in + 2) { /* has the buffer been exhausted? if so, replenish it */ while (1) { -#ifdef READLINE +#if READLINE if (interactive && istack->fd == 0) { - rlinebuf = readline(prompt); + rlinebuf = rc_readline(prompt); if (rlinebuf == NULL) { chars_in = 0; } else { @@ -143,7 +143,7 @@ static int fdgchar() { uerror("read"); rc_exit(1); } - chars_in = (SIZE_T) r; + chars_in = (size_t) r; } break; } @@ -169,7 +169,7 @@ extern void initinput() { /* push an input source onto the stack. set up a new input buffer, and set gchar() */ static void pushcommon() { - SIZE_T idiff; + size_t idiff; istack->index = chars_out; istack->read = chars_in; istack->ibuf = inbuf; @@ -253,6 +253,7 @@ extern Node *doit(bool execit) { Jbwrap j; Estack e1, e2; Edata jerror; + if (dashen) execit = FALSE; setjmp(j.j); @@ -278,7 +279,7 @@ extern Node *doit(bool execit) { funcall(arglist); } if ((s = varlookup("prompt")) != NULL) { -#ifdef READLINE +#if READLINE prompt = s->w; #else fprint(2, "%s", s->w); @@ -322,7 +323,7 @@ extern Node *parseline(char *extdef) { static void history() { List *hist; - SIZE_T a; + size_t a; if (!interactive || (hist = varlookup("history")) == NULL) return; diff --git a/install-sh b/install-sh @@ -0,0 +1,250 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/jbwrap.h b/jbwrap.h @@ -1,3 +1,5 @@ +#include <setjmp.h> + /* certain braindamaged environments don't define jmp_buf as an array, so... */ struct Jbwrap { @@ -5,6 +7,3 @@ struct Jbwrap { }; extern Jbwrap slowbuf; /* for getting out of interrupts while performing slow i/o on BSD */ - -extern int setjmp(jmp_buf); -extern void longjmp(jmp_buf, int); diff --git a/lex.c b/lex.c @@ -20,7 +20,7 @@ it declared in rc.h) */ -#define BUFSIZE ((SIZE_T) 1000) /* malloc hates power of 2 buffers? */ +#define BUFSIZE ((size_t) 1000) /* malloc hates power of 2 buffers? */ #define BUFMAX (8 * BUFSIZE) /* How big the buffer can get before we re-allocate the space at BUFSIZE again. Premature optimization? Maybe. */ @@ -55,7 +55,7 @@ const char dnw[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -static SIZE_T bufsize = BUFSIZE; +static size_t bufsize = BUFSIZE; static char *realbuf = NULL; static bool newline = FALSE; static bool errset = FALSE; @@ -73,7 +73,7 @@ extern int yylex() { static bool dollar = FALSE; bool saw_meta = FALSE; int c; - SIZE_T i; /* The purpose of all these local assignments is to */ + size_t i; /* The purpose of all these local assignments is to */ const char *meta; /* allow optimizing compilers like gcc to load these */ char *buf = realbuf; /* values into registers. On a sparc this is a */ YYSTYPE *y = &yylval; /* win, in code size *and* execution time */ @@ -338,7 +338,7 @@ extern void inityy() { extern void print_prompt2() { lineno++; -#ifdef READLINE +#if READLINE prompt = prompt2; #else if (interactive) diff --git a/list.c b/list.c @@ -22,7 +22,7 @@ extern void listfree(List *p) { /* Copy list into malloc space (for storing a variable) */ -extern List *listcpy(List *s, void *(*alloc)(SIZE_T)) { +extern List *listcpy(List *s, void *(*alloc)(size_t)) { List *top, *r; for (top = r = NULL; s != NULL; s = s->n) { if (top == NULL) @@ -40,8 +40,8 @@ extern List *listcpy(List *s, void *(*alloc)(SIZE_T)) { /* Length of list */ -extern SIZE_T listlen(List *s) { - SIZE_T size; +extern size_t listlen(List *s) { + size_t size; for (size = 0; s != NULL; s = s->n) size += strlen(s->w) + 1; return size; diff --git a/main.c b/main.c @@ -4,7 +4,7 @@ bool dashdee, dashee, dashvee, dashex, dashell, dasheye, dashen, dashpee, dashess, interactive; -int rc_pid; +pid_t rc_pid; static bool dashoh; diff --git a/mksignal b/mksignal @@ -12,7 +12,8 @@ sed ' s/\/\*[ ]*// s/([@*+!]) // s/[ ]*([a-zA-Z,->& ]*)[ ]*// s/^[ ]*\#[ ]*define/\#define/ - s/[ ]*signal$//' $1 | + s/[ ]*signal$// + s/_SIG/SIG/g' $1 | awk ' BEGIN { # assign to nomesg["SIGNAME"] to suppress a long message diff --git a/nalloc.c b/nalloc.c @@ -2,18 +2,18 @@ #include "rc.h" static struct Block { - SIZE_T used, size; + size_t used, size; char *mem; Block *n; } *fl, *ul; /* alignto() works only with power of 2 blocks and assumes 2's complement arithmetic */ #define alignto(m, n) ((m + n - 1) & ~(n - 1)) -#define BLOCKSIZE ((SIZE_T) 4096) +#define BLOCKSIZE ((size_t) 4096) /* Allocate a block from the free list or malloc one if none in the fl fit */ -static void getblock(SIZE_T n) { +static void getblock(size_t n) { Block *r, *p; for (r = fl, p = NULL; r != NULL; p = r, r = r->n) if (n <= r->size) @@ -41,10 +41,10 @@ static void getblock(SIZE_T n) { address of a global in a register) */ -extern void *nalloc(SIZE_T n) { - SIZE_T base; +extern void *nalloc(size_t n) { + size_t base; Block *ulp; - n = alignto(n, sizeof (ALIGN_T)); + n = alignto(n, sizeof(align_t)); ulp = ul; if (ulp != NULL && n + (base = ulp->used) < ulp->size) { ulp->used = base + n; @@ -65,7 +65,7 @@ extern void *nalloc(SIZE_T n) { #define MAXMEM 500000 extern void nfree() { - SIZE_T count; + size_t count; Block *r; if (ul == NULL) return; @@ -110,8 +110,8 @@ extern void restoreblock(Block *old) { /* generic memory allocation functions */ -extern void *ealloc(SIZE_T n) { - extern void *malloc(SIZE_T); +extern void *ealloc(size_t n) { + extern void *malloc(size_t); void *p = malloc(n); if (p == NULL) { uerror("malloc"); @@ -120,8 +120,8 @@ extern void *ealloc(SIZE_T n) { return p; } -extern void *erealloc(void *p, SIZE_T n) { - extern void *realloc(void *, SIZE_T); +extern void *erealloc(void *p, size_t n) { + extern void *realloc(void *, size_t); if (p == NULL) /* convenience feature */ return ealloc(n); if ((p = realloc(p, n)) == NULL) { diff --git a/open.c b/open.c @@ -3,10 +3,6 @@ #include <fcntl.h> #include "rc.h" -/* prototype for open() follows. comment out if necessary */ - -/*extern int open(const char *, int,...);*/ - /* Opens a file with the necessary flags. Assumes the following declaration for redirtype: diff --git a/print.c b/print.c @@ -3,8 +3,8 @@ #include "rc.h" #include <setjmp.h> -#define PRINT_ALLOCSIZE ((SIZE_T)64) -#define SPRINT_BUFSIZ ((SIZE_T)1024) +#define PRINT_ALLOCSIZE ((size_t)64) +#define SPRINT_BUFSIZ ((size_t)1024) #define MAXCONV 256 @@ -22,6 +22,11 @@ static bool name(Format *format, int c) { \ Flag(uconv, FMT_unsigned) Flag(hconv, FMT_short) Flag(lconv, FMT_long) + +#if HAVE_QUAD_T +Flag(qconv, FMT_quad) +#endif + Flag(altconv, FMT_altform) Flag(leftconv, FMT_leftside) Flag(dotconv, FMT_f2set) @@ -43,7 +48,7 @@ static bool zeroconv(Format *format, int c) { return TRUE; } -static void pad(Format *format, SIZE_T len, int c) { +static void pad(Format *format, size_t len, int c) { while (len-- != 0) fmtputc(format, c); } @@ -53,7 +58,7 @@ static bool sconv(Format *format, int c) { if ((format->flags & FMT_f1set) == 0) fmtcat(format, s); else { - SIZE_T len = strlen(s), width = format->f1 - len; + size_t len = strlen(s), width = format->f1 - len; if (format->flags & FMT_leftside) { fmtappend(format, s, len); pad(format, width, ' '); @@ -80,7 +85,7 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", }; char padchar; - SIZE_T len, pre, zeroes, padding, width; + size_t len, pre, zeroes, padding, width; long n, flags; unsigned long u; char number[64], prefix[20]; @@ -89,6 +94,13 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a return; flags = format->flags; + +#if HAVE_QUAD_T + if (flags & FMT_quad) + n = va_arg(format->args, quad_t); + else +#endif + if (flags & FMT_long) n = va_arg(format->args, long); else if (flags & FMT_short) @@ -109,13 +121,13 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a prefix[pre++] = *altform++; len = utoa(u, number, radix, table[upper]) - number; - if ((flags & FMT_f2set) && (SIZE_T) format->f2 > len) + if ((flags & FMT_f2set) && (size_t) format->f2 > len) zeroes = format->f2 - len; else zeroes = 0; width = pre + zeroes + len; - if ((flags & FMT_f1set) && (SIZE_T) format->f1 > width) { + if ((flags & FMT_f1set) && (size_t) format->f1 > width) { padding = format->f1 - width; } else padding = 0; @@ -196,6 +208,10 @@ static void inittab(void) { fmttab['-'] = leftconv; fmttab['.'] = dotconv; +#if HAVE_QUAD_T + fmttab['q'] = qconv; +#endif + fmttab['0'] = zeroconv; for (i = '1'; i <= '9'; i++) fmttab[i] = digitconv; @@ -218,9 +234,9 @@ extern bool (*fmtinstall(int c, bool (*f)(Format *, int)))(Format *, int) { * functions for inserting strings in the format buffer */ -extern void fmtappend(Format *format, const char *s, SIZE_T len) { +extern void fmtappend(Format *format, const char *s, size_t len) { while (format->buf + len > format->bufend) { - SIZE_T split = format->bufend - format->buf; + size_t split = format->bufend - format->buf; memcpy(format->buf, s, split); format->buf += split; s += split; @@ -282,8 +298,8 @@ extern int fmtprint(Format *format, const char *fmt,...) { return n + format->flushed; } -static void fprint_flush(Format *format, SIZE_T more) { - SIZE_T n = format->buf - format->bufbegin; +static void fprint_flush(Format *format, size_t more) { + size_t n = format->buf - format->bufbegin; char *buf = format->bufbegin; format->flushed += n; @@ -308,20 +324,20 @@ extern int fprint(int fd, const char *fmt,...) { printfmt(&format, fmt); va_end(format.args); - fprint_flush(&format, (SIZE_T) 0); + fprint_flush(&format, 0); return format.flushed; } -static void memprint_grow(Format *format, SIZE_T more) { +static void memprint_grow(Format *format, size_t more) { char *buf; - SIZE_T len = format->bufend - format->bufbegin + 1; + size_t len = format->bufend - format->bufbegin + 1; len = (len >= more) ? len * 2 : ((len + more) + PRINT_ALLOCSIZE) &~ (PRINT_ALLOCSIZE - 1); if (format->u.n) buf = erealloc(format->bufbegin, len); else { - SIZE_T used = format->buf - format->bufbegin; + size_t used = format->buf - format->bufbegin; buf = nalloc(len); memcpy(buf, format->bufbegin, used); } @@ -330,7 +346,7 @@ static void memprint_grow(Format *format, SIZE_T more) { format->bufend = buf + len - 1; } -static char *memprint(Format *format, const char *fmt, char *buf, SIZE_T len) { +static char *memprint(Format *format, const char *fmt, char *buf, size_t len) { format->buf = buf; format->bufbegin = buf; format->bufend = buf + len - 1; @@ -410,7 +426,7 @@ extern int eprint(const char *fmt,...) { return format.flushed; } -static void snprint_grow(Format *format, SIZE_T more) { +static void snprint_grow(Format *format, size_t more) { longjmp(format->u.p, 1); } diff --git a/proto.h b/proto.h @@ -1,82 +1,40 @@ -/* proto.h - This file provides a definition for size_t and align_t that - should work for your system. If it does not, it is up to you to - make it the right thing. The problem is that I cannot rely upon - <sys/params.h> to do the right thing on machines which don't - yet have ansi header files. Note that on many RISC machines, - align_t must be at least 32 bits wide, and sparc doubles are - aligned on 64 bit boundaries, but of course rc does not use - doubles in its code, so the "typedef long ALIGN_T" is good - enough in the sparc's case. Also for performance reasons on a - VAX one would probably want align_t to be 32 bits wide. - - You can override these definitions with compile-line definitions - of the same macros. -*/ - -#ifndef ALIGN_T -typedef long ALIGN_T; -#endif -#ifndef SIZE_T -typedef unsigned int SIZE_T; -#endif -#ifndef MODE_T -typedef short int MODE_T; -#endif -#ifndef PID_T -typedef int PID_T; +#if HAVE_QUAD_T +typedef quad_t align_t; +#else +typedef long align_t; #endif + +/* If you need to change this, please let the maintainer know. */ #ifndef SIG_ATOMIC_T typedef int SIG_ATOMIC_T; #endif +#if STDC_HEADERS +#include <stdlib.h> +#else /* fake stdlib.h */ - extern void exit(int); -extern void qsort(void *, SIZE_T, SIZE_T, int (*)(const void *, const void *)); +extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); +#endif +#if STDC_HEADERS +#include <string.h> +#else /* fake string.h */ - -extern int strncmp(const char *, const char *, SIZE_T); +extern int strncmp(const char *, const char *, size_t); extern int strcmp(const char *, const char *); -extern SIZE_T strlen(const char *); +extern size_t strlen(const char *); extern char *strchr(const char *, int); extern char *strrchr(const char *, int); extern char *strcpy(char *, const char *); -extern char *strncpy(char *, const char *, SIZE_T); +extern char *strncpy(char *, const char *, size_t); extern char *strcat(char *, const char *); -extern char *strncat(char *, const char *, SIZE_T); -extern void *memcpy(void *, const void *, SIZE_T); -extern void *memset(void *, int, SIZE_T); - -/* fake unistd.h */ - -extern PID_T fork(void); -extern PID_T getpid(void); -extern char *getenv(const char *); -extern int chdir(const char *); -extern int close(int); -extern int dup(int); -extern int dup2(int, int); -extern int execve(const char *, const char **, const char **); -extern int execl(const char *,...); -extern int getegid(void); -extern int geteuid(void); -extern int getgroups(int, int *); -/*extern int ioctl(int, long,...);*/ /* too much trouble leaving this uncommented */ -extern int isatty(int); -#ifndef SYSVR4 /* declares AND defines this in sys/stat.h!! */ -extern int mknod(const char *, int, int); +extern char *strncat(char *, const char *, size_t); +extern void *memcpy(void *, const void *, size_t); +extern void *memset(void *, int, size_t); #endif -extern int pipe(int *); -extern int read(int, void *, unsigned int); -extern int setpgrp(int, PID_T); -extern int unlink(const char *); -extern int wait(int *); -extern int write(int, const void *, unsigned int); /* fake errno.h for mips (which doesn't declare errno in errno.h!?!?) */ - #ifdef host_mips extern int errno; #endif diff --git a/rc.h b/rc.h @@ -1,4 +1,13 @@ #include "config.h" + +#if HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#if HAVE_UNISTD_H +#include <unistd.h> +#endif + #include "proto.h" /* datatypes */ @@ -9,6 +18,24 @@ #include <stdarg.h> +#if HAVE_SETPGRP + +#if SETPGRP_VOID +/* Smells like POSIX: should all be ok. */ +#else +/* BSD: fake it. */ +#define setpgid(pid, pgrp) setpgrp(pid, pgrp) +#define tcsetpgrp(fd, pgrp) ioctl((fd), TIOCSPGRP, &(pgrp)) +#endif + +#else /* HAVE_SETPGRP */ + +/* Nothing doing. */ +#define setpgid +#define tcsetpgrp + +#endif /*HAVE_SETPGRP */ + typedef void builtin_t(char **); typedef struct Block Block; typedef struct Dup Dup; @@ -126,20 +153,21 @@ struct Format { /* for the buffer maintainence routines */ char *buf, *bufbegin, *bufend; int flushed; - void (*grow)(Format *, SIZE_T); + void (*grow)(Format *, size_t); union { int n; void *p; } u; }; /* Format->flags values */ enum { - FMT_long = 1, /* %l */ - FMT_short = 2, /* %h */ - FMT_unsigned = 4, /* %u */ - FMT_zeropad = 8, /* %0 */ - FMT_leftside = 16, /* %- */ - FMT_altform = 32, /* %# */ - FMT_f1set = 64, /* %<n> */ - FMT_f2set = 128 /* %.<n> */ + FMT_quad = 1, /* %q */ + FMT_long = 2, /* %l */ + FMT_short = 4, /* %h */ + FMT_unsigned = 8, /* %u */ + FMT_zeropad = 16, /* %0 */ + FMT_leftside = 32, /* %- */ + FMT_altform = 64, /* %# */ + FMT_f1set = 128, /* %<n> */ + FMT_f2set = 256 /* %.<n> */ }; /* macros */ @@ -158,7 +186,7 @@ enum { #define nnew(x) ((x *) nalloc(sizeof(x))) #define ncpy(x) (strcpy((char *) nalloc(strlen(x) + 1), x)) #ifndef offsetof -#define offsetof(t, m) ((SIZE_T) (((char *) &((t *) 0)->m) - (char *)0)) +#define offsetof(t, m) ((size_t) (((char *) &((t *) 0)->m) - (char *)0)) #endif #define streq(x, y) (*(x) == *(y) && strcmp(x, y) == 0) #define conststrlen(x) (sizeof (x) - 1) @@ -170,7 +198,7 @@ extern char *prompt, *prompt2; extern Rq *redirq; extern bool dashdee, dashee, dashvee, dashex, dashell, dasheye, dashen, dashpee, interactive; -extern int rc_pid; +extern pid_t rc_pid; extern int lineno; /* builtins.c */ @@ -278,19 +306,19 @@ extern const char nw[], dnw[]; /* list.c */ extern void listfree(List *); -extern List *listcpy(List *, void *(*)(SIZE_T)); -extern SIZE_T listlen(List *); +extern List *listcpy(List *, void *(*)(size_t)); +extern size_t listlen(List *); extern int listnel(List *); /* match.c */ extern bool match(char *, char *, char *); /* alloc.c */ -extern void *ealloc(SIZE_T); -extern void *erealloc(void *, SIZE_T); +extern void *ealloc(size_t); +extern void *erealloc(void *, size_t); extern void efree(void *); extern Block *newblock(void); -extern void *nalloc(SIZE_T); +extern void *nalloc(size_t); extern void nfree(void); extern void restoreblock(Block *); @@ -306,7 +334,7 @@ extern Conv fmtinstall(int, Conv); extern bool (*fmtinstall(int, bool (*)(Format *, int)))(Format *, int); extern int printfmt(Format *, const char *); extern int fmtprint(Format *, const char *,...); -extern void fmtappend(Format *, const char *, SIZE_T); +extern void fmtappend(Format *, const char *, size_t); extern void fmtcat(Format *, const char *); extern int fprint(int fd, const char *fmt,...); extern char *mprint(const char *fmt,...); @@ -318,7 +346,7 @@ extern char *nprint(const char *fmt,...); */ #define fmtputc(f, c) {\ if ((f)->buf >= (f)->bufend)\ - (*(f)->grow)((f), (SIZE_T)1);\ + (*(f)->grow)((f), (size_t)1);\ *(f)->buf++ = (c);\ } @@ -342,32 +370,32 @@ extern volatile SIG_ATOMIC_T slow, interrupt_happened; extern int istrue(void); extern int getstatus(void); extern void set(bool); -extern void setstatus(int, int); +extern void setstatus(pid_t, int); extern List *sgetstatus(void); extern void setpipestatus(int [], int); -extern void statprint(int, int); +extern void statprint(pid_t, int); extern void ssetstatus(char **); extern char *strstatus(int s); /* tree.c */ extern Node *mk(int /*nodetype*/,...); -extern Node *treecpy(Node *, void *(*)(SIZE_T)); +extern Node *treecpy(Node *, void *(*)(size_t)); extern void treefree(Node *); /* utils.c */ extern bool isabsolute(char *); extern int n2u(char *, unsigned int); -extern int rc_read(int, char *, SIZE_T); +extern int rc_read(int, char *, size_t); extern int mvfd(int, int); extern int starstrcmp(const void *, const void *); extern void pr_error(char *); extern void panic(char *); extern void uerror(char *); -extern void writeall(int, char *, SIZE_T); +extern void writeall(int, char *, size_t); /* wait.c */ -extern int rc_fork(void); -extern int rc_wait4(int, int *, bool); +extern pid_t rc_fork(void); +extern pid_t rc_wait4(pid_t, int *, bool); extern List *sgetapids(void); extern void waitforall(void); extern bool forked; diff --git a/rlimit.h b/rlimit.h @@ -0,0 +1,42 @@ +/* What a mess. This file attempts to straighten everything out. */ + +#if HAVE_SETRLIMIT + +#if HAVE_SYS_RESOURCE_H +# include <sys/time.h> +# if RLIMIT_NEEDS_KERNEL +# define _KERNEL +# endif +# include <sys/resource.h> +# if RLIMIT_NEEDS_KERNEL +# undef _KERNEL +# endif +#else +# include <sys/times.h> +#endif + +#if HAVE_LIMITS_H +# include <limits.h> +#endif + +#ifndef HAVE_RLIM_T +# if RLIM_T_IS_QUAD_T +typedef quad_t rlim_t; +# else +typedef long rlim_t; +# endif +#endif + +#if HAVE_QUAD_T +# define RLIM_CONV quad_t +# define RLIM_FMT "%s \t%qd%s\n" +#else +# define RLIM_CONV long +# define RLIM_FMT "%s \t%ld%s\n" +#endif + +#if defined(RLIMIT_OFILE) && !defined (RLIMIT_NOFILE) +# define RLIMIT_NOFILE RLIMIT_OFILE +#endif + +#endif /* HAVE_SETRLIMIT */ diff --git a/signal.c b/signal.c @@ -19,7 +19,7 @@ extern void catcher(int s) { } signal(s, catcher); interrupt_happened = TRUE; -#ifndef SVSIGS +#ifndef HAVE_RESTARTABLE_SYSCALLS if (slow) longjmp(slowbuf.j, 1); #endif @@ -70,4 +70,11 @@ extern void initsignal() { signal(i, h); sighandlers[i] = h; } + +#ifdef SIGCLD + /* Ensure that SIGCLD is not SIG_IGN. Solaris's rshd does this. :-( */ + h = signal(SIGCLD, SIG_DFL); + if (h != SIG_IGN) + signal(SIGCLD, h); +#endif } diff --git a/status.c b/status.c @@ -52,7 +52,7 @@ extern void setpipestatus(int stats[], int num) { /* set a simple status, as opposed to a pipeline */ -extern void setstatus(int pid, int i) { +extern void setstatus(pid_t pid, int i) { pipelength = 1; statuses[0] = i; statprint(pid, i); @@ -60,11 +60,11 @@ extern void setstatus(int pid, int i) { /* print a message if termination was with a signal, and if the child dumped core. exit on error if -e is set */ -extern void statprint(int pid, int i) { +extern void statprint(pid_t pid, int i) { if (i & 0xff) { char *msg = ((i & 0x7f) < NUMOFSIGNALS ? signals[i & 0x7f].msg : ""); if (pid != -1) - fprint(2, "%d: ", pid); + fprint(2, "%ld: ", (long)pid); if (i & 0x80) { if (*msg == '\0') fprint(2, "core dumped\n"); @@ -129,7 +129,7 @@ extern void ssetstatus(char **av) { break; } else { - SIZE_T len = strlen(signals[k].name); + size_t len = strlen(signals[k].name); if (strncmp(signals[k].name, av[i], len) == 0 && streq(av[i] + len, "+core")) { statuses[l - i] = k + 0x80; found = TRUE; diff --git a/tree.c b/tree.c @@ -65,7 +65,7 @@ extern Node *mk(int /*nodetype*/ t,...) { /* copy a tree to malloc space. Used when storing the definition of a function */ -extern Node *treecpy(Node *s, void *(*alloc)(SIZE_T)) { +extern Node *treecpy(Node *s, void *(*alloc)(size_t)) { Node *n; if (s == NULL) return NULL; @@ -83,7 +83,7 @@ extern Node *treecpy(Node *s, void *(*alloc)(SIZE_T)) { n = (*alloc)(offsetof(Node, u[2])); n->u[0].s = strcpy((char *) (*alloc)(strlen(s->u[0].s) + 1), s->u[0].s); if (s->u[1].s != NULL) { - SIZE_T i = strlen(s->u[0].s); + size_t i = strlen(s->u[0].s); n->u[1].s = (*alloc)(i); memcpy(n->u[1].s, s->u[1].s, i); } else diff --git a/utils.c b/utils.c @@ -67,7 +67,7 @@ extern bool isabsolute(char *path) { /* signal-safe read and write (for BSD slow devices). writeall also allows partial writes */ -extern void writeall(int fd, char *buf, SIZE_T remain) { +extern void writeall(int fd, char *buf, size_t remain) { int i; for (i = 0; remain > 0; buf += i, remain -= i) { interrupt_happened = FALSE; @@ -85,7 +85,7 @@ extern void writeall(int fd, char *buf, SIZE_T remain) { sigchk(); } -extern int rc_read(int fd, char *buf, SIZE_T n) { +extern int rc_read(int fd, char *buf, size_t n) { long /*ssize_t*/ r; interrupt_happened = FALSE; if (!setjmp(slowbuf.j)) { diff --git a/var.c b/var.c @@ -18,7 +18,7 @@ extern void varassign(char *name, List *def, bool stack) { new = get_var_place(name, stack); new->def = newdef; new->extdef = NULL; -#ifdef READLINE /* need to reset readline() every time TERM or TERMCAP changes */ +#if READLINE /* need to reset readline() every time TERM or TERMCAP changes */ if (interactive && (streq(name, "TERM") || streq(name, "TERMCAP"))) { extern void rl_reset_terminal(char *); rl_reset_terminal(NULL); diff --git a/version.c b/version.c @@ -1 +1 @@ -const char id[] = "@(#)rc version 1.5betadev-1, 1/9/94."; +const char id[] = "@(#)rc version 1.5b2, 1997-07-01."; diff --git a/wait.c b/wait.c @@ -1,23 +1,27 @@ +#include "rc.h" + #include <errno.h> #include <setjmp.h> -#include "rc.h" +#include <sys/wait.h> + #include "jbwrap.h" bool forked = FALSE; -static int rc_wait(int *); +static pid_t rc_wait(int *); typedef struct Pid Pid; static struct Pid { - int pid, stat; + pid_t pid; + int stat; bool alive; Pid *n; } *plist = NULL; -extern int rc_fork() { +extern pid_t rc_fork() { Pid *new; - int pid = fork(); + pid_t pid = fork(); switch (pid) { case -1: uerror("fork"); @@ -37,7 +41,7 @@ extern int rc_fork() { } } -extern int rc_wait4(int pid, int *stat, bool nointr) { +extern pid_t rc_wait4(pid_t pid, int *stat, bool nointr) { Pid *r, *prev; int ret; /* first look for a child which may already have exited */ @@ -109,7 +113,7 @@ extern void waitforall() { may want to resume the wait() without delivering any signals. */ -static int rc_wait(int *stat) { +static pid_t rc_wait(int *stat) { int r; interrupt_happened = FALSE; if (!setjmp(slowbuf.j)) { diff --git a/walk.c b/walk.c @@ -43,12 +43,12 @@ top: sigchk(); case nNowait: { int pid; if ((pid = rc_fork()) == 0) { -#if !defined(NOJOB) && defined(SIGTTOU) && defined(SIGTTIN) && defined(SIGTSTP) +#if defined(RC_JOB) && defined(SIGTTOU) && defined(SIGTTIN) && defined(SIGTSTP) setsigdefaults(FALSE); rc_signal(SIGTTOU, SIG_IGN); /* Berkeleyized version: put it in a new pgroup. */ rc_signal(SIGTTIN, SIG_IGN); rc_signal(SIGTSTP, SIG_IGN); - setpgrp(0, getpid()); + setpgid(0, getpid()); #else setsigdefaults(TRUE); /* ignore SIGINT, SIGQUIT, SIGTERM */ #endif diff --git a/which.c b/which.c @@ -8,11 +8,11 @@ and to strip out unneeded functionality. */ +#include "rc.h" +#include <errno.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/param.h> -#include <errno.h> -#include "rc.h" +#include <unistd.h> #define X_USR 0100 #define X_GRP 0010 @@ -22,16 +22,18 @@ extern int stat(const char *, struct stat *); static bool initialized = FALSE; -static int uid, gid; +static uid_t uid; +static gid_t gid; -#ifdef NGROUPS -static int ngroups, gidset[NGROUPS]; +#if HAVE_GETGROUPS +static int ngroups; +static GETGROUPS_T *gidset; /* determine whether gid lies in gidset */ -static int ingidset(int g) { - int i; - for (i = 0; i < ngroups; i++) +static int ingidset(gid_t g) { + gid_t i; + for (i = 0; i < ngroups; ++i) if (g == gidset[i]) return 1; return 0; @@ -55,7 +57,7 @@ static bool rc_access(char *path, bool verbose) { mask = X_ALL; else if (uid == st.st_uid) mask = X_USR; -#ifdef NGROUPS +#if HAVE_GETGROUPS else if (gid == st.st_gid || ingidset(st.st_gid)) #else else if (gid == st.st_gid) @@ -75,7 +77,7 @@ static bool rc_access(char *path, bool verbose) { extern char *which(char *name, bool verbose) { static char *test = NULL; - static SIZE_T testlen = 0; + static size_t testlen = 0; List *path; int len; if (name == NULL) /* no filename? can happen with "> foo" as a command */ @@ -84,15 +86,20 @@ extern char *which(char *name, bool verbose) { initialized = TRUE; uid = geteuid(); gid = getegid(); -#ifdef NGROUPS - ngroups = getgroups(NGROUPS, gidset); +#if HAVE_GETGROUPS + ngroups = getgroups(0, (gid_t *)0); + gidset = malloc(ngroups * sizeof(gid_t)); + if (!gidset) + uerror("malloc"); + else + getgroups(ngroups, gidset); #endif } if (isabsolute(name)) /* absolute pathname? */ return rc_access(name, verbose) ? name : NULL; len = strlen(name); for (path = varlookup("path"); path != NULL; path = path->n) { - SIZE_T need = strlen(path->w) + len + 2; /* one for null terminator, one for the '/' */ + size_t need = strlen(path->w) + len + 2; /* one for null terminator, one for the '/' */ if (testlen < need) { efree(test); test = ealloc(testlen = need); diff --git a/y.tab.c b/y.tab.c @@ -0,0 +1,1070 @@ +#ifndef lint +static char const yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYLEX yylex() +#define YYEMPTY -1 +#define yyclearin (yychar=(YYEMPTY)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING (yyerrflag!=0) +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif +#ifdef __cplusplus +extern "C" { char *getenv(const char *); } +#else +extern char *getenv(); +extern int yylex(); +extern int yyparse(); +#endif +#define YYPREFIX "yy" +#line 8 "parse.y" +#include "rc.h" +#ifndef lint +#define lint /* hush up gcc -Wall, leave out the dumb sccsid's. */ +#endif +static Node *star, *nolist; +Node *parsetree; /* not using yylval because bison declares it as an auto */ +#line 28 "parse.y" +typedef union { + struct Node *node; + struct Redir redir; + struct Pipe pipe; + struct Dup dup; + struct Word word; + char *keyword; +} YYSTYPE; +#line 43 "y.tab.c" +#define ANDAND 257 +#define BACKBACK 258 +#define BANG 259 +#define CASE 260 +#define COUNT 261 +#define DUP 262 +#define ELSE 263 +#define END 264 +#define FLAT 265 +#define FN 266 +#define FOR 267 +#define IF 268 +#define IN 269 +#define OROR 270 +#define PIPE 271 +#define REDIR 272 +#define SREDIR 273 +#define SUB 274 +#define SUBSHELL 275 +#define SWITCH 276 +#define TWIDDLE 277 +#define WHILE 278 +#define WORD 279 +#define HUH 280 +#define YYERRCODE 256 +const short yylhs[] = { -1, + 0, 0, 22, 22, 8, 8, 13, 13, 3, 3, + 9, 9, 4, 15, 2, 11, 11, 16, 16, 16, + 5, 5, 6, 6, 6, 19, 19, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 24, 24, 18, 18, 18, + 12, 12, 17, 17, 20, 20, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, + 14, 14, 14, 23, 23, +}; +const short yylen[] = { 2, + 2, 2, 1, 1, 2, 2, 1, 2, 1, 2, + 1, 2, 3, 3, 3, 0, 2, 1, 2, 2, + 3, 3, 1, 2, 2, 1, 4, 0, 1, 2, + 4, 8, 6, 4, 8, 4, 4, 4, 4, 2, + 2, 3, 3, 3, 2, 0, 1, 1, 2, 2, + 1, 3, 1, 1, 1, 3, 2, 5, 2, 2, + 2, 2, 3, 3, 3, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, + 0, 2, 2, 0, 2, +}; +const short yydefred[] = { 0, + 0, 0, 0, 0, 18, 0, 79, 0, 0, 0, + 0, 0, 0, 0, 0, 67, 0, 0, 81, 0, + 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, + 3, 4, 2, 77, 75, 74, 73, 68, 71, 69, + 0, 78, 72, 76, 70, 54, 53, 55, 0, 47, + 0, 59, 60, 0, 0, 0, 84, 66, 0, 0, + 0, 0, 0, 84, 0, 0, 0, 11, 0, 0, + 62, 61, 0, 0, 30, 0, 84, 84, 84, 5, + 6, 8, 0, 0, 1, 0, 50, 0, 0, 63, + 64, 0, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 79, 13, 12, 10, 65, 82, 0, 17, 0, + 0, 0, 0, 52, 56, 79, 84, 14, 85, 0, + 0, 31, 84, 0, 0, 0, 0, 0, 39, 0, + 0, 84, 0, 58, 84, 0, 0, 0, 0, 0, + 79, 0, 0, 0, 0, 0, 0, 24, 35, 25, + 22, 21, +}; +const short yydgoto[] = { 21, + 46, 22, 66, 23, 142, 143, 67, 68, 69, 47, + 75, 27, 28, 70, 57, 29, 48, 30, 122, 94, + 54, 33, 97, 51, +}; +const short yysindex[] = { 874, + 24, 1001, -82, 1001, 0, 1001, 0, -27, -26, 900, + 1001, -82, -20, -82, -26, 0, 1001, 1134, 0, 900, + 0, 1134, -203, -30, 1134, 0, -55, 24, 1134, 826, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -66, 0, 0, 0, 0, 0, 0, 0, 849, 0, + 1134, 0, 0, 900, 1001, 1134, 0, 0, -52, -52, + 1134, 1001, 1001, 0, -212, -58, 154, 0, 1134, 426, + 0, 0, -196, 1001, 0, -203, 0, 0, 0, 0, + 0, 0, 1001, 1001, 0, -196, 0, -52, 1001, 0, + 0, -196, 0, -52, -38, 36, 502, -196, -36, -52, + 502, 0, 0, 0, 0, 0, 0, -52, 0, 502, + 502, 502, -52, 0, 0, 0, 0, 0, 0, -97, + -234, 0, 0, 1001, -234, 922, -196, -196, 0, 944, + 502, 0, -9, 0, 0, -234, 502, 967, 502, -234, + 0, 967, -45, 154, 967, -234, 448, 0, 0, 0, + 0, 0, +}; +const short yyrindex[] = { 134, + 0, 0, 356, 0, 0, 0, 0, 0, 0, 0, + 0, 356, 0, 1024, 0, 0, 0, 571, 0, 0, + 0, 487, 529, 54, 134, 0, 62, 0, 487, 548, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 487, 0, 0, 712, 0, 142, 0, 0, 14, 38, + 487, 0, 0, 0, -10, 0, -32, 0, 744, 0, + 0, 0, 749, 0, 0, 529, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 763, 0, 86, 0, 0, + 0, 779, 0, 110, 0, 0, -34, 788, 0, 380, + -34, 0, 0, 0, 0, 0, 0, 470, 0, -34, + -34, -34, 404, 0, 0, 0, 0, 0, 0, 529, + 6, 0, 0, 724, 30, 0, 805, 813, 0, 0, + -34, 0, 0, 0, 0, 119, -34, 571, -34, 187, + 0, 571, 0, -44, 571, 396, 0, 0, 0, 0, + 0, 0, +}; +const short yygindex[] = { 0, + 0, 0, -23, 12, 0, -104, 1319, 2, -127, 1307, + 7, 0, 57, 0, 70, -13, 84, 0, 0, 420, + -81, 59, 369, 31, +}; +#define YYTABLESIZE 1464 +const short yytable[] = { 57, + 119, 25, 117, 28, 123, 83, 28, 81, 9, 76, + 145, 50, 55, 56, 145, 26, 87, 145, 124, 62, + 126, 58, 77, 19, 28, 57, 25, 57, 80, 57, + 57, 71, 96, 32, 130, 78, 79, 148, 84, 34, + 150, 89, 61, 26, 63, 105, 26, 20, 57, 19, + 57, 19, 58, 19, 19, 89, 18, 89, 5, 147, + 90, 102, 76, 7, 26, 93, 103, 34, 74, 11, + 34, 48, 19, 20, 79, 20, 118, 20, 20, 149, + 23, 82, 109, 57, 64, 57, 85, 52, 34, 53, + 28, 0, 9, 0, 0, 49, 20, 48, 0, 48, + 65, 48, 48, 72, 0, 0, 76, 0, 120, 19, + 0, 0, 57, 138, 57, 0, 0, 0, 0, 80, + 48, 49, 0, 49, 0, 49, 49, 0, 33, 0, + 26, 0, 91, 20, 0, 0, 19, 0, 19, 0, + 0, 0, 0, 28, 49, 80, 0, 80, 0, 80, + 80, 28, 0, 0, 34, 0, 33, 48, 0, 33, + 20, 0, 20, 104, 5, 132, 0, 114, 80, 0, + 0, 28, 115, 0, 74, 11, 0, 33, 0, 28, + 0, 49, 28, 0, 0, 0, 48, 0, 0, 0, + 0, 81, 28, 0, 0, 0, 27, 0, 0, 0, + 28, 0, 0, 0, 0, 80, 0, 0, 0, 0, + 49, 0, 80, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 28, 0, 27, 0, 77, 27, 0, 28, + 116, 0, 80, 0, 80, 28, 28, 0, 0, 78, + 79, 0, 0, 33, 0, 27, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 0, 57, 57, 57, 57, 57, 26, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 31, 19, 19, + 19, 19, 19, 34, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 27, 20, 20, 20, 20, 20, 7, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 0, 48, 48, 48, 48, + 48, 0, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, + 49, 49, 49, 49, 49, 46, 80, 80, 80, 80, + 80, 0, 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 33, 0, 80, 80, 80, 80, 80, 79, + 28, 46, 0, 46, 0, 46, 46, 28, 28, 0, + 0, 0, 0, 28, 28, 32, 0, 0, 0, 0, + 77, 28, 28, 15, 46, 79, 0, 79, 0, 79, + 79, 49, 0, 78, 79, 0, 0, 0, 0, 59, + 60, 0, 101, 32, 0, 107, 32, 0, 79, 15, + 0, 15, 0, 15, 15, 110, 111, 112, 0, 88, + 27, 46, 0, 0, 32, 0, 0, 151, 0, 0, + 0, 17, 15, 0, 0, 19, 106, 0, 0, 0, + 0, 0, 0, 0, 95, 79, 0, 0, 46, 83, + 46, 99, 100, 17, 0, 131, 0, 19, 0, 108, + 0, 133, 0, 59, 0, 0, 28, 0, 0, 15, + 137, 0, 113, 139, 79, 83, 152, 0, 0, 83, + 83, 119, 0, 0, 0, 0, 0, 0, 0, 0, + 32, 20, 0, 0, 28, 0, 15, 28, 15, 0, + 0, 0, 0, 0, 0, 0, 0, 17, 16, 0, + 0, 19, 0, 20, 0, 28, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, + 0, 0, 0, 0, 0, 83, 16, 0, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, 29, 0, 16, 29, 0, + 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, + 0, 0, 0, 0, 0, 0, 29, 0, 28, 0, + 0, 28, 46, 46, 46, 0, 46, 46, 0, 46, + 46, 46, 46, 46, 18, 46, 46, 46, 46, 28, + 46, 46, 46, 46, 46, 0, 79, 79, 79, 79, + 79, 0, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 0, 16, 79, 79, 79, 79, 79, 32, + 15, 15, 15, 0, 15, 15, 0, 15, 15, 15, + 15, 15, 29, 15, 15, 15, 15, 0, 15, 15, + 15, 15, 15, 2, 34, 35, 4, 0, 36, 0, + 6, 37, 38, 39, 40, 28, 0, 41, 0, 0, + 42, 43, 44, 45, 16, 2, 34, 35, 4, 0, + 36, 0, 6, 37, 38, 39, 40, 0, 0, 41, + 0, 45, 42, 43, 44, 45, 16, 83, 83, 83, + 83, 0, 83, 36, 83, 83, 83, 83, 83, 0, + 0, 83, 0, 28, 83, 83, 83, 83, 83, 45, + 28, 0, 45, 28, 0, 0, 28, 28, 41, 2, + 3, 36, 4, 5, 36, 0, 6, 7, 8, 9, + 45, 0, 40, 10, 11, 0, 12, 13, 14, 15, + 16, 28, 36, 0, 28, 16, 41, 0, 42, 41, + 0, 0, 16, 0, 0, 0, 0, 43, 16, 16, + 40, 0, 28, 40, 29, 0, 0, 41, 0, 0, + 0, 29, 0, 0, 37, 0, 42, 29, 29, 42, + 0, 40, 38, 0, 0, 43, 0, 28, 43, 0, + 0, 0, 0, 0, 0, 0, 45, 42, 0, 0, + 28, 28, 37, 0, 0, 37, 43, 0, 36, 0, + 38, 0, 0, 38, 0, 0, 0, 0, 0, 0, + 0, 17, 0, 37, 0, 19, 0, 0, 28, 0, + 0, 38, 0, 41, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 17, 0, 0, 40, 19, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 42, 0, 0, 0, 0, 0, 17, + 0, 0, 43, 19, 0, 0, 0, 0, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 0, 0, 37, + 0, 0, 0, 0, 0, 17, 0, 38, 0, 19, + 0, 0, 89, 0, 20, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, + 0, 19, 134, 0, 0, 0, 0, 0, 45, 20, + 0, 18, 0, 0, 0, 45, 0, 0, 0, 17, + 36, 45, 45, 19, 135, 0, 0, 36, 0, 0, + 0, 0, 0, 36, 36, 20, 18, 0, 0, 0, + 28, 0, 17, 0, 0, 41, 19, 0, 0, 0, + 0, 0, 41, 28, 28, 0, 0, 20, 41, 40, + 0, 0, 18, 0, 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 0, 42, 17, 0, 0, 20, + 19, 0, 42, 0, 43, 0, 0, 0, 42, 0, + 0, 43, 0, 0, 0, 0, 0, 43, 0, 46, + 0, 37, 20, 46, 0, 0, 0, 0, 37, 38, + 0, 0, 0, 0, 37, 0, 38, 0, 0, 0, + 0, 0, 38, 2, 34, 35, 4, 5, 36, 18, + 6, 37, 38, 39, 40, 0, 20, 10, 11, 0, + 42, 43, 44, 45, 16, 0, 2, 34, 35, 4, + 0, 36, 0, 6, 37, 38, 39, 40, 0, 46, + 41, 0, 0, 42, 43, 44, 45, 16, 0, 1, + 0, 2, 3, 0, 4, 5, 0, 0, 6, 7, + 8, 9, 0, 0, 0, 10, 11, 0, 12, 13, + 14, 15, 16, 0, 0, 0, 0, 2, 34, 35, + 4, 0, 36, 0, 6, 37, 38, 39, 40, 17, + 0, 41, 0, 19, 42, 43, 44, 45, 16, 2, + 34, 35, 4, 0, 36, 0, 6, 37, 38, 39, + 40, 0, 0, 41, 0, 0, 42, 43, 44, 45, + 16, 2, 34, 35, 4, 0, 36, 0, 6, 37, + 38, 39, 40, 0, 0, 41, 0, 0, 42, 43, + 44, 45, 16, 0, 2, 3, 141, 4, 5, 20, + 0, 6, 7, 8, 9, 0, 0, 0, 10, 11, + 0, 12, 13, 14, 15, 16, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 2, 34, + 35, 4, 0, 36, 0, 6, 37, 38, 39, 40, + 0, 0, 41, 0, 0, 42, 43, 44, 45, 16, + 0, 46, 46, 46, 46, 0, 46, 0, 46, 46, + 46, 46, 46, 0, 0, 46, 0, 0, 46, 46, + 46, 46, 46, 0, 0, 0, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, + 0, 0, 0, 0, 26, 0, 0, 0, 26, 0, + 0, 26, 0, 0, 0, 26, 0, 0, 0, 0, + 73, 0, 0, 24, 0, 0, 0, 86, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, + 0, 0, 26, 0, 0, 0, 0, 26, 0, 92, + 0, 0, 0, 0, 0, 26, 0, 0, 0, 98, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 3, 0, 4, 5, 0, 0, 6, 7, + 8, 9, 0, 26, 0, 10, 11, 26, 12, 13, + 14, 15, 16, 0, 0, 121, 26, 26, 26, 125, + 0, 0, 0, 0, 0, 0, 0, 0, 127, 128, + 129, 0, 0, 0, 0, 0, 0, 26, 0, 0, + 0, 0, 0, 26, 26, 26, 0, 0, 26, 136, + 0, 26, 0, 0, 0, 140, 144, 146, 0, 0, + 144, 0, 0, 144, +}; +const short yycheck[] = { 10, + 10, 0, 41, 38, 41, 61, 41, 38, 41, 23, + 138, 94, 40, 40, 142, 10, 30, 145, 100, 40, + 102, 10, 257, 10, 59, 36, 25, 38, 59, 40, + 41, 20, 56, 10, 116, 270, 271, 142, 94, 10, + 145, 94, 12, 38, 14, 69, 41, 10, 59, 36, + 61, 38, 41, 40, 41, 94, 123, 94, 262, 141, + 49, 274, 76, 10, 59, 54, 125, 38, 272, 273, + 41, 10, 59, 36, 271, 38, 41, 40, 41, 125, + 125, 25, 76, 94, 15, 96, 28, 4, 59, 6, + 125, -1, 125, -1, -1, 10, 59, 36, -1, 38, + 17, 40, 41, 20, -1, -1, 120, -1, 97, 96, + -1, -1, 123, 123, 125, -1, -1, -1, -1, 10, + 59, 36, -1, 38, -1, 40, 41, -1, 10, -1, + 125, -1, 49, 96, -1, -1, 123, -1, 125, -1, + -1, -1, -1, 10, 59, 36, -1, 38, -1, 40, + 41, 10, -1, -1, 125, -1, 38, 96, -1, 41, + 123, -1, 125, 10, 262, 263, -1, 84, 59, -1, + -1, 38, 89, -1, 272, 273, -1, 59, -1, 38, + -1, 96, 41, -1, -1, -1, 125, -1, -1, -1, + -1, 38, 59, -1, -1, -1, 10, -1, -1, -1, + 59, -1, -1, -1, -1, 96, -1, -1, -1, -1, + 125, -1, 59, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 257, -1, 38, -1, 257, 41, -1, 264, + 269, -1, 123, -1, 125, 270, 271, -1, -1, 270, + 271, -1, -1, 125, -1, 59, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, -1, 275, 276, 277, 278, 279, 264, + 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 264, 275, 276, + 277, 278, 279, 264, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 125, 275, 276, 277, 278, 279, 264, 257, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, -1, 275, 276, 277, 278, + 279, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, -1, + 275, 276, 277, 278, 279, 10, 257, 258, 259, 260, + 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 264, -1, 275, 276, 277, 278, 279, 10, + 257, 36, -1, 38, -1, 40, 41, 264, 257, -1, + -1, -1, -1, 270, 271, 10, -1, -1, -1, -1, + 257, 270, 271, 10, 59, 36, -1, 38, -1, 40, + 41, 2, -1, 270, 271, -1, -1, -1, -1, 10, + 11, -1, 64, 38, -1, 10, 41, -1, 59, 36, + -1, 38, -1, 40, 41, 77, 78, 79, -1, 30, + 264, 96, -1, -1, 59, -1, -1, 10, -1, -1, + -1, 36, 59, -1, -1, 40, 41, -1, -1, -1, + -1, -1, -1, -1, 55, 96, -1, -1, 123, 10, + 125, 62, 63, 36, -1, 117, -1, 40, -1, 70, + -1, 123, -1, 74, -1, -1, 10, -1, -1, 96, + 132, -1, 83, 135, 125, 36, 59, -1, -1, 40, + 41, 10, -1, -1, -1, -1, -1, -1, -1, -1, + 125, 96, -1, -1, 38, -1, 123, 41, 125, -1, + -1, -1, -1, -1, -1, -1, -1, 36, 10, -1, + -1, 40, -1, 96, -1, 59, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 10, -1, -1, + -1, -1, -1, -1, -1, 96, 38, -1, -1, 41, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, -1, -1, -1, -1, 38, -1, 59, 41, -1, + -1, -1, -1, -1, -1, -1, -1, 96, -1, -1, + -1, -1, -1, -1, -1, -1, 59, -1, 38, -1, + -1, 125, 257, 258, 259, -1, 261, 262, -1, 264, + 265, 266, 267, 268, 123, 270, 271, 272, 273, 59, + 275, 276, 277, 278, 279, -1, 257, 258, 259, 260, + 261, -1, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, -1, 125, 275, 276, 277, 278, 279, 264, + 257, 258, 259, -1, 261, 262, -1, 264, 265, 266, + 267, 268, 125, 270, 271, 272, 273, -1, 275, 276, + 277, 278, 279, 258, 259, 260, 261, -1, 263, -1, + 265, 266, 267, 268, 269, 125, -1, 272, -1, -1, + 275, 276, 277, 278, 279, 258, 259, 260, 261, -1, + 263, -1, 265, 266, 267, 268, 269, -1, -1, 272, + -1, 10, 275, 276, 277, 278, 279, 258, 259, 260, + 261, -1, 263, 10, 265, 266, 267, 268, 269, -1, + -1, 272, -1, 257, 275, 276, 277, 278, 279, 38, + 264, -1, 41, 10, -1, -1, 270, 271, 10, 258, + 259, 38, 261, 262, 41, -1, 265, 266, 267, 268, + 59, -1, 10, 272, 273, -1, 275, 276, 277, 278, + 279, 38, 59, -1, 41, 257, 38, -1, 10, 41, + -1, -1, 264, -1, -1, -1, -1, 10, 270, 271, + 38, -1, 59, 41, 257, -1, -1, 59, -1, -1, + -1, 264, -1, -1, 10, -1, 38, 270, 271, 41, + -1, 59, 10, -1, -1, 38, -1, 257, 41, -1, + -1, -1, -1, -1, -1, -1, 125, 59, -1, -1, + 270, 271, 38, -1, -1, 41, 59, -1, 125, -1, + 38, -1, -1, 41, -1, -1, -1, -1, -1, -1, + -1, 36, -1, 59, -1, 40, -1, -1, 125, -1, + -1, 59, -1, 125, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 36, -1, -1, 125, 40, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 125, -1, -1, -1, -1, -1, 36, + -1, -1, 125, 40, -1, -1, -1, -1, -1, -1, + -1, 96, -1, -1, -1, -1, -1, -1, -1, 125, + -1, -1, -1, -1, -1, 36, -1, 125, -1, 40, + -1, -1, 94, -1, 96, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, + -1, 40, 41, -1, -1, -1, -1, -1, 257, 96, + -1, 123, -1, -1, -1, 264, -1, -1, -1, 36, + 257, 270, 271, 40, 41, -1, -1, 264, -1, -1, + -1, -1, -1, 270, 271, 96, 123, -1, -1, -1, + 257, -1, 36, -1, -1, 257, 40, -1, -1, -1, + -1, -1, 264, 270, 271, -1, -1, 96, 270, 257, + -1, -1, 123, -1, -1, -1, 264, -1, -1, -1, + -1, -1, 270, -1, -1, 257, 36, -1, -1, 96, + 40, -1, 264, -1, 257, -1, -1, -1, 270, -1, + -1, 264, -1, -1, -1, -1, -1, 270, -1, 36, + -1, 257, 96, 40, -1, -1, -1, -1, 264, 257, + -1, -1, -1, -1, 270, -1, 264, -1, -1, -1, + -1, -1, 270, 258, 259, 260, 261, 262, 263, 123, + 265, 266, 267, 268, 269, -1, 96, 272, 273, -1, + 275, 276, 277, 278, 279, -1, 258, 259, 260, 261, + -1, 263, -1, 265, 266, 267, 268, 269, -1, 96, + 272, -1, -1, 275, 276, 277, 278, 279, -1, 256, + -1, 258, 259, -1, 261, 262, -1, -1, 265, 266, + 267, 268, -1, -1, -1, 272, 273, -1, 275, 276, + 277, 278, 279, -1, -1, -1, -1, 258, 259, 260, + 261, -1, 263, -1, 265, 266, 267, 268, 269, 36, + -1, 272, -1, 40, 275, 276, 277, 278, 279, 258, + 259, 260, 261, -1, 263, -1, 265, 266, 267, 268, + 269, -1, -1, 272, -1, -1, 275, 276, 277, 278, + 279, 258, 259, 260, 261, -1, 263, -1, 265, 266, + 267, 268, 269, -1, -1, 272, -1, -1, 275, 276, + 277, 278, 279, -1, 258, 259, 260, 261, 262, 96, + -1, 265, 266, 267, 268, -1, -1, -1, 272, 273, + -1, 275, 276, 277, 278, 279, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 123, -1, 258, 259, + 260, 261, -1, 263, -1, 265, 266, 267, 268, 269, + -1, -1, 272, -1, -1, 275, 276, 277, 278, 279, + -1, 258, 259, 260, 261, -1, 263, -1, 265, 266, + 267, 268, 269, -1, -1, 272, -1, -1, 275, 276, + 277, 278, 279, -1, -1, -1, 0, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, -1, -1, -1, 18, -1, -1, -1, 22, -1, + -1, 25, -1, -1, -1, 29, -1, -1, -1, -1, + 22, -1, -1, 25, -1, -1, -1, 29, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 51, -1, -1, + -1, -1, 56, -1, -1, -1, -1, 61, -1, 51, + -1, -1, -1, -1, -1, 69, -1, -1, -1, 61, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 258, 259, -1, 261, 262, -1, -1, 265, 266, + 267, 268, -1, 97, -1, 272, 273, 101, 275, 276, + 277, 278, 279, -1, -1, 97, 110, 111, 112, 101, + -1, -1, -1, -1, -1, -1, -1, -1, 110, 111, + 112, -1, -1, -1, -1, -1, -1, 131, -1, -1, + -1, -1, -1, 137, 138, 139, -1, -1, 142, 131, + -1, 145, -1, -1, -1, 137, 138, 139, -1, -1, + 142, -1, -1, 145, +}; +#define YYFINAL 21 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 280 +#if YYDEBUG +char *yyname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,"'$'",0,"'&'",0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0, +"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'^'",0, +"'`'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,"ANDAND","BACKBACK","BANG","CASE","COUNT","DUP","ELSE","END", +"FLAT","FN","FOR","IF","IN","OROR","PIPE","REDIR","SREDIR","SUB","SUBSHELL", +"SWITCH","TWIDDLE","WHILE","WORD","HUH", +}; +const char * const yyrule[] = { +"$accept : rc", +"rc : line end", +"rc : error end", +"end : END", +"end : '\\n'", +"cmdsa : cmd ';'", +"cmdsa : cmd '&'", +"line : cmd", +"line : cmdsa line", +"body : cmd", +"body : cmdsan body", +"cmdsan : cmdsa", +"cmdsan : cmd '\\n'", +"brace : '{' body '}'", +"paren : '(' body ')'", +"assign : first '=' word", +"epilog :", +"epilog : redir epilog", +"redir : DUP", +"redir : REDIR word", +"redir : SREDIR word", +"case : CASE words ';'", +"case : CASE words '\\n'", +"cbody : cmd", +"cbody : case cbody", +"cbody : cmdsan cbody", +"iftail : cmd", +"iftail : brace ELSE optnl cmd", +"cmd :", +"cmd : simple", +"cmd : brace epilog", +"cmd : IF paren optnl iftail", +"cmd : FOR '(' word IN words ')' optnl cmd", +"cmd : FOR '(' word ')' optnl cmd", +"cmd : WHILE paren optnl cmd", +"cmd : SWITCH '(' word ')' optnl '{' cbody '}'", +"cmd : TWIDDLE optcaret word words", +"cmd : cmd ANDAND optnl cmd", +"cmd : cmd OROR optnl cmd", +"cmd : cmd PIPE optnl cmd", +"cmd : redir cmd", +"cmd : assign cmd", +"cmd : BANG optcaret cmd", +"cmd : SUBSHELL optcaret cmd", +"cmd : FN words brace", +"cmd : FN words", +"optcaret :", +"optcaret : '^'", +"simple : first", +"simple : simple word", +"simple : simple redir", +"first : comword", +"first : first '^' sword", +"sword : comword", +"sword : keyword", +"word : sword", +"word : word '^' sword", +"comword : '$' sword", +"comword : '$' sword SUB words ')'", +"comword : COUNT sword", +"comword : FLAT sword", +"comword : '`' sword", +"comword : '`' brace", +"comword : BACKBACK word brace", +"comword : BACKBACK word sword", +"comword : '(' nlwords ')'", +"comword : REDIR brace", +"comword : WORD", +"keyword : FOR", +"keyword : IN", +"keyword : WHILE", +"keyword : IF", +"keyword : SWITCH", +"keyword : FN", +"keyword : ELSE", +"keyword : CASE", +"keyword : TWIDDLE", +"keyword : BANG", +"keyword : SUBSHELL", +"words :", +"words : words word", +"nlwords :", +"nlwords : nlwords '\\n'", +"nlwords : nlwords word", +"optnl :", +"optnl : optnl '\\n'", +}; +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 169 "parse.y" + +void initparse() { + star = treecpy(mk(nVar,mk(nWord,"*",NULL)), ealloc); + nolist = treecpy(mk(nVar,mk(nWord,"ifs",NULL)), ealloc); +} + +#line 590 "y.tab.c" +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab + +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + + if ((yys = getenv("YYDEBUG"))) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate])) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#if defined(lint) || defined(__GNUC__) + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#if defined(lint) || defined(__GNUC__) + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 1: +#line 49 "parse.y" +{ parsetree = yyvsp[-1].node; YYACCEPT; } +break; +case 2: +#line 50 "parse.y" +{ yyerrok; parsetree = NULL; YYABORT; } +break; +case 3: +#line 53 "parse.y" +{ if (!heredoc(1)) YYABORT; } +break; +case 4: +#line 54 "parse.y" +{ if (!heredoc(0)) YYABORT; } +break; +case 6: +#line 58 "parse.y" +{ yyval.node = (yyvsp[-1].node != NULL ? mk(nNowait,yyvsp[-1].node) : yyvsp[-1].node); } +break; +case 8: +#line 62 "parse.y" +{ yyval.node = (yyvsp[-1].node != NULL ? mk(nBody,yyvsp[-1].node,yyvsp[0].node) : yyvsp[0].node); } +break; +case 10: +#line 66 "parse.y" +{ yyval.node = (yyvsp[-1].node == NULL ? yyvsp[0].node : yyvsp[0].node == NULL ? yyvsp[-1].node : mk(nBody,yyvsp[-1].node,yyvsp[0].node)); } +break; +case 12: +#line 69 "parse.y" +{ yyval.node = yyvsp[-1].node; if (!heredoc(0)) YYABORT; } +break; +case 13: +#line 71 "parse.y" +{ yyval.node = yyvsp[-1].node; } +break; +case 14: +#line 73 "parse.y" +{ yyval.node = yyvsp[-1].node; } +break; +case 15: +#line 75 "parse.y" +{ yyval.node = mk(nAssign,yyvsp[-2].node,yyvsp[0].node); } +break; +case 16: +#line 77 "parse.y" +{ yyval.node = NULL; } +break; +case 17: +#line 78 "parse.y" +{ yyval.node = mk(nEpilog,yyvsp[-1].node,yyvsp[0].node); } +break; +case 18: +#line 81 "parse.y" +{ yyval.node = mk(nDup,yyvsp[0].dup.type,yyvsp[0].dup.left,yyvsp[0].dup.right); } +break; +case 19: +#line 82 "parse.y" +{ yyval.node = mk(nRedir,yyvsp[-1].redir.type,yyvsp[-1].redir.fd,yyvsp[0].node); + if (yyvsp[-1].redir.type == rHeredoc && !qdoc(yyvsp[0].node, yyval.node)) YYABORT; /* queue heredocs up */ + } +break; +case 20: +#line 85 "parse.y" +{ yyval.node = mk(nRedir,yyvsp[-1].redir.type,yyvsp[-1].redir.fd,yyvsp[0].node); + if (yyvsp[-1].redir.type == rHeredoc && !qdoc(yyvsp[0].node, yyval.node)) YYABORT; /* queue heredocs up */ + } +break; +case 21: +#line 89 "parse.y" +{ yyval.node = mk(nCase, yyvsp[-1].node); } +break; +case 22: +#line 90 "parse.y" +{ yyval.node = mk(nCase, yyvsp[-1].node); } +break; +case 23: +#line 92 "parse.y" +{ yyval.node = mk(nCbody, yyvsp[0].node, NULL); } +break; +case 24: +#line 93 "parse.y" +{ yyval.node = mk(nCbody, yyvsp[-1].node, yyvsp[0].node); } +break; +case 25: +#line 94 "parse.y" +{ yyval.node = mk(nCbody, yyvsp[-1].node, yyvsp[0].node); } +break; +case 27: +#line 97 "parse.y" +{ yyval.node = mk(nElse,yyvsp[-3].node,yyvsp[0].node); } +break; +case 28: +#line 99 "parse.y" +{ yyval.node = NULL; } +break; +case 30: +#line 101 "parse.y" +{ yyval.node = mk(nBrace,yyvsp[-1].node,yyvsp[0].node); } +break; +case 31: +#line 102 "parse.y" +{ yyval.node = mk(nIf,yyvsp[-2].node,yyvsp[0].node); } +break; +case 32: +#line 103 "parse.y" +{ yyval.node = mk(nForin,yyvsp[-5].node,yyvsp[-3].node,yyvsp[0].node); } +break; +case 33: +#line 104 "parse.y" +{ yyval.node = mk(nForin,yyvsp[-3].node,star,yyvsp[0].node); } +break; +case 34: +#line 105 "parse.y" +{ yyval.node = mk(nWhile,yyvsp[-2].node,yyvsp[0].node); } +break; +case 35: +#line 106 "parse.y" +{ yyval.node = mk(nSwitch,yyvsp[-5].node,yyvsp[-1].node); } +break; +case 36: +#line 107 "parse.y" +{ yyval.node = mk(nMatch,yyvsp[-1].node,yyvsp[0].node); } +break; +case 37: +#line 108 "parse.y" +{ yyval.node = mk(nAndalso,yyvsp[-3].node,yyvsp[0].node); } +break; +case 38: +#line 109 "parse.y" +{ yyval.node = mk(nOrelse,yyvsp[-3].node,yyvsp[0].node); } +break; +case 39: +#line 110 "parse.y" +{ yyval.node = mk(nPipe,yyvsp[-2].pipe.left,yyvsp[-2].pipe.right,yyvsp[-3].node,yyvsp[0].node); } +break; +case 40: +#line 111 "parse.y" +{ yyval.node = (yyvsp[0].node != NULL ? mk(nPre,yyvsp[-1].node,yyvsp[0].node) : yyvsp[-1].node); } +break; +case 41: +#line 112 "parse.y" +{ yyval.node = (yyvsp[0].node != NULL ? mk(nPre,yyvsp[-1].node,yyvsp[0].node) : yyvsp[-1].node); } +break; +case 42: +#line 113 "parse.y" +{ yyval.node = mk(nBang,yyvsp[0].node); } +break; +case 43: +#line 114 "parse.y" +{ yyval.node = mk(nSubshell,yyvsp[0].node); } +break; +case 44: +#line 115 "parse.y" +{ yyval.node = mk(nNewfn,yyvsp[-1].node,yyvsp[0].node); } +break; +case 45: +#line 116 "parse.y" +{ yyval.node = mk(nRmfn,yyvsp[0].node); } +break; +case 49: +#line 122 "parse.y" +{ yyval.node = (yyvsp[0].node != NULL ? mk(nArgs,yyvsp[-1].node,yyvsp[0].node) : yyvsp[-1].node); } +break; +case 50: +#line 123 "parse.y" +{ yyval.node = mk(nArgs,yyvsp[-1].node,yyvsp[0].node); } +break; +case 52: +#line 126 "parse.y" +{ yyval.node = mk(nConcat,yyvsp[-2].node,yyvsp[0].node); } +break; +case 54: +#line 129 "parse.y" +{ yyval.node = mk(nWord,yyvsp[0].keyword, NULL); } +break; +case 56: +#line 132 "parse.y" +{ yyval.node = mk(nConcat,yyvsp[-2].node,yyvsp[0].node); } +break; +case 57: +#line 134 "parse.y" +{ yyval.node = mk(nVar,yyvsp[0].node); } +break; +case 58: +#line 135 "parse.y" +{ yyval.node = mk(nVarsub,yyvsp[-3].node,yyvsp[-1].node); } +break; +case 59: +#line 136 "parse.y" +{ yyval.node = mk(nCount,yyvsp[0].node); } +break; +case 60: +#line 137 "parse.y" +{ yyval.node = mk(nFlat, yyvsp[0].node); } +break; +case 61: +#line 138 "parse.y" +{ yyval.node = mk(nBackq,nolist,yyvsp[0].node); } +break; +case 62: +#line 139 "parse.y" +{ yyval.node = mk(nBackq,nolist,yyvsp[0].node); } +break; +case 63: +#line 140 "parse.y" +{ yyval.node = mk(nBackq,yyvsp[-1].node,yyvsp[0].node); } +break; +case 64: +#line 141 "parse.y" +{ yyval.node = mk(nBackq,yyvsp[-1].node,yyvsp[0].node); } +break; +case 65: +#line 142 "parse.y" +{ yyval.node = yyvsp[-1].node; } +break; +case 66: +#line 143 "parse.y" +{ yyval.node = mk(nNmpipe,yyvsp[-1].redir.type,yyvsp[-1].redir.fd,yyvsp[0].node); } +break; +case 67: +#line 144 "parse.y" +{ yyval.node = (yyvsp[0].word.w[0] == '\'') ? mk(nQword, yyvsp[0].word.w+1, NULL) : mk(nWord,yyvsp[0].word.w, yyvsp[0].word.m); } +break; +case 68: +#line 146 "parse.y" +{ yyval.keyword = "for"; } +break; +case 69: +#line 147 "parse.y" +{ yyval.keyword = "in"; } +break; +case 70: +#line 148 "parse.y" +{ yyval.keyword = "while"; } +break; +case 71: +#line 149 "parse.y" +{ yyval.keyword = "if"; } +break; +case 72: +#line 150 "parse.y" +{ yyval.keyword = "switch"; } +break; +case 73: +#line 151 "parse.y" +{ yyval.keyword = "fn"; } +break; +case 74: +#line 152 "parse.y" +{ yyval.keyword = "else"; } +break; +case 75: +#line 153 "parse.y" +{ yyval.keyword = "case"; } +break; +case 76: +#line 154 "parse.y" +{ yyval.keyword = "~"; } +break; +case 77: +#line 155 "parse.y" +{ yyval.keyword = "!"; } +break; +case 78: +#line 156 "parse.y" +{ yyval.keyword = "@"; } +break; +case 79: +#line 158 "parse.y" +{ yyval.node = NULL; } +break; +case 80: +#line 159 "parse.y" +{ yyval.node = (yyvsp[-1].node != NULL ? (yyvsp[0].node != NULL ? mk(nLappend,yyvsp[-1].node,yyvsp[0].node) : yyvsp[-1].node) : yyvsp[0].node); } +break; +case 81: +#line 161 "parse.y" +{ yyval.node = NULL; } +break; +case 83: +#line 163 "parse.y" +{ yyval.node = (yyvsp[-1].node != NULL ? (yyvsp[0].node != NULL ? mk(nLappend,yyvsp[-1].node,yyvsp[0].node) : yyvsp[-1].node) : yyvsp[0].node); } +break; +#line 1015 "y.tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/y.tab.h b/y.tab.h @@ -0,0 +1,33 @@ +#define ANDAND 257 +#define BACKBACK 258 +#define BANG 259 +#define CASE 260 +#define COUNT 261 +#define DUP 262 +#define ELSE 263 +#define END 264 +#define FLAT 265 +#define FN 266 +#define FOR 267 +#define IF 268 +#define IN 269 +#define OROR 270 +#define PIPE 271 +#define REDIR 272 +#define SREDIR 273 +#define SUB 274 +#define SUBSHELL 275 +#define SWITCH 276 +#define TWIDDLE 277 +#define WHILE 278 +#define WORD 279 +#define HUH 280 +typedef union { + struct Node *node; + struct Redir redir; + struct Pipe pipe; + struct Dup dup; + struct Word word; + char *keyword; +} YYSTYPE; +extern YYSTYPE yylval;