• fix one more of the enum arithmetics complaints

• split Xinit into XinitN and Xinit macro, the former
  not initialising the “xp” argument of the latter,
  and use this to get rid of two variables that are
  only assigned but never referenced (gcc doesn’t see
  this, but MIPSpro and IIRC SUNWcc do)
• re-indent while here
• bump patchlevel
This commit is contained in:
tg 2008-03-28 13:46:53 +00:00
parent 5d41a86e86
commit 2f0c894290
4 changed files with 50 additions and 53 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.162 2008/03/25 21:34:44 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.163 2008/03/28 13:46:51 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R33 2008/03/25
@(#)MIRBSD KSH R33 2008/03/28
description:
Check version of shell.
category: pdksh

11
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.70 2008/03/28 13:28:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.71 2008/03/28 13:46:52 tg Exp $");
/* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin;
@ -136,7 +136,6 @@ c_cd(const char **wp)
int rval;
struct tbl *pwd_s, *oldpwd_s;
XString xs;
char *xp;
char *dir, *try, *pwd;
int phys_path;
char *cdpath;
@ -215,11 +214,7 @@ c_cd(const char **wp)
return 1;
}
Xinit(xs, xp, PATH_MAX, ATEMP);
/* xp will have a bogus value after make_path() - set it to 0
* so that if it's used, it will cause a dump
*/
xp = NULL;
XinitN(xs, PATH_MAX, ATEMP);
cdpath = str_val(global("CDPATH"));
do {
@ -2808,7 +2803,7 @@ test_primary(Test_env *te, int do_eval)
(*te->error)(te, 0, "expression expected");
return 0;
}
if ((op = (*te->isa)(te, TM_BINOP))) {
if ((op = (*te->isa)(te, TM_BINOP)) != TO_NONOP) {
/* binary expression */
opnd2 = (*te->getopnd)(te, op, do_eval);
if (!opnd2) {

11
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.56 2008/03/05 16:49:22 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.57 2008/03/28 13:46:53 tg Exp $");
/*
* states while lexing word
@ -1012,7 +1012,7 @@ pushs(int type, Area *areap)
{
Source *s;
s = (Source *) alloc(sizeof(Source), areap);
s = (Source *)alloc(sizeof(Source), areap);
s->type = type;
s->str = null;
s->start = NULL;
@ -1022,10 +1022,9 @@ pushs(int type, Area *areap)
s->flags = 0;
s->next = NULL;
s->areap = areap;
if (type == SFILE || type == SSTDIN) {
char *dummy;
Xinit(s->xs, dummy, 256, s->areap);
} else
if (type == SFILE || type == SSTDIN)
XinitN(s->xs, 256, s->areap);
else
memset(&s->xs, 0, sizeof(s->xs));
return s;
}

77
sh.h
View File

@ -8,8 +8,8 @@
/* $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.198 2008/03/25 21:34:45 tg Exp $"
#define MKSH_VERSION "R33 2008/03/25"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.199 2008/03/28 13:46:53 tg Exp $"
#define MKSH_VERSION "R33 2008/03/28"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
@ -1018,33 +1018,36 @@ typedef struct XString {
typedef char *XStringP;
/* initialise expandable string */
#define Xinit(xs, xp, length, area) do { \
(xs).len = length; \
(xs).areap = (area); \
(xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \
(xs).end = (xs).beg + (xs).len; \
xp = (xs).beg; \
} while (0)
#define XinitN(xs, length, area) do { \
(xs).len = (length); \
(xs).areap = (area); \
(xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \
(xs).end = (xs).beg + (xs).len; \
} while (0)
#define Xinit(xs, xp, length, area) do { \
XinitN((xs), (length), (area)); \
(xp) = (xs).beg; \
} while (0)
/* stuff char into string */
#define Xput(xs, xp, c) (*xp++ = (c))
/* check if there are at least n bytes left */
#define XcheckN(xs, xp, n) do { \
int more = ((xp) + (n)) - (xs).end; \
if (more > 0) \
xp = Xcheck_grow_(&xs, xp, more); \
} while (0)
#define XcheckN(xs, xp, n) do { \
int more = ((xp) + (n)) - (xs).end; \
if (more > 0) \
(xp) = Xcheck_grow_(&(xs), (xp), more); \
} while (0)
/* check for overflow, expand string */
#define Xcheck(xs, xp) XcheckN(xs, xp, 1)
#define Xcheck(xs, xp) XcheckN((xs), (xp), 1)
/* free string */
#define Xfree(xs, xp) afree((void*) (xs).beg, (xs).areap)
#define Xfree(xs, xp) afree((void*)(xs).beg, (xs).areap)
/* close, return string */
#define Xclose(xs, xp) (char*) aresize((void*)(xs).beg, \
(size_t)((xp) - (xs).beg), (xs).areap)
#define Xclose(xs, xp) (char*)aresize((void*)(xs).beg, \
(size_t)((xp) - (xs).beg), (xs).areap)
/* begin of string */
#define Xstring(xs, xp) ((xs).beg)
@ -1065,31 +1068,31 @@ typedef struct XPtrV {
void **beg, **end; /* begin, end of vector */
} XPtrV;
#define XPinit(x, n) do { \
void **vp__; \
vp__ = (void**) alloc(sizeofN(void*, n), ATEMP); \
(x).cur = (x).beg = vp__; \
(x).end = vp__ + n; \
} while (0)
#define XPinit(x, n) do { \
void **vp__; \
vp__ = (void**) alloc(sizeofN(void*, (n)), ATEMP); \
(x).cur = (x).beg = vp__; \
(x).end = vp__ + (n); \
} while (0)
#define XPput(x, p) do { \
if ((x).cur >= (x).end) { \
int n = XPsize(x); \
(x).beg = (void**) aresize((void*) (x).beg, \
sizeofN(void*, n*2), ATEMP); \
(x).cur = (x).beg + n; \
(x).end = (x).cur + n; \
} \
*(x).cur++ = (p); \
} while (0)
#define XPput(x, p) do { \
if ((x).cur >= (x).end) { \
int n = XPsize(x); \
(x).beg = (void**) aresize((void*) (x).beg, \
sizeofN(void *, n * 2), ATEMP); \
(x).cur = (x).beg + n; \
(x).end = (x).cur + n; \
} \
*(x).cur++ = (p); \
} while (0)
#define XPptrv(x) ((x).beg)
#define XPsize(x) ((x).cur - (x).beg)
#define XPclose(x) (void**) aresize((void*)(x).beg, \
sizeofN(void*, XPsize(x)), ATEMP)
#define XPclose(x) (void**)aresize((void*)(x).beg, \
sizeofN(void *, XPsize(x)), ATEMP)
#define XPfree(x) afree((void*) (x).beg, ATEMP)
#define XPfree(x) afree((void *)(x).beg, ATEMP)
#define IDENT 64