reduce stack usage a bit (several candidates for more, including $CC itself…)

This commit is contained in:
tg 2012-01-29 01:41:15 +00:00
parent 8b023994de
commit bee3bbaaf8
5 changed files with 36 additions and 18 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.513 2012/01/14 19:20:17 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.514 2012/01/29 01:41:09 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 $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R40 2012/01/04
@(#)MIRBSD KSH R40 2012/01/28
description:
Check version of shell.
stdin:

4
edit.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.226 2011/12/29 23:36:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.227 2012/01/29 01:41:12 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -1802,7 +1802,7 @@ static int
x_search_hist(int c)
{
int offset = -1; /* offset of match in xbuf, else -1 */
char pat[256 + 1]; /* pattern buffer */
char pat[80 + 1]; /* pattern buffer */
char *p = pat;
unsigned char f;

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.206 2011/12/29 22:54:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.207 2012/01/29 01:41:13 tg Exp $");
#if HAVE_KILLPG
/*
@ -1759,11 +1759,11 @@ c_wait(const char **wp)
return (rv);
}
static char REPLY[] = "REPLY";
int
c_read(const char **wp)
{
#define is_ifsws(c) (ctype((c), C_IFS) && ctype((c), C_IFSWS))
static char REPLY[] = "REPLY";
int c, fd = 0, rv = 0, lastparm = 0;
bool savehist = false, intoarray = false, aschars = false;
bool rawmode = false, expanding = false;

38
main.c
View File

@ -4,7 +4,8 @@
/* $OpenBSD: table.c,v 1.13 2009/01/17 22:06:44 millert Exp $ */
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012
* Thorsten Glaser <tg@mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@ -33,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.201 2011/11/08 22:07:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.202 2012/01/29 01:41:14 tg Exp $");
extern char **environ;
@ -45,6 +46,7 @@ extern char **environ;
#define MKSH_DEFAULT_TMPDIR "/tmp"
#endif
static int main_init(int, const char *[], Source **, struct block **);
void chvt_reinit(void);
static void reclaim(void);
static void remove_temps(struct temp *);
@ -155,8 +157,8 @@ static const char *empty_argv[] = {
"mksh", NULL
};
int
main(int argc, const char *argv[])
static int
main_init(int argc, const char *argv[], Source **sp, struct block **lp)
{
int argi, i;
Source *s = NULL;
@ -594,15 +596,31 @@ main(int argc, const char *argv[])
alarm_init();
if (Flag(FAS_BUILTIN))
return (shcomexec(l->argv));
/* doesn't return */
shell(s, true);
/* NOTREACHED */
*sp = s;
*lp = l;
return (0);
}
/* this indirection barrier reduces stack usage during normal operation */
int
main(int argc, const char *argv[])
{
int rv;
Source *s;
struct block *l;
if ((rv = main_init(argc, argv, &s, &l)) == 0) {
if (Flag(FAS_BUILTIN)) {
rv = shcomexec(l->argv);
} else {
shell(s, true);
/* NOTREACHED */
}
}
return (rv);
}
int
include(const char *name, int argc, const char **argv, int intr_ok)
{

4
sh.h
View File

@ -152,9 +152,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.519 2012/01/04 19:09:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.520 2012/01/29 01:41:15 tg Exp $");
#endif
#define MKSH_VERSION "R40 2012/01/04"
#define MKSH_VERSION "R40 2012/01/28"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES