apply some fixes from OpenBSD and don't apply some others

but sync RCS IDs for easier future adaption:
* Simplify savefd() by removing the "noclose" flag and make noclose
  behavior the default. Almost all uses of savefd() are followed
  by an implicit or explicit close.
* fix typos
* might as well make ksh_getopt() match real getopt(), ie. get rid of that
  stupid EOF concept that was never true. adobriyan@gmail
* use SEEK_* for lseek()
* fix lint comments, no functional changes
* remove excessive optimization; from adobriyan@gmail
* only santa checks things twice; from adobriyan@gmail
* Interpret zero-filled numbers as decimal; PR 4213; from Alexey Dobriyan
This commit is contained in:
tg 2006-05-10 18:54:13 +00:00
parent 301066165b
commit 7672b9b346
16 changed files with 96 additions and 93 deletions

4
edit.c
View File

@ -1,11 +1,11 @@
/* $OpenBSD: edit.c,v 1.31 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: edit.h,v 1.8 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: emacs.c,v 1.39 2005/09/26 19:25:22 otto Exp $ */
/* $OpenBSD: vi.c,v 1.22 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: vi.c,v 1.23 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.20 2006/02/16 11:48:31 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.21 2006/05/10 18:54:09 tg Exp $");
/* tty driver characters we are interested in */
typedef struct {

6
eval.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: eval.c,v 1.28 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: eval.c,v 1.30 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.11 2006/05/08 11:07:38 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.12 2006/05/10 18:54:09 tg Exp $");
/*
* string expansion
@ -852,7 +852,7 @@ comsub(Expand *xp, char *cp)
int ofd1, pv[2];
openpipe(pv);
shf = shf_fdopen(pv[0], SHF_RD, NULL);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */
ofd1 = savefd(1);
if (pv[1] != 1) {
ksh_dup2(pv[1], 1, false);
close(pv[1]);

19
exec.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: exec.c,v 1.44 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: exec.c,v 1.46 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.14 2006/01/30 12:37:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.15 2006/05/10 18:54:10 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, char **,
int volatile);
@ -113,9 +113,8 @@ execute(struct op *volatile t,
case TPIPE:
flags |= XFORK;
flags &= ~XEXEC;
e->savefd[0] = savefd(0, 0);
(void) ksh_dup2(e->savefd[0], 0, false); /* stdin of first */
e->savefd[1] = savefd(1, 0);
e->savefd[0] = savefd(0);
e->savefd[1] = savefd(1);
while (t->type == TPIPE) {
openpipe(pv);
(void) ksh_dup2(pv[1], 1, false); /* stdout of curr */
@ -160,7 +159,7 @@ execute(struct op *volatile t,
sigprocmask(SIG_SETMASK, &omask, NULL);
quitenv(NULL);
unwind(i);
/*NOTREACHED*/
/* NOTREACHED */
}
/* Already have a (live) co-process? */
if (coproc.job && coproc.write >= 0)
@ -170,8 +169,8 @@ execute(struct op *volatile t,
coproc_cleanup(true);
/* do this before opening pipes, in case these fail */
e->savefd[0] = savefd(0, 0);
e->savefd[1] = savefd(1, 0);
e->savefd[0] = savefd(0);
e->savefd[1] = savefd(1);
openpipe(pv);
if (pv[0] != 0) {
@ -607,7 +606,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
case LSHELL:
quitenv(NULL);
unwind(i);
/*NOTREACHED*/
/* NOTREACHED */
default:
quitenv(NULL);
internal_errorf(1, "CFUNC %d", i);
@ -1091,7 +1090,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
* is 2; also means we can't lose the fd (eg, both
* dup2 below and dup2 in restfd() failing).
*/
e->savefd[iop->unit] = savefd(iop->unit, 1);
e->savefd[iop->unit] = savefd(iop->unit);
}
if (do_close)

8
expr.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: expr.c,v 1.18 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: expr.c,v 1.19 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.3 2005/11/22 18:40:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.4 2006/05/10 18:54:10 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */
enum token {
@ -182,7 +182,7 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok,
errorf(null);
}
unwind(i);
/*NOTREACHED*/
/* NOTREACHED */
}
token(es);
@ -298,7 +298,7 @@ evalexpr(Expr_state *es, enum prec prec)
token(es);
} else {
evalerr(es, ET_UNEXPECTED, NULL);
/*NOTREACHED*/
/* NOTREACHED */
}
if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) {
vl = do_ppmm(es, es->tok, vl, false);

44
funcs.c
View File

@ -1,11 +1,11 @@
/* $OpenBSD: c_ksh.c,v 1.28 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: c_sh.c,v 1.31 2005/10/08 18:07:31 otto Exp $ */
/* $OpenBSD: c_ksh.c,v 1.29 2006/03/12 00:26:58 deraadt Exp $ */
/* $OpenBSD: c_sh.c,v 1.35 2006/04/10 14:38:59 jaredy Exp $ */
/* $OpenBSD: c_test.c,v 1.17 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.14 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.15 2006/03/12 00:26:58 deraadt Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.26 2006/01/30 12:37:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.27 2006/05/10 18:54:10 tg Exp $");
int
c_cd(char **wp)
@ -22,7 +22,7 @@ c_cd(char **wp)
int phys_path;
char *cdpath;
while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != -1)
switch (optc) {
case 'L':
physical = 0;
@ -157,7 +157,7 @@ c_pwd(char **wp)
int physical = Flag(FPHYSICAL);
char *p;
while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != -1)
switch (optc) {
case 'L':
physical = 0;
@ -239,7 +239,7 @@ c_print(char **wp)
} else {
int optc;
const char *opts = "Rnprsu,";
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != -1)
switch (optc) {
case 'R': /* fake BSD echo command */
flags |= PO_PMINUSMINUS;
@ -390,7 +390,7 @@ c_whence(char **wp)
int fcflags;
const char *opts = iam_whence ? "pv" : "pvV";
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != -1)
switch (optc) {
case 'p':
pflag = 1;
@ -549,7 +549,7 @@ c_typeset(char **wp)
* Here, the number must follow the RLZi option, but is optional
* (see the # kludge in ksh_getopt()).
*/
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != EOF) {
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != -1) {
flag = 0;
switch (optc) {
case 'L':
@ -817,7 +817,7 @@ c_alias(char **wp)
int optc;
builtin_opt.flags |= GF_PLUSOPT;
while ((optc = ksh_getopt(wp, &builtin_opt, "dprtUx")) != EOF) {
while ((optc = ksh_getopt(wp, &builtin_opt, "dprtUx")) != -1) {
prefix = builtin_opt.info & GI_PLUS ? '+' : '-';
switch (optc) {
case 'd':
@ -951,7 +951,7 @@ c_unalias(char **wp)
int rv = 0, all = 0;
int optc;
while ((optc = ksh_getopt(wp, &builtin_opt, "adt")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "adt")) != -1)
switch (optc) {
case 'a':
all = 1;
@ -1021,7 +1021,7 @@ c_jobs(char **wp)
int nflag = 0;
int rv = 0;
while ((optc = ksh_getopt(wp, &builtin_opt, "lpnz")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "lpnz")) != -1)
switch (optc) {
case 'l':
flag = 1;
@ -1116,7 +1116,7 @@ c_kill(char **wp)
} else {
int optc;
while ((optc = ksh_getopt(wp, &builtin_opt, "ls:")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "ls:")) != -1)
switch (optc) {
case 'l':
lflag = 1;
@ -1313,7 +1313,7 @@ c_bind(char **wp)
int optc, rv = 0, macro = 0, list = 0;
char *cp;
while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != -1)
switch (optc) {
case 'l':
list = 1;
@ -1418,7 +1418,7 @@ c_umask(char **wp)
mode_t old_umask;
int optc;
while ((optc = ksh_getopt(wp, &builtin_opt, "S")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "S")) != -1)
switch (optc) {
case 'S':
symbolic = 1;
@ -1613,7 +1613,7 @@ c_read(char **wp)
char *xp = NULL;
static char REPLY[] = "REPLY";
while ((optc = ksh_getopt(wp, &builtin_opt, "prsu,")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "prsu,")) != -1)
switch (optc) {
case 'p':
if ((fd = coproc_getfd(R_OK, &emsg)) < 0) {
@ -1901,7 +1901,7 @@ c_exitreturn(char **wp)
quitenv(NULL); /* get rid of any i/o redirections */
unwind(how);
/*NOTREACHED*/
/* NOTREACHED */
return 0;
}
@ -1955,7 +1955,7 @@ c_brkcont(char **wp)
}
unwind(*wp[0] == 'b' ? LBREAK : LCONTIN);
/*NOTREACHED*/
/* NOTREACHED */
}
int
@ -2000,7 +2000,7 @@ c_unset(char **wp)
int optc, unset_var = 1;
int ret = 0;
while ((optc = ksh_getopt(wp, &builtin_opt, "fv")) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, "fv")) != -1)
switch (optc) {
case 'f':
unset_var = 0;
@ -2141,7 +2141,7 @@ timex_hook(struct op *t, char **volatile *app)
ksh_getopt_reset(&opt, 0);
opt.optind = 0; /* start at the start */
while ((optc = ksh_getopt(wp, &opt, ":p")) != EOF)
while ((optc = ksh_getopt(wp, &opt, ":p")) != -1)
switch (optc) {
case 'p':
t->str[0] |= TF_POSIX;
@ -2193,7 +2193,7 @@ c_mknod(char **wp)
void *set = NULL;
mode_t mode = 0, oldmode = 0;
while ((optc = ksh_getopt(wp, &builtin_opt, "m:")) != EOF) {
while ((optc = ksh_getopt(wp, &builtin_opt, "m:")) != -1) {
switch (optc) {
case 'm':
set = setmode(builtin_opt.optarg);
@ -2902,7 +2902,7 @@ c_ulimit(char **wp)
*p = '\0';
}
what = 'f';
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != EOF)
while ((optc = ksh_getopt(wp, &builtin_opt, opts)) != -1)
switch (optc) {
case 'H':
how = HARD;

View File

@ -1,9 +1,9 @@
/* $OpenBSD: history.c,v 1.32 2005/12/11 18:53:51 deraadt Exp $ */
/* $OpenBSD: history.c,v 1.34 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: trap.c,v 1.22 2005/03/30 17:16:37 deraadt Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.14 2006/01/29 20:04:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.15 2006/05/10 18:54:10 tg Exp $");
static int histfd;
static int hsize;
@ -63,7 +63,7 @@ c_fc(char **wp)
}
while ((optc = ksh_getopt(wp, &builtin_opt,
"e:glnrs0,1,2,3,4,5,6,7,8,9,")) != EOF)
"e:glnrs0,1,2,3,4,5,6,7,8,9,")) != -1)
switch (optc) {
case 'e':
p = builtin_opt.optarg;
@ -653,7 +653,9 @@ hist_init(Source *s)
if ((fd = open(hname, O_RDWR|O_CREAT|O_APPEND, 0600)) < 0)
return;
histfd = savefd(fd, 0);
histfd = savefd(fd);
if (histfd != fd)
close(fd);
(void) flock(histfd, LOCK_EX);

6
jobs.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: jobs.c,v 1.34 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: jobs.c,v 1.35 2006/02/06 16:47:07 jmc Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.7 2006/01/30 12:37:23 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.8 2006/05/10 18:54:11 tg Exp $");
/* Order important! */
#define PRUNNING 0
@ -1408,7 +1408,7 @@ new_job(void)
return newj;
}
/* Allocate new process strut
/* Allocate new process struct
*
* If jobs are compiled in then this routine expects sigchld to be blocked.
*/

4
lex.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: lex.c,v 1.38 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: lex.c,v 1.39 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.11 2006/01/29 20:04:52 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.12 2006/05/10 18:54:11 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. */

33
main.c
View File

@ -1,12 +1,12 @@
/* $OpenBSD: main.c,v 1.40 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: tty.c,v 1.8 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.21 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: main.c,v 1.41 2006/04/10 14:38:59 jaredy Exp $ */
/* $OpenBSD: tty.c,v 1.9 2006/03/14 22:08:01 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.22 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: table.c,v 1.12 2005/12/11 20:31:21 otto Exp $ */
#define EXTERN /* define EXTERNs in sh.h */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.35 2006/05/08 11:42:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.36 2006/05/10 18:54:11 tg Exp $");
#define MKSH_VERSION "@(#)MIRBSD KSH R26 2006/05/08"
@ -676,12 +676,9 @@ tty_init(int init_ttystate)
tty_devtty = 1;
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
if (tfd < 0) {
tty_devtty = 0;
warningf(false,
"No controlling tty (open /dev/tty: %s)",
strerror(errno));
}
tty_devtty = 0;
warningf(false, "No controlling tty (open /dev/tty: %s)",
strerror(errno));
}
if (tfd < 0) {
do_close = 0;
@ -878,7 +875,7 @@ ksh_dup2(int ofd, int nfd, int errok)
* set close-on-exec flag.
*/
int
savefd(int fd, int noclose)
savefd(int fd)
{
int nfd;
@ -890,8 +887,6 @@ savefd(int fd, int noclose)
else
errorf("too many files open in shell");
}
if (!noclose)
close(fd);
} else
nfd = fd;
fcntl(nfd, F_SETFD, FD_CLOEXEC);
@ -914,10 +909,16 @@ restfd(int fd, int ofd)
void
openpipe(int *pv)
{
if (pipe(pv) < 0)
int lpv[2];
if (pipe(lpv) < 0)
errorf("can't create pipe - try again");
pv[0] = savefd(pv[0], 0);
pv[1] = savefd(pv[1], 0);
pv[0] = savefd(lpv[0]);
if (pv[0] != lpv[0])
close(lpv[0]);
pv[1] = savefd(lpv[1]);
if (pv[1] != lpv[1])
close(lpv[1]);
}
void

10
misc.c
View File

@ -1,9 +1,9 @@
/* $OpenBSD: misc.c,v 1.28 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: misc.c,v 1.30 2006/03/12 00:26:58 deraadt Exp $ */
/* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.10 2005/11/24 19:39:10 tg Exp $"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.11 2006/05/10 18:54:11 tg Exp $"
"\t" MKSH_SH_H_ID);
short chtypes[UCHAR_MAX+1]; /* type bits for unsigned char */
@ -328,7 +328,7 @@ parse_args(char **argv,
} else
opts = set_opts;
ksh_getopt_reset(&go, GF_ERROR|GF_PLUSOPT);
while ((optc = ksh_getopt(argv, &go, opts)) != EOF) {
while ((optc = ksh_getopt(argv, &go, opts)) != -1) {
set = (go.info & GI_PLUS) ? 0 : 1;
switch (optc) {
case 'A':
@ -896,14 +896,14 @@ ksh_getopt(char **argv, Getopt *go, const char *optionsp)
go->optind++;
go->p = 0;
go->info |= GI_MINUSMINUS;
return EOF;
return -1;
}
if (arg == NULL ||
((flag != '-' ) && /* neither a - nor a + (if + allowed) */
(!(go->flags & GF_PLUSOPT) || flag != '+')) ||
(c = arg[1]) == '\0') {
go->p = 0;
return EOF;
return -1;
}
go->optind++;
go->info &= ~(GI_MINUS|GI_PLUS);

6
mksh.1
View File

@ -1,8 +1,8 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.33 2006/05/08 12:12:36 tg Exp $
.\" $OpenBSD: ksh.1,v 1.109 2005/12/06 20:40:02 jmc Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.34 2006/05/10 18:54:11 tg Exp $
.\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
.Dd May 22, 2005
.Dd May 10, 2006
.Dt MKSH 1
.Os MirBSD
.\" for portability

6
sh.h
View File

@ -4,11 +4,11 @@
/* $OpenBSD: tree.h,v 1.10 2005/03/28 21:28:22 deraadt Exp $ */
/* $OpenBSD: expand.h,v 1.6 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: lex.h,v 1.10 2005/09/11 18:02:27 otto Exp $ */
/* $OpenBSD: proto.h,v 1.29 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: proto.h,v 1.30 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.25 2006/03/19 18:06:32 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.26 2006/05/10 18:54:12 tg Exp $"
#include <sys/param.h>
@ -1106,7 +1106,7 @@ void shprintf(const char *, ...)
int can_seek(int);
void initio(void);
int ksh_dup2(int, int, int);
int savefd(int, int);
int savefd(int);
void restfd(int, int);
void openpipe(int *);
void closepipe(int *);

6
shf.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: shf.c,v 1.14 2005/12/11 18:53:51 deraadt Exp $ */
/* $OpenBSD: shf.c,v 1.15 2006/04/02 00:48:33 deraadt Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.4 2006/01/29 20:04:53 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.5 2006/05/10 18:54:12 tg Exp $");
/* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */
@ -280,7 +280,7 @@ shf_flush(struct shf *shf)
if (shf->flags & SHF_READING) {
shf->flags &= ~(SHF_EOF | SHF_READING);
if (shf->rnleft > 0) {
lseek(shf->fd, (off_t) -shf->rnleft, 1);
lseek(shf->fd, (off_t) -shf->rnleft, SEEK_CUR);
shf->rnleft = 0;
shf->rp = shf->buf;
}

16
syn.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: syn.c,v 1.23 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: syn.c,v 1.27 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.6 2006/01/30 12:37:24 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.7 2006/05/10 18:54:13 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -693,7 +693,7 @@ syntaxerr(const char *what)
}
/* don't quote the EOF */
yyerror("syntax error: unexpected EOF\n");
/*NOTREACHED*/
/* NOTREACHED */
case LWORD:
s = snptreef(NULL, 32, "%S", yylval.cp);
@ -775,14 +775,12 @@ compile(Source *s)
static int
assign_command(char *s)
{
char c = *s;
if (!*s)
return 0;
return (c == 'a' && strcmp(s, "alias") == 0) ||
(c == 'e' && strcmp(s, "export") == 0) ||
(c == 'r' && strcmp(s, "readonly") == 0) ||
(c == 't' && strcmp(s, "typeset") == 0);
return (strcmp(s, "alias") == 0) ||
(strcmp(s, "export") == 0) ||
(strcmp(s, "readonly") == 0) ||
(strcmp(s, "typeset") == 0);
}
/* Check if we are in the middle of reading an alias */

4
tree.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: tree.c,v 1.17 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: tree.c,v 1.18 2006/04/10 14:38:59 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.3 2005/11/22 18:40:44 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.4 2006/05/10 18:54:13 tg Exp $");
#define INDENT 4

7
var.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: var.c,v 1.28 2005/12/11 20:31:21 otto Exp $ */
/* $OpenBSD: var.c,v 1.29 2006/03/13 08:21:37 otto Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.16 2006/01/30 12:37:24 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.17 2006/05/10 18:54:13 tg Exp $");
/*
* Variables
@ -418,6 +418,9 @@ getint(struct tbl *vp, long int *nump, bool arith)
if (*s == 'x' || *s == 'X') {
s++;
base = 16;
} else if (vp->flag & ZEROFIL) {
while (*s == '0')
s++;
} else
base = 8;
have_base++;