improve MKSH_NOPWNAM handling, whether MKSH_SMALL or not; it will cause

the entire ~fac/ expansion code to be omitted
This commit is contained in:
tg 2009-07-25 20:26:33 +00:00
parent 5e3aba8b00
commit bcf4080793
4 changed files with 24 additions and 15 deletions

6
eval.c
View File

@ -22,11 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.62 2009/07/25 20:17:47 tg Exp $");
#if defined(MKSH_SMALL) && !defined(MKSH_NOPWNAM)
#define MKSH_NOPWNAM
#endif
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.63 2009/07/25 20:26:31 tg Exp $");
/*
* string expansion

18
funcs.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.115 2009/06/11 12:42:18 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.116 2009/07/25 20:26:32 tg Exp $");
#if HAVE_KILLPG
/*
@ -1048,8 +1048,8 @@ c_alias(const char **wp)
prefix = builtin_opt.info & GI_PLUS ? '+' : '-';
switch (optc) {
case 'd':
#ifdef MKSH_SMALL
return (0);
#ifdef MKSH_NOPWNAM
t = NULL; /* fix "alias -dt" */
#else
t = &homedirs;
#endif
@ -1077,6 +1077,10 @@ c_alias(const char **wp)
return (1);
}
}
#ifdef MKSH_NOPWNAM
if (t == NULL)
return (0);
#endif
wp += builtin_opt.optind;
if (!(builtin_opt.info & GI_MINUSMINUS) && *wp &&
@ -1187,8 +1191,8 @@ c_unalias(const char **wp)
all = true;
break;
case 'd':
#ifdef MKSH_SMALL
return (0);
#ifdef MKSH_NOPWNAM
t = NULL; /* fix "unalias -dt" */
#else
t = &homedirs;
#endif
@ -1199,6 +1203,10 @@ c_unalias(const char **wp)
case '?':
return (1);
}
#ifdef MKSH_NOPWNAM
if (t == NULL)
return (0);
#endif
wp += builtin_opt.optind;
for (; *wp != NULL; wp++) {

4
main.c
View File

@ -33,7 +33,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.133 2009/06/11 12:42:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.134 2009/07/25 20:26:32 tg Exp $");
extern char **environ;
@ -141,7 +141,7 @@ main(int argc, const char *argv[])
/* set up variable and command dictionaries */
ktinit(&taliases, APERM, 0);
ktinit(&aliases, APERM, 0);
#ifndef MKSH_SMALL
#ifndef MKSH_NOPWNAM
ktinit(&homedirs, APERM, 0);
#endif

11
sh.h
View File

@ -122,7 +122,7 @@
#define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.314 2009/07/25 20:18:13 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.315 2009/07/25 20:26:33 tg Exp $");
#endif
#define MKSH_VERSION "R39 2009/07/16"
@ -430,9 +430,14 @@ char *ucstrstr(char *, const char *);
#define stristr(b,l) ((const char *)strcasestr((b), (l)))
#endif
#if defined(MKSH_SMALL) && !defined(MKSH_NOVI)
#ifdef MKSH_SMALL
#ifndef MKSH_NOPWNAM
#define MKSH_NOPWNAM
#endif
#ifndef MKSH_NOVI
#define MKSH_NOVI
#endif
#endif
/*
* simple grouping allocator
@ -951,7 +956,7 @@ EXTERN struct table taliases; /* tracked aliases */
EXTERN struct table builtins; /* built-in commands */
EXTERN struct table aliases; /* aliases */
EXTERN struct table keywords; /* keywords */
#ifndef MKSH_SMALL
#ifndef MKSH_NOPWNAM
EXTERN struct table homedirs; /* homedir() cache */
#endif