• 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

11
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.83 2008/06/08 17:16:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.84 2008/07/12 16:56:39 tg Exp $");
/* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin;
@ -1074,8 +1074,10 @@ c_alias(const char **wp)
struct tbl *ap;
int h;
if ((val = cstrchr(alias, '=')))
alias = xalias = str_nsave(alias, val++ - alias, ATEMP);
if ((val = cstrchr(alias, '='))) {
h = val++ - alias;
alias = xalias = str_nsave(alias, h, ATEMP);
}
h = hash(alias);
if (val == NULL && !tflag && !xflag) {
ap = ktsearch(t, alias, h);
@ -1103,8 +1105,7 @@ c_alias(const char **wp)
afree((void*)ap->val.s, APERM);
}
/* ignore values for -t (at&t ksh does this) */
newval = tflag ? search(alias, path, X_OK, NULL) :
val;
newval = tflag ? search(alias, path, X_OK, NULL) : val;
if (newval) {
ap->val.s = str_save(newval, APERM);
ap->flag |= ALLOC|ISSET;