• bump patchlevel to today’s

• while here, reformat 'struct tbl' comment-wise and placement-wise
  and drop the Tflag typedef
• while here, write regression test for the "global" built-in, which
  does what typeset is supposed to do except that it doubles as "local"
This commit is contained in:
tg 2011-07-05 20:12:20 +00:00
parent 71fa2ca232
commit f2405b7dde
5 changed files with 71 additions and 31 deletions

38
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.470 2011/07/02 17:57:37 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.471 2011/07/05 20:12:15 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 $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R40 2011/07/02
@(#)MIRBSD KSH R40 2011/07/05
description:
Check version of shell.
stdin:
@ -5710,6 +5710,40 @@ expected-stdout-pattern:
expected-stderr-pattern:
/^X*$/
---
name: typeset-1
description:
Check that global does what typeset is supposed to do
stdin:
set -A arrfoo 65
foo() {
global -Uui16 arrfoo[*]
}
echo before ${arrfoo[0]} .
foo
echo after ${arrfoo[0]} .
set -A arrbar 65
bar() {
echo inside before ${arrbar[0]} .
arrbar[0]=97
echo inside changed ${arrbar[0]} .
global -Uui16 arrbar[*]
echo inside typeset ${arrbar[0]} .
arrbar[0]=48
echo inside changed ${arrbar[0]} .
}
echo before ${arrbar[0]} .
bar
echo after ${arrbar[0]} .
expected-stdout:
before 65 .
after 16#41 .
before 65 .
inside before 65 .
inside changed 97 .
inside typeset 16#61 .
inside changed 16#30 .
after 16#30 .
---
name: typeset-padding-1
description:
Check if left/right justification works as per TFM

6
exec.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.92 2011/05/29 02:18:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.93 2011/07/05 20:12:17 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -669,7 +669,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
/* function call */
case CFUNC: {
volatile unsigned char old_xflag;
volatile Tflag old_inuse;
volatile uint32_t old_inuse;
const char * volatile old_kshname;
if (!(tp->flag & ISSET)) {
@ -1033,7 +1033,7 @@ const char *
builtin(const char *name, int (*func) (const char **))
{
struct tbl *tp;
Tflag flag;
uint32_t flag;
/* see if any flags should be set for this builtin */
for (flag = 0; ; name++) {

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.192 2011/07/05 19:56:24 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.193 2011/07/05 20:12:18 tg Exp $");
#if HAVE_KILLPG
/*
@ -604,7 +604,7 @@ c_typeset(const char **wp)
{
struct block *l;
struct tbl *vp, **p;
Tflag fset = 0, fclr = 0, flag;
uint32_t fset = 0, fclr = 0, flag;
int thing = 0, field, base, optc;
const char *opts;
const char *fieldstr, *basestr;
@ -966,7 +966,7 @@ c_alias(const char **wp)
struct table *t = &aliases;
int rv = 0, prefix = 0;
bool rflag = false, tflag, Uflag = false, pflag = false;
Tflag xflag = 0;
uint32_t xflag = 0;
int optc;
builtin_opt.flags |= GF_PLUSOPT;

48
sh.h
View File

@ -151,9 +151,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.481 2011/07/02 17:57:40 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.482 2011/07/05 20:12:19 tg Exp $");
#endif
#define MKSH_VERSION "R40 2011/07/02"
#define MKSH_VERSION "R40 2011/07/05"
#ifndef MKSH_INCLUDES_ONLY
@ -344,9 +344,6 @@ extern int wcwidth(__WCHAR_TYPE__);
#define BIT(i) (1 << (i))
#define NELEM(a) (sizeof(a) / sizeof((a)[0]))
/* Table flag type - needs > 16 and < 32 bits */
typedef int32_t Tflag;
/* arithmetics types */
typedef int32_t mksh_ari_t;
typedef uint32_t mksh_uari_t;
@ -843,7 +840,7 @@ EXTERN sigset_t sm_default, sm_sigchld;
/* name of called builtin function (used by error functions) */
EXTERN const char *builtin_argv0;
/* flags of called builtin (SPEC_BI, etc.) */
EXTERN Tflag builtin_flag;
EXTERN uint32_t builtin_flag;
/* current working directory */
EXTERN char *current_wd;
@ -946,31 +943,40 @@ struct table {
uint8_t tshift; /* table size (2^tshift) */
};
struct tbl { /* table item */
Area *areap; /* area to allocate from */
/* table item */
struct tbl {
/* Area to allocate from */
Area *areap;
/* value */
union {
char *s; /* string */
mksh_ari_t i; /* integer */
mksh_uari_t u; /* unsigned integer */
int (*f)(const char **); /* int function */
struct op *t; /* "function" tree */
} val; /* value */
char *s; /* string */
mksh_ari_t i; /* integer */
mksh_uari_t u; /* unsigned integer */
int (*f)(const char **); /* built-in command */
struct op *t; /* "function" tree */
} val;
union {
struct tbl *array; /* array values */
const char *fpath; /* temporary path to undef function */
} u;
union {
int field; /* field with for -L/-R/-Z */
int errno_; /* CEXEC/CTALIAS */
int field; /* field with for -L/-R/-Z */
int errno_; /* CEXEC/CTALIAS */
} u2;
int type; /* command type (see below), base (if INTEGER),
* or offset from val.s of value (if EXPORT) */
Tflag flag; /* flags */
union {
uint32_t hval; /* hash(name) */
uint32_t index; /* index for an array */
} ua;
char name[4]; /* name -- variable length */
/*
* command type (see below), base (if INTEGER),
* offset from val.s of value (if EXPORT)
*/
int type;
/* flags (see below) */
uint32_t flag;
/* actually longer: name (variable length) */
char name[4];
};
/* common flag bits */
@ -1797,7 +1803,7 @@ int setstr(struct tbl *, const char *, int);
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
void setint(struct tbl *, mksh_ari_t);
void setint_n(struct tbl *, mksh_ari_t);
struct tbl *typeset(const char *, Tflag, Tflag, int, int)
struct tbl *typeset(const char *, uint32_t, uint32_t, int, int)
MKSH_A_NONNULL((__nonnull__ (1)));
void unset(struct tbl *, int);
const char *skip_varname(const char *, int);

4
var.c
View File

@ -26,7 +26,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.127 2011/07/02 17:57:41 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.128 2011/07/05 20:12:20 tg Exp $");
/*-
* Variables
@ -687,7 +687,7 @@ exportprep(struct tbl *vp, const char *val)
* UCASEV_AL), and optionally set its value if an assignment.
*/
struct tbl *
typeset(const char *var, Tflag set, Tflag clr, int field, int base)
typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
{
struct tbl *vp;
struct tbl *vpbase, *t;