Tue Jan 22 22:40:31 2013 UTC ()
fix compilation without -DEDIT


(christos)
diff -r1.34 -r1.35 src/bin/csh/Makefile
diff -r1.23 -r1.24 src/bin/csh/csh.h

cvs diff -r1.34 -r1.35 src/bin/csh/Makefile (switch to unified diff)

--- src/bin/csh/Makefile 2013/01/22 20:35:29 1.34
+++ src/bin/csh/Makefile 2013/01/22 22:40:31 1.35
@@ -1,72 +1,72 @@ @@ -1,72 +1,72 @@
1# $NetBSD: Makefile,v 1.34 2013/01/22 20:35:29 christos Exp $ 1# $NetBSD: Makefile,v 1.35 2013/01/22 22:40:31 christos Exp $
2# @(#)Makefile 8.1 (Berkeley) 5/31/93 2# @(#)Makefile 8.1 (Berkeley) 5/31/93
3# 3#
4# C Shell with process control; VM/UNIX VAX Makefile 4# C Shell with process control; VM/UNIX VAX Makefile
5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria 5# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
6# 6#
7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile. 7# To profile, put -DPROF in DFLAGS and -pg in COPTS, and recompile.
8 8
9.include <bsd.own.mk> 9.include <bsd.own.mk>
10 10
11PROG= csh 11PROG= csh
12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS 12DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
13# - Not integrated with history 13# - Not integrated with history
14# - Does not handle escaped prompts. 14# - Does not handle escaped prompts.
15# - Does not do completion 15# - Does not do completion
16# DFLAGS+=-DEDIT 16# DFLAGS+=-DEDIT
17CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS} 17CPPFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
18SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \ 18SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
19 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \ 19 func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
20 sem.c set.c str.c time.c 20 sem.c set.c str.c time.c
21.PATH: ${NETBSDSRCDIR}/usr.bin/printf 21.PATH: ${NETBSDSRCDIR}/usr.bin/printf
22 22
23MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \ 23MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
24 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \ 24 csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
25 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \ 25 csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
26 csh.1 stop.1 csh.1 source.1 26 csh.1 stop.1 csh.1 source.1
27 27
28DPSRCS+= errnum.h const.h 28DPSRCS+= errnum.h const.h
29CLEANFILES+= errnum.h const.h 29CLEANFILES+= errnum.h const.h
30 30
31errnum.h: err.c 31errnum.h: err.c
32 ${_MKTARGET_CREATE} 32 ${_MKTARGET_CREATE}
33 rm -f ${.TARGET} 33 rm -f ${.TARGET}
34 (\ 34 (\
35 echo '/* Do not edit this file, make creates it. */' ;\ 35 echo '/* Do not edit this file, make creates it. */' ;\
36 echo '#ifndef _h_sh_errnum' ;\ 36 echo '#ifndef _h_sh_errnum' ;\
37 echo '#define _h_sh_errnum' ;\ 37 echo '#define _h_sh_errnum' ;\
38 egrep 'ERR_' ${.ALLSRC} | egrep '^#define' ;\ 38 egrep 'ERR_' ${.ALLSRC} | egrep '^#define' ;\
39 echo '#endif /* _h_sh_errnum */' ;\ 39 echo '#endif /* _h_sh_errnum */' ;\
40 ) > ${.TARGET} 40 ) > ${.TARGET}
41 41
42const.c: errnum.h 42const.c: errnum.h
43const.h: const.c 43const.h: const.c
44 ${_MKTARGET_CREATE} 44 ${_MKTARGET_CREATE}
45 rm -f ${.TARGET} 45 rm -f ${.TARGET}
46 echo '/* Do not edit this file, make creates it. */' > ${.TARGET} 46 echo '/* Do not edit this file, make creates it. */' > ${.TARGET}
47 ${CC} -E ${CPPFLAGS} ${.ALLSRC} | egrep 'Char STR' | \ 47 ${CC} -E ${CPPFLAGS} ${.ALLSRC} | egrep 'Char STR' | \
48 ${TOOL_SED} -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \ 48 ${TOOL_SED} -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
49 sort >> ${.TARGET} 49 sort >> ${.TARGET}
50 50
51.if make(install) 51.if make(install)
52SUBDIR+=USD.doc 52SUBDIR+=USD.doc
53.endif 53.endif
54 54
55# XXX Only GCC 4.1 problem 55# XXX Only GCC 4.1 problem
56.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax" 56.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax"
57COPTS.parse.c+= -O0 57COPTS.parse.c+= -O0
58.endif 58.endif
59COPTS.err.c = -Wno-format-nonliteral 59COPTS.err.c = -Wno-format-nonliteral
60COPTS.printf.c = -Wno-format-nonliteral 60COPTS.printf.c = -Wno-format-nonliteral
61COPTS.proc.c = -Wno-format-nonliteral 61COPTS.proc.c = -Wno-format-nonliteral
62 62
63.if 0 63.if 0
64LDADD+=-lutil 
65DPADD+=${LIBUTIL} 
66.elese 
67LDADD+=-ledit -lutil 64LDADD+=-ledit -lutil
68DPADD+=${LIBEDIT} ${LIBUTIL} 65DPADD+=${LIBEDIT} ${LIBUTIL}
 66.else
 67LDADD+=-lutil
 68DPADD+=${LIBUTIL}
69.endif 69.endif
70 70
71.include <bsd.prog.mk> 71.include <bsd.prog.mk>
72.include <bsd.subdir.mk> 72.include <bsd.subdir.mk>

cvs diff -r1.23 -r1.24 src/bin/csh/csh.h (switch to unified diff)

--- src/bin/csh/csh.h 2013/01/22 20:35:29 1.23
+++ src/bin/csh/csh.h 2013/01/22 22:40:31 1.24
@@ -1,558 +1,558 @@ @@ -1,558 +1,558 @@
1/* $NetBSD: csh.h,v 1.23 2013/01/22 20:35:29 christos Exp $ */ 1/* $NetBSD: csh.h,v 1.24 2013/01/22 22:40:31 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1980, 1991, 1993 4 * Copyright (c) 1980, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors 15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software 16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission. 17 * without specific prior written permission.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 * 30 *
31 * @(#)csh.h 8.1 (Berkeley) 5/31/93 31 * @(#)csh.h 8.1 (Berkeley) 5/31/93
32 */ 32 */
33 33
34#ifndef _CSH_H_ 34#ifndef _CSH_H_
35#define _CSH_H_ 35#define _CSH_H_
36 36
37/* 37/*
38 * Fundamental definitions which may vary from system to system. 38 * Fundamental definitions which may vary from system to system.
39 * 39 *
40 * BUFSIZE The i/o buffering size; also limits word size 40 * BUFSIZE The i/o buffering size; also limits word size
41 * MAILINTVL How often to mailcheck; more often is more expensive 41 * MAILINTVL How often to mailcheck; more often is more expensive
42 */ 42 */
43#ifndef BUFSIZE 43#ifndef BUFSIZE
44#define BUFSIZE 4096 /* default buffer size */ 44#define BUFSIZE 4096 /* default buffer size */
45#endif /* BUFSIZE */ 45#endif /* BUFSIZE */
46 46
47#define FORKSLEEP 10 /* delay loop on non-interactive fork failure */ 47#define FORKSLEEP 10 /* delay loop on non-interactive fork failure */
48#define MAILINTVL 600 /* 10 minutes */ 48#define MAILINTVL 600 /* 10 minutes */
49 49
50/* 50/*
51 * The shell moves std in/out/diag and the old std input away from units 51 * The shell moves std in/out/diag and the old std input away from units
52 * 0, 1, and 2 so that it is easy to set up these standards for invoked 52 * 0, 1, and 2 so that it is easy to set up these standards for invoked
53 * commands. 53 * commands.
54 */ 54 */
55#define FSHTTY 15 /* /dev/tty when manip pgrps */ 55#define FSHTTY 15 /* /dev/tty when manip pgrps */
56#define FSHIN 16 /* Preferred desc for shell input */ 56#define FSHIN 16 /* Preferred desc for shell input */
57#define FSHOUT 17 /* ... shell output */ 57#define FSHOUT 17 /* ... shell output */
58#define FSHERR 18 /* ... shell diagnostics */ 58#define FSHERR 18 /* ... shell diagnostics */
59#define FOLDSTD 19 /* ... old std input */ 59#define FOLDSTD 19 /* ... old std input */
60 60
61#ifdef PROF 61#ifdef PROF
62#define xexit(n) done(n) 62#define xexit(n) done(n)
63#endif 63#endif
64 64
65#ifdef SHORT_STRINGS 65#ifdef SHORT_STRINGS
66typedef short Char; 66typedef short Char;
67 67
68#define SAVE(a) (Strsave(str2short(a))) 68#define SAVE(a) (Strsave(str2short(a)))
69#else 69#else
70typedef char Char; 70typedef char Char;
71 71
72#define SAVE(a) (strsave(a)) 72#define SAVE(a) (strsave(a))
73#endif 73#endif
74 74
75/* 75/*
76 * Make sure a variable is not stored in a register by taking its address 76 * Make sure a variable is not stored in a register by taking its address
77 * This is used where variables might be clobbered by longjmp. 77 * This is used where variables might be clobbered by longjmp.
78 */ 78 */
79#define UNREGISTER(a) (void) &a 79#define UNREGISTER(a) (void) &a
80 80
81typedef void *ioctl_t; /* Third arg of ioctl */ 81typedef void *ioctl_t; /* Third arg of ioctl */
82 82
83typedef void *ptr_t; 83typedef void *ptr_t;
84 84
85#include "const.h" 85#include "const.h"
86#include "char.h" 86#include "char.h"
87#include "errnum.h" 87#include "errnum.h"
88 88
89#define xmalloc(i) Malloc(i) 89#define xmalloc(i) Malloc(i)
90#define xrealloc(p, i) Realloc(p, i) 90#define xrealloc(p, i) Realloc(p, i)
91#define xcalloc(n, s) Calloc(n, s) 91#define xcalloc(n, s) Calloc(n, s)
92#define xfree(p) Free(p) 92#define xfree(p) Free(p)
93 93
94#include <stdio.h> 94#include <stdio.h>
95FILE *cshin, *cshout, *csherr; 95FILE *cshin, *cshout, *csherr;
96 96
97#define isdir(d) (S_ISDIR(d.st_mode)) 97#define isdir(d) (S_ISDIR(d.st_mode))
98 98
99#define eq(a, b) (Strcmp(a, b) == 0) 99#define eq(a, b) (Strcmp(a, b) == 0)
100 100
101/* globone() flags */ 101/* globone() flags */
102#define G_ERROR 0 /* default action: error if multiple words */ 102#define G_ERROR 0 /* default action: error if multiple words */
103#define G_IGNORE 1 /* ignore the rest of the words */ 103#define G_IGNORE 1 /* ignore the rest of the words */
104#define G_APPEND 2 /* make a sentence by cat'ing the words */ 104#define G_APPEND 2 /* make a sentence by cat'ing the words */
105 105
106/* 106/*
107 * Global flags 107 * Global flags
108 */ 108 */
109int child; /* Child shell ... errors cause exit */ 109int child; /* Child shell ... errors cause exit */
110int chkstop; /* Warned of stopped jobs... allow exit */ 110int chkstop; /* Warned of stopped jobs... allow exit */
111int didfds; /* Have setup i/o fd's for child */ 111int didfds; /* Have setup i/o fd's for child */
112int doneinp; /* EOF indicator after reset from readc */ 112int doneinp; /* EOF indicator after reset from readc */
113int exiterr; /* Exit if error or non-zero exit status */ 113int exiterr; /* Exit if error or non-zero exit status */
114int haderr; /* Reset was because of an error */ 114int haderr; /* Reset was because of an error */
115int havhash; /* path hashing is available */ 115int havhash; /* path hashing is available */
116int intact; /* We are interactive... therefore prompt */ 116int intact; /* We are interactive... therefore prompt */
117int intty; /* Input is a tty */ 117int intty; /* Input is a tty */
118int justpr; /* Just print because of :p hist mod */ 118int justpr; /* Just print because of :p hist mod */
119int loginsh; /* We are a loginsh -> .login/.logout */ 119int loginsh; /* We are a loginsh -> .login/.logout */
120int neednote; /* Need to pnotify() */ 120int neednote; /* Need to pnotify() */
121int noexec; /* Don't execute, just syntax check */ 121int noexec; /* Don't execute, just syntax check */
122int pjobs; /* want to print jobs if interrupted */ 122int pjobs; /* want to print jobs if interrupted */
123int setintr; /* Set interrupts on/off -> Wait intr... */ 123int setintr; /* Set interrupts on/off -> Wait intr... */
124int timflg; /* Time the next waited for command */ 124int timflg; /* Time the next waited for command */
125 125
126#ifdef FILEC 126#ifdef FILEC
127extern int filec; /* doing filename expansion */ 127extern int filec; /* doing filename expansion */
128#endif 128#endif
129 129
130/* 130/*
131 * Global i/o info 131 * Global i/o info
132 */ 132 */
133Char *arginp; /* Argument input for sh -c and internal `xx` */ 133Char *arginp; /* Argument input for sh -c and internal `xx` */
134Char *ffile; /* Name of shell file for $0 */ 134Char *ffile; /* Name of shell file for $0 */
135int onelflg; /* 2 -> need line for -t, 1 -> exit on read */ 135int onelflg; /* 2 -> need line for -t, 1 -> exit on read */
136 136
137extern char *seterr; /* Error message from scanner/parser */ 137extern char *seterr; /* Error message from scanner/parser */
138Char *shtemp; /* Temp name for << shell files in /tmp */ 138Char *shtemp; /* Temp name for << shell files in /tmp */
139 139
140#include <sys/resource.h> 140#include <sys/resource.h>
141#include <sys/time.h> 141#include <sys/time.h>
142#include <sys/types.h> 142#include <sys/types.h>
143 143
144struct timespec time0; /* Time at which the shell started */ 144struct timespec time0; /* Time at which the shell started */
145struct rusage ru0; 145struct rusage ru0;
146 146
147/* 147/*
148 * Miscellany 148 * Miscellany
149 */ 149 */
150time_t chktim; /* Time mail last checked */ 150time_t chktim; /* Time mail last checked */
151Char *doldol; /* Character pid for $$ */ 151Char *doldol; /* Character pid for $$ */
152int backpid; /* Pid of the last background process */ 152int backpid; /* Pid of the last background process */
153int egid, gid; /* Invokers gid */ 153int egid, gid; /* Invokers gid */
154int euid, uid; /* Invokers uid */ 154int euid, uid; /* Invokers uid */
155int shpgrp; /* Pgrp of shell */ 155int shpgrp; /* Pgrp of shell */
156int tpgrp; /* Terminal process group */ 156int tpgrp; /* Terminal process group */
157 157
158/* If tpgrp is -1, leave tty alone! */ 158/* If tpgrp is -1, leave tty alone! */
159int opgrp; /* Initial pgrp and tty pgrp */ 159int opgrp; /* Initial pgrp and tty pgrp */
160 160
161 161
162/* 162/*
163 * To be able to redirect i/o for builtins easily, the shell moves the i/o 163 * To be able to redirect i/o for builtins easily, the shell moves the i/o
164 * descriptors it uses away from 0,1,2. 164 * descriptors it uses away from 0,1,2.
165 * Ideally these should be in units which are closed across exec's 165 * Ideally these should be in units which are closed across exec's
166 * (this saves work) but for version 6, this is not usually possible. 166 * (this saves work) but for version 6, this is not usually possible.
167 * The desired initial values for these descriptors are F{SHIN,...}. 167 * The desired initial values for these descriptors are F{SHIN,...}.
168 */ 168 */
169int SHIN; /* Current shell input (script) */ 169int SHIN; /* Current shell input (script) */
170int SHOUT; /* Shell output */ 170int SHOUT; /* Shell output */
171int SHERR; /* Diagnostic output... shell errs go here */ 171int SHERR; /* Diagnostic output... shell errs go here */
172int OLDSTD; /* Old standard input (def for cmds) */ 172int OLDSTD; /* Old standard input (def for cmds) */
173 173
174/* 174/*
175 * Error control 175 * Error control
176 * 176 *
177 * Errors in scanning and parsing set up an error message to be printed 177 * Errors in scanning and parsing set up an error message to be printed
178 * at the end and complete. Other errors always cause a reset. 178 * at the end and complete. Other errors always cause a reset.
179 * Because of source commands and .cshrc we need nested error catches. 179 * Because of source commands and .cshrc we need nested error catches.
180 */ 180 */
181 181
182#include <setjmp.h> 182#include <setjmp.h>
183jmp_buf reslab; 183jmp_buf reslab;
184 184
185#define setexit() (setjmp(reslab)) 185#define setexit() (setjmp(reslab))
186#define reset() longjmp(reslab, 1) 186#define reset() longjmp(reslab, 1)
187 /* Should use structure assignment here */ 187 /* Should use structure assignment here */
188#define getexit(a) (void)memcpy((a), reslab, sizeof reslab) 188#define getexit(a) (void)memcpy((a), reslab, sizeof reslab)
189#define resexit(a) (void)memcpy(reslab, (a), sizeof reslab) 189#define resexit(a) (void)memcpy(reslab, (a), sizeof reslab)
190 190
191Char *gointr; /* Label for an onintr transfer */ 191Char *gointr; /* Label for an onintr transfer */
192 192
193#include <signal.h> 193#include <signal.h>
194sig_t parintr; /* Parents interrupt catch */ 194sig_t parintr; /* Parents interrupt catch */
195sig_t parterm; /* Parents terminate catch */ 195sig_t parterm; /* Parents terminate catch */
196 196
197/* 197/*
198 * Lexical definitions. 198 * Lexical definitions.
199 * 199 *
200 * All lexical space is allocated dynamically. 200 * All lexical space is allocated dynamically.
201 * The eighth/sixteenth bit of characters is used to prevent recognition, 201 * The eighth/sixteenth bit of characters is used to prevent recognition,
202 * and eventually stripped. 202 * and eventually stripped.
203 */ 203 */
204#define META 0200 204#define META 0200
205#define ASCII 0177 205#define ASCII 0177
206#ifdef SHORT_STRINGS 206#ifdef SHORT_STRINGS
207#define CHAR 0377 207#define CHAR 0377
208#define QUOTE 0100000 /* 16nth char bit used for 'ing */ 208#define QUOTE 0100000 /* 16nth char bit used for 'ing */
209#define TRIM 0077777 /* Mask to strip quote bit */ 209#define TRIM 0077777 /* Mask to strip quote bit */
210#else 210#else
211#define CHAR 0177 211#define CHAR 0177
212#define QUOTE 0200 /* Eighth char bit used for 'ing */ 212#define QUOTE 0200 /* Eighth char bit used for 'ing */
213#define TRIM 0177 /* Mask to strip quote bit */ 213#define TRIM 0177 /* Mask to strip quote bit */
214#endif 214#endif
215 215
216int AsciiOnly; /* If set only 7 bits is expected in characters */ 216int AsciiOnly; /* If set only 7 bits is expected in characters */
217 217
218/* 218/*
219 * Each level of input has a buffered input structure. 219 * Each level of input has a buffered input structure.
220 * There are one or more blocks of buffered input for each level, 220 * There are one or more blocks of buffered input for each level,
221 * exactly one if the input is seekable and tell is available. 221 * exactly one if the input is seekable and tell is available.
222 * In other cases, the shell buffers enough blocks to keep all loops 222 * In other cases, the shell buffers enough blocks to keep all loops
223 * in the buffer. 223 * in the buffer.
224 */ 224 */
225struct Bin { 225struct Bin {
226 off_t Bfseekp; /* Seek pointer */ 226 off_t Bfseekp; /* Seek pointer */
227 off_t Bfbobp; /* Seekp of beginning of buffers */ 227 off_t Bfbobp; /* Seekp of beginning of buffers */
228 off_t Bfeobp; /* Seekp of end of buffers */ 228 off_t Bfeobp; /* Seekp of end of buffers */
229 int Bfblocks; /* Number of buffer blocks */ 229 int Bfblocks; /* Number of buffer blocks */
230 Char **Bfbuf; /* The array of buffer blocks */ 230 Char **Bfbuf; /* The array of buffer blocks */
231} B; 231} B;
232 232
233/* 233/*
234 * This structure allows us to seek inside aliases 234 * This structure allows us to seek inside aliases
235 */ 235 */
236struct Ain { 236struct Ain {
237 int type; 237 int type;
238#define I_SEEK -1 /* Invalid seek */ 238#define I_SEEK -1 /* Invalid seek */
239#define A_SEEK 0 /* Alias seek */ 239#define A_SEEK 0 /* Alias seek */
240#define F_SEEK 1 /* File seek */ 240#define F_SEEK 1 /* File seek */
241#define E_SEEK 2 /* Eval seek */ 241#define E_SEEK 2 /* Eval seek */
242 union { 242 union {
243 off_t _f_seek; 243 off_t _f_seek;
244 Char* _c_seek; 244 Char* _c_seek;
245 } fc; 245 } fc;
246#define f_seek fc._f_seek 246#define f_seek fc._f_seek
247#define c_seek fc._c_seek 247#define c_seek fc._c_seek
248 Char **a_seek; 248 Char **a_seek;
249} ; 249} ;
250extern int aret; /* What was the last character returned */ 250extern int aret; /* What was the last character returned */
251#define SEEKEQ(a, b) ((a)->type == (b)->type && \ 251#define SEEKEQ(a, b) ((a)->type == (b)->type && \
252 (a)->f_seek == (b)->f_seek && \ 252 (a)->f_seek == (b)->f_seek && \
253 (a)->a_seek == (b)->a_seek) 253 (a)->a_seek == (b)->a_seek)
254 254
255#define fseekp B.Bfseekp 255#define fseekp B.Bfseekp
256#define fbobp B.Bfbobp 256#define fbobp B.Bfbobp
257#define feobp B.Bfeobp 257#define feobp B.Bfeobp
258#define fblocks B.Bfblocks 258#define fblocks B.Bfblocks
259#define fbuf B.Bfbuf 259#define fbuf B.Bfbuf
260 260
261/* 261/*
262 * The shell finds commands in loops by reseeking the input 262 * The shell finds commands in loops by reseeking the input
263 * For whiles, in particular, it reseeks to the beginning of the 263 * For whiles, in particular, it reseeks to the beginning of the
264 * line the while was on; hence the while placement restrictions. 264 * line the while was on; hence the while placement restrictions.
265 */ 265 */
266struct Ain lineloc; 266struct Ain lineloc;
267 267
268int cantell; /* Is current source tellable ? */ 268int cantell; /* Is current source tellable ? */
269 269
270/* 270/*
271 * Input lines are parsed into doubly linked circular 271 * Input lines are parsed into doubly linked circular
272 * lists of words of the following form. 272 * lists of words of the following form.
273 */ 273 */
274struct wordent { 274struct wordent {
275 Char *word; 275 Char *word;
276 struct wordent *prev; 276 struct wordent *prev;
277 struct wordent *next; 277 struct wordent *next;
278}; 278};
279 279
280/* 280/*
281 * During word building, both in the initial lexical phase and 281 * During word building, both in the initial lexical phase and
282 * when expanding $ variable substitutions, expansion by `!' and `$' 282 * when expanding $ variable substitutions, expansion by `!' and `$'
283 * must be inhibited when reading ahead in routines which are themselves 283 * must be inhibited when reading ahead in routines which are themselves
284 * processing `!' and `$' expansion or after characters such as `\' or in 284 * processing `!' and `$' expansion or after characters such as `\' or in
285 * quotations. The following flags are passed to the getC routines 285 * quotations. The following flags are passed to the getC routines
286 * telling them which of these substitutions are appropriate for the 286 * telling them which of these substitutions are appropriate for the
287 * next character to be returned. 287 * next character to be returned.
288 */ 288 */
289#define DODOL 1 289#define DODOL 1
290#define DOEXCL 2 290#define DOEXCL 2
291#define DOALL DODOL|DOEXCL 291#define DOALL DODOL|DOEXCL
292 292
293/* 293/*
294 * Labuf implements a general buffer for lookahead during lexical operations. 294 * Labuf implements a general buffer for lookahead during lexical operations.
295 * Text which is to be placed in the input stream can be stuck here. 295 * Text which is to be placed in the input stream can be stuck here.
296 * We stick parsed ahead $ constructs during initial input, 296 * We stick parsed ahead $ constructs during initial input,
297 * process id's from `$$', and modified variable values (from qualifiers 297 * process id's from `$$', and modified variable values (from qualifiers
298 * during expansion in sh.dol.c) here. 298 * during expansion in sh.dol.c) here.
299 */ 299 */
300Char *lap; 300Char *lap;
301 301
302/* 302/*
303 * Parser structure 303 * Parser structure
304 * 304 *
305 * Each command is parsed to a tree of command structures and 305 * Each command is parsed to a tree of command structures and
306 * flags are set bottom up during this process, to be propagated down 306 * flags are set bottom up during this process, to be propagated down
307 * as needed during the semantics/execution pass (sh.sem.c). 307 * as needed during the semantics/execution pass (sh.sem.c).
308 */ 308 */
309struct command { 309struct command {
310 short t_dtyp; /* Type of node */ 310 short t_dtyp; /* Type of node */
311#define NODE_COMMAND 1 /* t_dcom <t_dlef >t_drit */ 311#define NODE_COMMAND 1 /* t_dcom <t_dlef >t_drit */
312#define NODE_PAREN 2 /* ( t_dspr ) <t_dlef >t_drit */ 312#define NODE_PAREN 2 /* ( t_dspr ) <t_dlef >t_drit */
313#define NODE_PIPE 3 /* t_dlef | t_drit */ 313#define NODE_PIPE 3 /* t_dlef | t_drit */
314#define NODE_LIST 4 /* t_dlef ; t_drit */ 314#define NODE_LIST 4 /* t_dlef ; t_drit */
315#define NODE_OR 5 /* t_dlef || t_drit */ 315#define NODE_OR 5 /* t_dlef || t_drit */
316#define NODE_AND 6 /* t_dlef && t_drit */ 316#define NODE_AND 6 /* t_dlef && t_drit */
317 short t_dflg; /* Flags, e.g. F_AMPERSAND|... */ 317 short t_dflg; /* Flags, e.g. F_AMPERSAND|... */
318#define F_SAVE (F_NICE|F_TIME|F_NOHUP) /* save these when re-doing */ 318#define F_SAVE (F_NICE|F_TIME|F_NOHUP) /* save these when re-doing */
319 319
320#define F_AMPERSAND (1<<0) /* executes in background */ 320#define F_AMPERSAND (1<<0) /* executes in background */
321#define F_APPEND (1<<1) /* output is redirected >> */ 321#define F_APPEND (1<<1) /* output is redirected >> */
322#define F_PIPEIN (1<<2) /* input is a pipe */ 322#define F_PIPEIN (1<<2) /* input is a pipe */
323#define F_PIPEOUT (1<<3) /* output is a pipe */ 323#define F_PIPEOUT (1<<3) /* output is a pipe */
324#define F_NOFORK (1<<4) /* don't fork, last ()ized cmd */ 324#define F_NOFORK (1<<4) /* don't fork, last ()ized cmd */
325#define F_NOINTERRUPT (1<<5) /* should be immune from intr's */ 325#define F_NOINTERRUPT (1<<5) /* should be immune from intr's */
326/* spare */ 326/* spare */
327#define F_STDERR (1<<7) /* redirect unit 2 with unit 1 */ 327#define F_STDERR (1<<7) /* redirect unit 2 with unit 1 */
328#define F_OVERWRITE (1<<8) /* output was ! */ 328#define F_OVERWRITE (1<<8) /* output was ! */
329#define F_READ (1<<9) /* input redirection is << */ 329#define F_READ (1<<9) /* input redirection is << */
330#define F_REPEAT (1<<10) /* reexec aft if, repeat,... */ 330#define F_REPEAT (1<<10) /* reexec aft if, repeat,... */
331#define F_NICE (1<<11) /* t_nice is meaningful */ 331#define F_NICE (1<<11) /* t_nice is meaningful */
332#define F_NOHUP (1<<12) /* nohup this command */ 332#define F_NOHUP (1<<12) /* nohup this command */
333#define F_TIME (1<<13) /* time this command */ 333#define F_TIME (1<<13) /* time this command */
334 union { 334 union {
335 Char *T_dlef; /* Input redirect word */ 335 Char *T_dlef; /* Input redirect word */
336 struct command *T_dcar; /* Left part of list/pipe */ 336 struct command *T_dcar; /* Left part of list/pipe */
337 } L; 337 } L;
338 union { 338 union {
339 Char *T_drit; /* Output redirect word */ 339 Char *T_drit; /* Output redirect word */
340 struct command *T_dcdr; /* Right part of list/pipe */ 340 struct command *T_dcdr; /* Right part of list/pipe */
341 } R; 341 } R;
342#define t_dlef L.T_dlef 342#define t_dlef L.T_dlef
343#define t_dcar L.T_dcar 343#define t_dcar L.T_dcar
344#define t_drit R.T_drit 344#define t_drit R.T_drit
345#define t_dcdr R.T_dcdr 345#define t_dcdr R.T_dcdr
346 Char **t_dcom; /* Command/argument vector */ 346 Char **t_dcom; /* Command/argument vector */
347 struct command *t_dspr; /* Pointer to ()'d subtree */ 347 struct command *t_dspr; /* Pointer to ()'d subtree */
348 int t_nice; 348 int t_nice;
349}; 349};
350 350
351 351
352/* 352/*
353 * These are declared here because they want to be 353 * These are declared here because they want to be
354 * initialized in sh.init.c (to allow them to be made readonly) 354 * initialized in sh.init.c (to allow them to be made readonly)
355 */ 355 */
356 356
357extern struct biltins { 357extern struct biltins {
358 const char *bname; 358 const char *bname;
359 void (*bfunct)(Char **, struct command *); 359 void (*bfunct)(Char **, struct command *);
360 short minargs, maxargs; 360 short minargs, maxargs;
361} bfunc[]; 361} bfunc[];
362 362
363extern int nbfunc; 363extern int nbfunc;
364extern int nsrchn; 364extern int nsrchn;
365 365
366extern struct srch { 366extern struct srch {
367 const char *s_name; 367 const char *s_name;
368 short s_value; 368 short s_value;
369} srchn[]; 369} srchn[];
370 370
371/* 371/*
372 * The keywords for the parser 372 * The keywords for the parser
373 */ 373 */
374#define T_BREAK 0 374#define T_BREAK 0
375#define T_BRKSW 1 375#define T_BRKSW 1
376#define T_CASE 2 376#define T_CASE 2
377#define T_DEFAULT 3 377#define T_DEFAULT 3
378#define T_ELSE 4 378#define T_ELSE 4
379#define T_END 5 379#define T_END 5
380#define T_ENDIF 6 380#define T_ENDIF 6
381#define T_ENDSW 7 381#define T_ENDSW 7
382#define T_EXIT 8 382#define T_EXIT 8
383#define T_FOREACH 9 383#define T_FOREACH 9
384#define T_GOTO 10 384#define T_GOTO 10
385#define T_IF 11 385#define T_IF 11
386#define T_LABEL 12 386#define T_LABEL 12
387#define T_LET 13 387#define T_LET 13
388#define T_SET 14 388#define T_SET 14
389#define T_SWITCH 15 389#define T_SWITCH 15
390#define T_TEST 16 390#define T_TEST 16
391#define T_THEN 17 391#define T_THEN 17
392#define T_WHILE 18 392#define T_WHILE 18
393 393
394/* 394/*
395 * Structure defining the existing while/foreach loops at this 395 * Structure defining the existing while/foreach loops at this
396 * source level. Loops are implemented by seeking back in the 396 * source level. Loops are implemented by seeking back in the
397 * input. For foreach (fe), the word list is attached here. 397 * input. For foreach (fe), the word list is attached here.
398 */ 398 */
399struct whyle { 399struct whyle {
400 struct Ain w_start; /* Point to restart loop */ 400 struct Ain w_start; /* Point to restart loop */
401 struct Ain w_end; /* End of loop (0 if unknown) */ 401 struct Ain w_end; /* End of loop (0 if unknown) */
402 Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */ 402 Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
403 Char *w_fename; /* Name for fe */ 403 Char *w_fename; /* Name for fe */
404 struct whyle *w_next; /* Next (more outer) loop */ 404 struct whyle *w_next; /* Next (more outer) loop */
405} *whyles; 405} *whyles;
406 406
407/* 407/*
408 * Variable structure 408 * Variable structure
409 * 409 *
410 * Aliases and variables are stored in AVL balanced binary trees. 410 * Aliases and variables are stored in AVL balanced binary trees.
411 */ 411 */
412struct varent { 412struct varent {
413 Char **vec; /* Array of words which is the value */ 413 Char **vec; /* Array of words which is the value */
414 Char *v_name; /* Name of variable/alias */ 414 Char *v_name; /* Name of variable/alias */
415 struct varent *v_link[3]; /* The links, see below */ 415 struct varent *v_link[3]; /* The links, see below */
416 int v_bal; /* Balance factor */ 416 int v_bal; /* Balance factor */
417} shvhed, aliases; 417} shvhed, aliases;
418 418
419#define v_left v_link[0] 419#define v_left v_link[0]
420#define v_right v_link[1] 420#define v_right v_link[1]
421#define v_parent v_link[2] 421#define v_parent v_link[2]
422 422
423#define adrof(v) adrof1(v, &shvhed) 423#define adrof(v) adrof1(v, &shvhed)
424#define value(v) value1(v, &shvhed) 424#define value(v) value1(v, &shvhed)
425 425
426/* 426/*
427 * The following are for interfacing redo substitution in 427 * The following are for interfacing redo substitution in
428 * aliases to the lexical routines. 428 * aliases to the lexical routines.
429 */ 429 */
430struct wordent *alhistp; /* Argument list (first) */ 430struct wordent *alhistp; /* Argument list (first) */
431struct wordent *alhistt; /* Node after last in arg list */ 431struct wordent *alhistt; /* Node after last in arg list */
432extern Char **alvec, *alvecp; /* The (remnants of) alias vector */ 432extern Char **alvec, *alvecp; /* The (remnants of) alias vector */
433 433
434/* 434/*
435 * Filename/command name expansion variables 435 * Filename/command name expansion variables
436 */ 436 */
437int gflag; /* After tglob -> is globbing needed? */ 437int gflag; /* After tglob -> is globbing needed? */
438 438
439#define MAXVARLEN 30 /* Maximum number of char in a variable name */ 439#define MAXVARLEN 30 /* Maximum number of char in a variable name */
440 440
441/* 441/*
442 * Variables for filename expansion 442 * Variables for filename expansion
443 */ 443 */
444extern long gargc; /* Number args in gargv */ 444extern long gargc; /* Number args in gargv */
445extern Char **gargv; /* Pointer to the (stack) arglist */ 445extern Char **gargv; /* Pointer to the (stack) arglist */
446 446
447/* 447/*
448 * Variables for command expansion. 448 * Variables for command expansion.
449 */ 449 */
450extern Char **pargv; /* Pointer to the argv list space */ 450extern Char **pargv; /* Pointer to the argv list space */
451extern long pargc; /* Count of arguments in pargv */ 451extern long pargc; /* Count of arguments in pargv */
452long pnleft; /* Number of chars left in pargs */ 452long pnleft; /* Number of chars left in pargs */
453Char *pargs; /* Pointer to start current word */ 453Char *pargs; /* Pointer to start current word */
454Char *pargcp; /* Current index into pargs */ 454Char *pargcp; /* Current index into pargs */
455 455
456/* 456/*
457 * History list 457 * History list
458 * 458 *
459 * Each history list entry contains an embedded wordlist 459 * Each history list entry contains an embedded wordlist
460 * from the scanner, a number for the event, and a reference count 460 * from the scanner, a number for the event, and a reference count
461 * to aid in discarding old entries. 461 * to aid in discarding old entries.
462 * 462 *
463 * Essentially "invisible" entries are put on the history list 463 * Essentially "invisible" entries are put on the history list
464 * when history substitution includes modifiers, and thrown away 464 * when history substitution includes modifiers, and thrown away
465 * at the next discarding since their event numbers are very negative. 465 * at the next discarding since their event numbers are very negative.
466 */ 466 */
467struct Hist { 467struct Hist {
468 struct wordent Hlex; 468 struct wordent Hlex;
469 int Hnum; 469 int Hnum;
470 int Href; 470 int Href;
471 struct Hist *Hnext; 471 struct Hist *Hnext;
472} Histlist; 472} Histlist;
473 473
474struct wordent paraml; /* Current lexical word list */ 474struct wordent paraml; /* Current lexical word list */
475int eventno; /* Next events number */ 475int eventno; /* Next events number */
476int lastev; /* Last event reference (default) */ 476int lastev; /* Last event reference (default) */
477 477
478Char HIST; /* history invocation character */ 478Char HIST; /* history invocation character */
479Char HISTSUB; /* auto-substitute character */ 479Char HISTSUB; /* auto-substitute character */
480 480
481/* 481/*
482 * strings.h: 482 * strings.h:
483 */ 483 */
484#ifndef SHORT_STRINGS 484#ifndef SHORT_STRINGS
485#define Strchr(a, b) strchr(a, b) 485#define Strchr(a, b) strchr(a, b)
486#define Strrchr(a, b) strrchr(a, b) 486#define Strrchr(a, b) strrchr(a, b)
487#define Strcat(a, b) strcat(a, b) 487#define Strcat(a, b) strcat(a, b)
488#define Strncat(a, b, c) strncat(a, b, c) 488#define Strncat(a, b, c) strncat(a, b, c)
489#define Strcpy(a, b) strcpy(a, b) 489#define Strcpy(a, b) strcpy(a, b)
490#define Strncpy(a, b, c) strncpy(a, b, c) 490#define Strncpy(a, b, c) strncpy(a, b, c)
491#define Strlen(a) strlen(a) 491#define Strlen(a) strlen(a)
492#define Strcmp(a, b) strcmp(a, b) 492#define Strcmp(a, b) strcmp(a, b)
493#define Strncmp(a, b, c) strncmp(a, b, c) 493#define Strncmp(a, b, c) strncmp(a, b, c)
494 494
495#define Strspl(a, b) strspl(a, b) 495#define Strspl(a, b) strspl(a, b)
496#define Strsave(a) strsave(a) 496#define Strsave(a) strsave(a)
497#define Strend(a) strend(a) 497#define Strend(a) strend(a)
498#define Strstr(a, b) strstr(a, b) 498#define Strstr(a, b) strstr(a, b)
499 499
500#define str2short(a) (a) 500#define str2short(a) (a)
501#define blk2short(a) saveblk(a) 501#define blk2short(a) saveblk(a)
502#define short2blk(a) saveblk(a) 502#define short2blk(a) saveblk(a)
503#define short2str(a) strip(a) 503#define short2str(a) strip(a)
504#else 504#else
505#define Strchr(a, b) s_strchr(a, b) 505#define Strchr(a, b) s_strchr(a, b)
506#define Strrchr(a, b) s_strrchr(a, b) 506#define Strrchr(a, b) s_strrchr(a, b)
507#define Strcat(a, b) s_strcat(a, b) 507#define Strcat(a, b) s_strcat(a, b)
508#define Strncat(a, b, c) s_strncat(a, b, c) 508#define Strncat(a, b, c) s_strncat(a, b, c)
509#define Strcpy(a, b) s_strcpy(a, b) 509#define Strcpy(a, b) s_strcpy(a, b)
510#define Strncpy(a, b, c) s_strncpy(a, b, c) 510#define Strncpy(a, b, c) s_strncpy(a, b, c)
511#define Strlen(a) s_strlen(a) 511#define Strlen(a) s_strlen(a)
512#define Strcmp(a, b) s_strcmp(a, b) 512#define Strcmp(a, b) s_strcmp(a, b)
513#define Strncmp(a, b, c) s_strncmp(a, b, c) 513#define Strncmp(a, b, c) s_strncmp(a, b, c)
514 514
515#define Strspl(a, b) s_strspl(a, b) 515#define Strspl(a, b) s_strspl(a, b)
516#define Strsave(a) s_strsave(a) 516#define Strsave(a) s_strsave(a)
517#define Strend(a) s_strend(a) 517#define Strend(a) s_strend(a)
518#define Strstr(a, b) s_strstr(a, b) 518#define Strstr(a, b) s_strstr(a, b)
519#endif 519#endif
520 520
521/* 521/*
522 * setname is a macro to save space (see sh.err.c) 522 * setname is a macro to save space (see sh.err.c)
523 */ 523 */
524const char *bname; 524const char *bname;
525 525
526#define setname(a) (bname = (a)) 526#define setname(a) (bname = (a))
527 527
528Char *Vsav; 528Char *Vsav;
529Char *Vdp; 529Char *Vdp;
530Char *Vexpath; 530Char *Vexpath;
531char **Vt; 531char **Vt;
532 532
533Char **evalvec; 533Char **evalvec;
534Char *evalp; 534Char *evalp;
535 535
536/* word_chars is set by default to WORD_CHARS but can be overridden by 536/* word_chars is set by default to WORD_CHARS but can be overridden by
537 the worchars variable--if unset, reverts to WORD_CHARS */ 537 the worchars variable--if unset, reverts to WORD_CHARS */
538 538
539Char *word_chars; 539Char *word_chars;
540 540
541#define WORD_CHARS "*?_-.[]~=" /* default chars besides alnums in words */ 541#define WORD_CHARS "*?_-.[]~=" /* default chars besides alnums in words */
542 542
543Char *STR_SHELLPATH; 543Char *STR_SHELLPATH;
544 544
545#include <paths.h> 545#include <paths.h>
546#ifdef _PATH_BSHELL 546#ifdef _PATH_BSHELL
547Char *STR_BSHELL; 547Char *STR_BSHELL;
548#endif 548#endif
549Char *STR_WORD_CHARS; 549Char *STR_WORD_CHARS;
550Char **STR_environ; 550Char **STR_environ;
551 551
552#ifdef EDIT 552#ifdef EDIT
553#include <histedit.h> 553#include <histedit.h>
554EditLine *el; 554EditLine *el;
555int editing; 
556#endif 555#endif
 556int editing;
557 557
558#endif /* !_CSH_H_ */ 558#endif /* !_CSH_H_ */