• syn.c: replace expanded use of str_save() with the actual macro

• others: fix 6 (!) cases of non-constant or side-effect arguments
  to the str_save() or str_nsave() macros, and other abuse of them
• also fix some cosmetics and other un-nice code while here
This commit is contained in:
tg
2008-07-12 16:56:40 +00:00
parent 9eae0851ef
commit 0b4f34e0a8
7 changed files with 40 additions and 37 deletions

10
eval.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.46 2008/05/17 18:46:58 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.47 2008/07/12 16:56:38 tg Exp $");
#ifdef MKSH_SMALL
#define MKSH_NOPWNAM
@ -425,7 +425,8 @@ expand(const char *cp, /* input word */
goto no_repl;
/* prepare string on which to work */
sbeg = s = str_save(str_val(st->var), ATEMP);
tpat0 = str_val(st->var);
sbeg = s = str_save(tpat0, ATEMP);
/* first see if we have any match at all */
tpat0 = pat;
@ -769,10 +770,7 @@ expand(const char *cp, /* input word */
Xlength(ds, dp) == 0) {
char *p;
if ((p = str_nsave(null, 0, ATEMP))
== NULL)
internal_errorf("unable "
"to allocate memory");
*(p = alloc(1, ATEMP)) = '\0';
XPput(*wp, p);
}
type = XSUBMID;