aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-02 08:35:37 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-02 08:35:37 +0000
commitab801874f852312787c049272c20b14e06ed8195 (patch)
tree1cfd38cfe48ed6a6625ce559ab7f3e5778a980be /shell
parent8003e266edbc0ec62a586dd70dcc80dc13e2dbf0 (diff)
downloadbusybox-w32-ab801874f852312787c049272c20b14e06ed8195.tar.gz
busybox-w32-ab801874f852312787c049272c20b14e06ed8195.tar.bz2
busybox-w32-ab801874f852312787c049272c20b14e06ed8195.zip
attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]: 4288 -mkfs_minix_main [busybox_unstripped]: 4276 -grave [busybox_unstripped]: 4260 (bzip2 users too - not listed) price we pay in code size increase: mainSort 2458 2515 +57 grave 1005 1058 +53 sendMTFValues 2177 2195 +18 BZ2_blockSort 122 125 +3 mkfs_minix_main 3070 3022 -48 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48) Total: 83 bytes
Diffstat (limited to 'shell')
-rw-r--r--shell/msh.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/shell/msh.c b/shell/msh.c
index 32953f4ed..9f95fe28a 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -735,6 +735,9 @@ struct globals {
735 char filechar_cmdbuf[BUFSIZ]; 735 char filechar_cmdbuf[BUFSIZ];
736 char line[LINELIM]; 736 char line[LINELIM];
737 char child_cmd[LINELIM]; 737 char child_cmd[LINELIM];
738
739 char grave__var_name[LINELIM];
740 char grave__alt_value[LINELIM];
738}; 741};
739 742
740#define G (*ptr_to_globals) 743#define G (*ptr_to_globals)
@@ -746,6 +749,9 @@ struct globals {
746#define filechar_cmdbuf (G.filechar_cmdbuf) 749#define filechar_cmdbuf (G.filechar_cmdbuf)
747#define line (G.line ) 750#define line (G.line )
748#define child_cmd (G.child_cmd ) 751#define child_cmd (G.child_cmd )
752#define INIT_G() do { \
753 PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
754} while (0)
749 755
750 756
751#ifdef MSHDEBUG 757#ifdef MSHDEBUG
@@ -4042,8 +4048,12 @@ static int grave(int quoted)
4042 ignore_once = 1; 4048 ignore_once = 1;
4043 if (*src == '$' && !ignore && !ignore_once) { 4049 if (*src == '$' && !ignore && !ignore_once) {
4044 struct var *vp; 4050 struct var *vp;
4051 /* moved to G to reduce stack usage
4045 char var_name[LINELIM]; 4052 char var_name[LINELIM];
4046 char alt_value[LINELIM]; 4053 char alt_value[LINELIM];
4054 */
4055#define var_name (G.grave__var_name)
4056#define alt_value (G.grave__alt_value)
4047 int var_index = 0; 4057 int var_index = 0;
4048 int alt_index = 0; 4058 int alt_index = 0;
4049 char operator = 0; 4059 char operator = 0;
@@ -4131,6 +4141,8 @@ static int grave(int quoted)
4131 count++; 4141 count++;
4132 } 4142 }
4133 } 4143 }
4144#undef var_name
4145#undef alt_value
4134 } else { 4146 } else {
4135 *dest++ = *src++; 4147 *dest++ = *src++;
4136 count++; 4148 count++;
@@ -5173,7 +5185,8 @@ int msh_main(int argc, char **argv)
5173 char *name, **ap; 5185 char *name, **ap;
5174 int (*iof) (struct ioarg *); 5186 int (*iof) (struct ioarg *);
5175 5187
5176 PTR_TO_GLOBALS = xzalloc(sizeof(G)); 5188 INIT_G();
5189
5177 sharedbuf.id = AFID_NOBUF; 5190 sharedbuf.id = AFID_NOBUF;
5178 mainbuf.id = AFID_NOBUF; 5191 mainbuf.id = AFID_NOBUF;
5179 e.linep = line; 5192 e.linep = line;