aboutsummaryrefslogtreecommitdiff
path: root/shell/msh.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/msh.c')
-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;