1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

typeset: only alloc stack space if needed (re: ff70c27f)

src/cmd/ksh93/bltins/typeset.c:
- Don't call stakalloc(3) unless/until we actually need it to
  construct a new list of arguments.
This commit is contained in:
Martijn Dekker 2021-01-21 08:39:10 +00:00
parent ff70c27f24
commit 6445573d24

View file

@ -196,9 +196,7 @@ int b_typeset(int argc,register char *argv[],Shbltin_t *context)
Namdecl_t *ntp = (Namdecl_t*)context->ptr; Namdecl_t *ntp = (Namdecl_t*)context->ptr;
Dt_t *troot; Dt_t *troot;
int isfloat=0, shortint=0, sflag=0; int isfloat=0, shortint=0, sflag=0;
char **new_argv;
new_argv = (char **)stakalloc((argc + 2) * sizeof(char*));
memset((void*)&tdata,0,sizeof(tdata)); memset((void*)&tdata,0,sizeof(tdata));
tdata.sh = context->shp; tdata.sh = context->shp;
troot = tdata.sh->var_tree; troot = tdata.sh->var_tree;
@ -210,6 +208,7 @@ int b_typeset(int argc,register char *argv[],Shbltin_t *context)
} }
else if(argv[0][0] != 't') /* not <t>ypeset */ else if(argv[0][0] != 't') /* not <t>ypeset */
{ {
char **new_argv = (char **)stakalloc((argc + 2) * sizeof(char*));
new_argv[0] = "typeset"; new_argv[0] = "typeset";
if(argv[0][0] == 'a') /* <a>utoload == typeset -fu */ if(argv[0][0] == 'a') /* <a>utoload == typeset -fu */
new_argv[1] = "-fu"; new_argv[1] = "-fu";