much better solution: save tablep and hash value¹ in the struct tbl entry
① also saves time during texpand :D XXX this doesn’t work well with the current indexed-array implementation
This commit is contained in:
16
funcs.c
16
funcs.c
@ -25,7 +25,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.122 2009/08/28 19:57:40 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.123 2009/08/28 20:30:56 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -637,11 +637,13 @@ c_whence(const char **wp)
|
||||
fcflags &= ~(FC_BI | FC_FUNC);
|
||||
|
||||
while ((vflag || rv == 0) && (id = *wp++) != NULL) {
|
||||
uint32_t h = 0;
|
||||
|
||||
tp = NULL;
|
||||
if ((iam_whence || vflag) && !pflag)
|
||||
tp = ktsearch(&keywords, id, hash(id), NULL);
|
||||
tp = ktsearch(&keywords, id, h = hash(id));
|
||||
if (!tp && !pflag) {
|
||||
tp = ktsearch(&aliases, id, hash(id), NULL);
|
||||
tp = ktsearch(&aliases, id, h ? h : hash(id));
|
||||
if (tp && !(tp->flag & ISSET))
|
||||
tp = NULL;
|
||||
}
|
||||
@ -879,7 +881,7 @@ c_typeset(const char **wp)
|
||||
for (i = builtin_opt.optind; wp[i]; i++) {
|
||||
if (func) {
|
||||
f = findfunc(wp[i], hash(wp[i]),
|
||||
(fset&UCASEV_AL) ? true : false, NULL);
|
||||
(fset&UCASEV_AL) ? true : false);
|
||||
if (!f) {
|
||||
/* AT&T ksh does ++rv: bogus */
|
||||
rv = 1;
|
||||
@ -1138,7 +1140,7 @@ c_alias(const char **wp)
|
||||
}
|
||||
h = hash(alias);
|
||||
if (val == NULL && !tflag && !xflag) {
|
||||
ap = ktsearch(t, alias, h, NULL);
|
||||
ap = ktsearch(t, alias, h);
|
||||
if (ap != NULL && (ap->flag&ISSET)) {
|
||||
if (pflag)
|
||||
shf_puts("alias ", shl_stdout);
|
||||
@ -1154,7 +1156,7 @@ c_alias(const char **wp)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ap = ktenter(t, alias, h, NULL);
|
||||
ap = ktenter(t, alias, h);
|
||||
ap->type = tflag ? CTALIAS : CALIAS;
|
||||
/* Are we setting the value or just some flags? */
|
||||
if ((val && !tflag) || (!val && tflag && !Uflag)) {
|
||||
@ -1214,7 +1216,7 @@ c_unalias(const char **wp)
|
||||
wp += builtin_opt.optind;
|
||||
|
||||
for (; *wp != NULL; wp++) {
|
||||
ap = ktsearch(t, *wp, hash(*wp), NULL);
|
||||
ap = ktsearch(t, *wp, hash(*wp));
|
||||
if (ap == NULL) {
|
||||
rv = 1; /* POSIX */
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user