use less stack storage, prefer .bss storage (saves us a memset() call)
and .data instead of another initialisation; this was prompted by a bug in scan-build (the value can never be NULL, but it doesn’t realise it), although this doesn’t fix it, but less stack usage is always good
This commit is contained in:
parent
7daf3f0b59
commit
9be489ea90
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.230 2008/10/13 23:06:01 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.231 2008/10/15 10:24:59 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 R35 2008/10/13
|
@(#)MIRBSD KSH R35 2008/10/15
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
8
main.c
8
main.c
@ -13,7 +13,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.102 2008/09/17 19:31:29 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.103 2008/10/15 10:25:01 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -57,6 +57,9 @@ static const char *initcoms[] = {
|
|||||||
|
|
||||||
static int initio_done;
|
static int initio_done;
|
||||||
|
|
||||||
|
static struct env env;
|
||||||
|
struct env *e = &env;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
@ -65,7 +68,6 @@ main(int argc, const char *argv[])
|
|||||||
struct block *l;
|
struct block *l;
|
||||||
int restricted, errexit;
|
int restricted, errexit;
|
||||||
const char **wp;
|
const char **wp;
|
||||||
struct env env;
|
|
||||||
pid_t ppid;
|
pid_t ppid;
|
||||||
struct tbl *vp;
|
struct tbl *vp;
|
||||||
struct stat s_stdin;
|
struct stat s_stdin;
|
||||||
@ -88,10 +90,8 @@ main(int argc, const char *argv[])
|
|||||||
ainit(&aperm); /* initialise permanent Area */
|
ainit(&aperm); /* initialise permanent Area */
|
||||||
|
|
||||||
/* set up base environment */
|
/* set up base environment */
|
||||||
memset(&env, 0, sizeof(env));
|
|
||||||
env.type = E_NONE;
|
env.type = E_NONE;
|
||||||
ainit(&env.area);
|
ainit(&env.area);
|
||||||
e = &env;
|
|
||||||
newblock(); /* set up global l->vars and l->funs */
|
newblock(); /* set up global l->vars and l->funs */
|
||||||
|
|
||||||
/* Do this first so output routines (eg, errorf, shellf) can work */
|
/* Do this first so output routines (eg, errorf, shellf) can work */
|
||||||
|
6
sh.h
6
sh.h
@ -100,9 +100,9 @@
|
|||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.240 2008/10/13 23:06:03 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.241 2008/10/15 10:25:01 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R35 2008/10/13"
|
#define MKSH_VERSION "R35 2008/10/15"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ EXTERN Area aperm; /* permanent object space */
|
|||||||
/*
|
/*
|
||||||
* parsing & execution environment
|
* parsing & execution environment
|
||||||
*/
|
*/
|
||||||
EXTERN struct env {
|
extern struct env {
|
||||||
Area area; /* temporary allocation area */
|
Area area; /* temporary allocation area */
|
||||||
struct block *loc; /* local variables and functions */
|
struct block *loc; /* local variables and functions */
|
||||||
short *savefd; /* original redirected fds */
|
short *savefd; /* original redirected fds */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user