• 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: 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: 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 $ # $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 # http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R33 2008/03/25 @(#)MIRBSD KSH R33 2008/03/28
description: description:
Check version of shell. Check version of shell.
category: pdksh category: pdksh

11
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #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 assignments before command are kept;
* a leading * means a POSIX special builtin; * a leading * means a POSIX special builtin;
@ -136,7 +136,6 @@ c_cd(const char **wp)
int rval; int rval;
struct tbl *pwd_s, *oldpwd_s; struct tbl *pwd_s, *oldpwd_s;
XString xs; XString xs;
char *xp;
char *dir, *try, *pwd; char *dir, *try, *pwd;
int phys_path; int phys_path;
char *cdpath; char *cdpath;
@ -215,11 +214,7 @@ c_cd(const char **wp)
return 1; return 1;
} }
Xinit(xs, xp, PATH_MAX, ATEMP); XinitN(xs, 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;
cdpath = str_val(global("CDPATH")); cdpath = str_val(global("CDPATH"));
do { do {
@ -2808,7 +2803,7 @@ test_primary(Test_env *te, int do_eval)
(*te->error)(te, 0, "expression expected"); (*te->error)(te, 0, "expression expected");
return 0; return 0;
} }
if ((op = (*te->isa)(te, TM_BINOP))) { if ((op = (*te->isa)(te, TM_BINOP)) != TO_NONOP) {
/* binary expression */ /* binary expression */
opnd2 = (*te->getopnd)(te, op, do_eval); opnd2 = (*te->getopnd)(te, op, do_eval);
if (!opnd2) { if (!opnd2) {

11
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #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 * states while lexing word
@ -1012,7 +1012,7 @@ pushs(int type, Area *areap)
{ {
Source *s; Source *s;
s = (Source *) alloc(sizeof(Source), areap); s = (Source *)alloc(sizeof(Source), areap);
s->type = type; s->type = type;
s->str = null; s->str = null;
s->start = NULL; s->start = NULL;
@ -1022,10 +1022,9 @@ pushs(int type, Area *areap)
s->flags = 0; s->flags = 0;
s->next = NULL; s->next = NULL;
s->areap = areap; s->areap = areap;
if (type == SFILE || type == SSTDIN) { if (type == SFILE || type == SSTDIN)
char *dummy; XinitN(s->xs, 256, s->areap);
Xinit(s->xs, dummy, 256, s->areap); else
} else
memset(&s->xs, 0, sizeof(s->xs)); memset(&s->xs, 0, sizeof(s->xs));
return s; 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: 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 $ */ /* $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_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/25" #define MKSH_VERSION "R33 2008/03/28"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
@ -1018,33 +1018,36 @@ typedef struct XString {
typedef char *XStringP; typedef char *XStringP;
/* initialise expandable string */ /* initialise expandable string */
#define Xinit(xs, xp, length, area) do { \ #define XinitN(xs, length, area) do { \
(xs).len = length; \ (xs).len = (length); \
(xs).areap = (area); \ (xs).areap = (area); \
(xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \ (xs).beg = alloc((xs).len + X_EXTRA, (xs).areap); \
(xs).end = (xs).beg + (xs).len; \ (xs).end = (xs).beg + (xs).len; \
xp = (xs).beg; \ } while (0)
} while (0) #define Xinit(xs, xp, length, area) do { \
XinitN((xs), (length), (area)); \
(xp) = (xs).beg; \
} while (0)
/* stuff char into string */ /* stuff char into string */
#define Xput(xs, xp, c) (*xp++ = (c)) #define Xput(xs, xp, c) (*xp++ = (c))
/* check if there are at least n bytes left */ /* check if there are at least n bytes left */
#define XcheckN(xs, xp, n) do { \ #define XcheckN(xs, xp, n) do { \
int more = ((xp) + (n)) - (xs).end; \ int more = ((xp) + (n)) - (xs).end; \
if (more > 0) \ if (more > 0) \
xp = Xcheck_grow_(&xs, xp, more); \ (xp) = Xcheck_grow_(&(xs), (xp), more); \
} while (0) } while (0)
/* check for overflow, expand string */ /* check for overflow, expand string */
#define Xcheck(xs, xp) XcheckN(xs, xp, 1) #define Xcheck(xs, xp) XcheckN((xs), (xp), 1)
/* free string */ /* 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 */ /* close, return string */
#define Xclose(xs, xp) (char*) aresize((void*)(xs).beg, \ #define Xclose(xs, xp) (char*)aresize((void*)(xs).beg, \
(size_t)((xp) - (xs).beg), (xs).areap) (size_t)((xp) - (xs).beg), (xs).areap)
/* begin of string */ /* begin of string */
#define Xstring(xs, xp) ((xs).beg) #define Xstring(xs, xp) ((xs).beg)
@ -1065,31 +1068,31 @@ typedef struct XPtrV {
void **beg, **end; /* begin, end of vector */ void **beg, **end; /* begin, end of vector */
} XPtrV; } XPtrV;
#define XPinit(x, n) do { \ #define XPinit(x, n) do { \
void **vp__; \ void **vp__; \
vp__ = (void**) alloc(sizeofN(void*, n), ATEMP); \ vp__ = (void**) alloc(sizeofN(void*, (n)), ATEMP); \
(x).cur = (x).beg = vp__; \ (x).cur = (x).beg = vp__; \
(x).end = vp__ + n; \ (x).end = vp__ + (n); \
} while (0) } while (0)
#define XPput(x, p) do { \ #define XPput(x, p) do { \
if ((x).cur >= (x).end) { \ if ((x).cur >= (x).end) { \
int n = XPsize(x); \ int n = XPsize(x); \
(x).beg = (void**) aresize((void*) (x).beg, \ (x).beg = (void**) aresize((void*) (x).beg, \
sizeofN(void*, n*2), ATEMP); \ sizeofN(void *, n * 2), ATEMP); \
(x).cur = (x).beg + n; \ (x).cur = (x).beg + n; \
(x).end = (x).cur + n; \ (x).end = (x).cur + n; \
} \ } \
*(x).cur++ = (p); \ *(x).cur++ = (p); \
} while (0) } while (0)
#define XPptrv(x) ((x).beg) #define XPptrv(x) ((x).beg)
#define XPsize(x) ((x).cur - (x).beg) #define XPsize(x) ((x).cur - (x).beg)
#define XPclose(x) (void**) aresize((void*)(x).beg, \ #define XPclose(x) (void**)aresize((void*)(x).beg, \
sizeofN(void*, XPsize(x)), ATEMP) sizeofN(void *, XPsize(x)), ATEMP)
#define XPfree(x) afree((void*) (x).beg, ATEMP) #define XPfree(x) afree((void *)(x).beg, ATEMP)
#define IDENT 64 #define IDENT 64