Module Name: src
Committed By: kamil
Date: Wed Jan 24 09:53:21 UTC 2018
Modified Files:
src/bin/ksh: c_ksh.c exec.c lex.c proto.h table.c var.c vi.c
Log Message:
ksh: Rename a local function tsearch to mytsearch
This removes a clash with well-known libc function tsearch(3) from POSIX.
This allows to build ksh against MSan.
The new name might not be perfect, but long term ksh should be switched to
the libc version.
Sponsored by <The NetBSD Foundation>
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/bin/ksh/c_ksh.c
cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/exec.c
cvs rdiff -u -r1.21 -r1.22 src/bin/ksh/lex.c
cvs rdiff -u -r1.11 -r1.12 src/bin/ksh/proto.h
cvs rdiff -u -r1.5 -r1.6 src/bin/ksh/table.c
cvs rdiff -u -r1.22 -r1.23 src/bin/ksh/var.c
cvs rdiff -u -r1.18 -r1.19 src/bin/ksh/vi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/ksh/c_ksh.c
diff -u src/bin/ksh/c_ksh.c:1.26 src/bin/ksh/c_ksh.c:1.27
--- src/bin/ksh/c_ksh.c:1.26 Fri Jun 30 04:41:19 2017
+++ src/bin/ksh/c_ksh.c Wed Jan 24 09:53:20 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: c_ksh.c,v 1.26 2017/06/30 04:41:19 kamil Exp $ */
+/* $NetBSD: c_ksh.c,v 1.27 2018/01/24 09:53:20 kamil Exp $ */
/*
* built-in Korn commands: c_*
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: c_ksh.c,v 1.26 2017/06/30 04:41:19 kamil Exp $");
+__RCSID("$NetBSD: c_ksh.c,v 1.27 2018/01/24 09:53:20 kamil Exp $");
#endif
#include <sys/stat.h>
@@ -470,9 +470,9 @@ c_whence(wp)
while ((vflag || ret == 0) && (id = *wp++) != NULL) {
tp = NULL;
if ((iam_whence || vflag) && !pflag)
- tp = tsearch(&keywords, id, hash(id));
+ tp = mytsearch(&keywords, id, hash(id));
if (!tp && !pflag) {
- tp = tsearch(&aliases, id, hash(id));
+ tp = mytsearch(&aliases, id, hash(id));
if (tp && !(tp->flag & ISSET))
tp = NULL;
}
@@ -946,7 +946,7 @@ c_alias(wp)
alias = str_nsave(alias, val++ - alias, ATEMP);
h = hash(alias);
if (val == NULL && !tflag && !xflag) {
- ap = tsearch(t, alias, h);
+ ap = mytsearch(t, alias, h);
if (ap != NULL && (ap->flag&ISSET)) {
if (pflag)
shf_puts("alias ", shl_stdout);
@@ -1017,7 +1017,7 @@ c_unalias(wp)
wp += builtin_opt.optind;
for (; *wp != NULL; wp++) {
- ap = tsearch(t, *wp, hash(*wp));
+ ap = mytsearch(t, *wp, hash(*wp));
if (ap == NULL) {
rv = 1; /* POSIX */
continue;
Index: src/bin/ksh/exec.c
diff -u src/bin/ksh/exec.c:1.25 src/bin/ksh/exec.c:1.26
--- src/bin/ksh/exec.c:1.25 Wed Jan 24 09:21:20 2018
+++ src/bin/ksh/exec.c Wed Jan 24 09:53:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.25 2018/01/24 09:21:20 kamil Exp $ */
+/* $NetBSD: exec.c,v 1.26 2018/01/24 09:53:21 kamil Exp $ */
/*
* execute command tree
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: exec.c,v 1.25 2018/01/24 09:21:20 kamil Exp $");
+__RCSID("$NetBSD: exec.c,v 1.26 2018/01/24 09:53:21 kamil Exp $");
#endif
#include <sys/stat.h>
@@ -775,7 +775,7 @@ shcomexec(wp)
{
register struct tbl *tp;
- tp = tsearch(&builtins, *wp, hash(*wp));
+ tp = mytsearch(&builtins, *wp, hash(*wp));
if (tp == NULL)
internal_errorf(1, "shcomexec: %s", *wp);
return call_builtin(tp, wp);
@@ -795,7 +795,7 @@ findfunc(name, h, create)
struct tbl *tp = (struct tbl *) 0;
for (l = e->loc; l; l = l->next) {
- tp = tsearch(&l->funs, name, h);
+ tp = mytsearch(&l->funs, name, h);
if (tp)
break;
if (!l->next && create) {
@@ -906,7 +906,7 @@ findcom(name, flags)
flags &= ~FC_FUNC;
goto Search;
}
- tbi = (flags & FC_BI) ? tsearch(&builtins, name, h) : NULL;
+ tbi = (flags & FC_BI) ? mytsearch(&builtins, name, h) : NULL;
/* POSIX says special builtins first, then functions, then
* POSIX regular builtins, then search path...
*/
@@ -936,7 +936,7 @@ findcom(name, flags)
if (!tp && (flags & FC_UNREGBI) && tbi)
tp = tbi;
if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
- tp = tsearch(&taliases, name, h);
+ tp = mytsearch(&taliases, name, h);
if (tp && (tp->flag & ISSET) && eaccess(tp->val.s, X_OK) != 0) {
if (tp->flag & ALLOC) {
tp->flag &= ~ALLOC;
Index: src/bin/ksh/lex.c
diff -u src/bin/ksh/lex.c:1.21 src/bin/ksh/lex.c:1.22
--- src/bin/ksh/lex.c:1.21 Fri Jun 30 04:41:19 2017
+++ src/bin/ksh/lex.c Wed Jan 24 09:53:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.21 2017/06/30 04:41:19 kamil Exp $ */
+/* $NetBSD: lex.c,v 1.22 2018/01/24 09:53:21 kamil Exp $ */
/*
* lexical analysis and source input
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lex.c,v 1.21 2017/06/30 04:41:19 kamil Exp $");
+__RCSID("$NetBSD: lex.c,v 1.22 2018/01/24 09:53:21 kamil Exp $");
#endif
@@ -734,13 +734,13 @@ Done:
int h = hash(ident);
/* { */
- if ((cf & KEYWORD) && (p = tsearch(&keywords, ident, h))
+ if ((cf & KEYWORD) && (p = mytsearch(&keywords, ident, h))
&& (!(cf & ESACONLY) || p->val.i == ESAC || p->val.i == '}'))
{
afree(yylval.cp, ATEMP);
return p->val.i;
}
- if ((cf & ALIAS) && (p = tsearch(&aliases, ident, h))
+ if ((cf & ALIAS) && (p = mytsearch(&aliases, ident, h))
&& (p->flag & ISSET))
{
register Source *s;
Index: src/bin/ksh/proto.h
diff -u src/bin/ksh/proto.h:1.11 src/bin/ksh/proto.h:1.12
--- src/bin/ksh/proto.h:1.11 Wed Jan 24 09:21:20 2018
+++ src/bin/ksh/proto.h Wed Jan 24 09:53:21 2018
@@ -1,9 +1,9 @@
-/* $NetBSD: proto.h,v 1.11 2018/01/24 09:21:20 kamil Exp $ */
+/* $NetBSD: proto.h,v 1.12 2018/01/24 09:53:21 kamil Exp $ */
/*
* prototypes for PD-KSH
* originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
- * $Id: proto.h,v 1.11 2018/01/24 09:21:20 kamil Exp $
+ * $Id: proto.h,v 1.12 2018/01/24 09:53:21 kamil Exp $
*/
#include <stdbool.h>
@@ -216,7 +216,7 @@ struct op * compile ARGS((Source *));
/* table.c */
unsigned int hash ARGS((const char *));
void tinit ARGS((struct table *, Area *, int));
-struct tbl * tsearch ARGS((struct table *, const char *, unsigned int));
+struct tbl * mytsearch ARGS((struct table *, const char *, unsigned int));
struct tbl * tenter ARGS((struct table *, const char *, unsigned int));
void mytdelete ARGS((struct tbl *));
void twalk ARGS((struct tstate *, struct table *));
Index: src/bin/ksh/table.c
diff -u src/bin/ksh/table.c:1.5 src/bin/ksh/table.c:1.6
--- src/bin/ksh/table.c:1.5 Wed Jan 24 09:21:20 2018
+++ src/bin/ksh/table.c Wed Jan 24 09:53:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: table.c,v 1.5 2018/01/24 09:21:20 kamil Exp $ */
+/* $NetBSD: table.c,v 1.6 2018/01/24 09:53:21 kamil Exp $ */
/*
* dynamic hashed associative table for commands and variables
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: table.c,v 1.5 2018/01/24 09:21:20 kamil Exp $");
+__RCSID("$NetBSD: table.c,v 1.6 2018/01/24 09:53:21 kamil Exp $");
#endif
@@ -79,7 +79,7 @@ texpand(tp, nsize)
}
struct tbl *
-tsearch(tp, n, h)
+mytsearch(tp, n, h)
register struct table *tp; /* table */
register const char *n; /* name to enter */
unsigned int h; /* hash(n) */
@@ -223,7 +223,7 @@ tprintinfo(tp)
h = hash(n = te->name);
ncmp = 0;
- /* taken from tsearch() and added counter */
+ /* taken from mytsearch() and added counter */
for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp); pp--) {
ncmp++;
if (*p->name == *n && strcmp(p->name, n) == 0
Index: src/bin/ksh/var.c
diff -u src/bin/ksh/var.c:1.22 src/bin/ksh/var.c:1.23
--- src/bin/ksh/var.c:1.22 Wed Jan 24 09:21:20 2018
+++ src/bin/ksh/var.c Wed Jan 24 09:53:21 2018
@@ -1,9 +1,9 @@
-/* $NetBSD: var.c,v 1.22 2018/01/24 09:21:20 kamil Exp $ */
+/* $NetBSD: var.c,v 1.23 2018/01/24 09:53:21 kamil Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: var.c,v 1.22 2018/01/24 09:21:20 kamil Exp $");
+__RCSID("$NetBSD: var.c,v 1.23 2018/01/24 09:53:21 kamil Exp $");
#endif
#include <sys/stat.h>
@@ -231,7 +231,7 @@ global(n)
return vp;
}
for (l = e->loc; ; l = l->next) {
- vp = tsearch(&l->vars, n, h);
+ vp = mytsearch(&l->vars, n, h);
if (vp != NULL) {
if (array)
return arraysearch(vp, val);
@@ -277,7 +277,7 @@ local(const char *n, bool copy)
struct block *ll = l;
struct tbl *vq = (struct tbl *) 0;
- while ((ll = ll->next) && !(vq = tsearch(&ll->vars, n, h)))
+ while ((ll = ll->next) && !(vq = mytsearch(&ll->vars, n, h)))
;
if (vq) {
vp->flag |= vq->flag & (EXPORT|INTEGER|RDONLY
@@ -886,7 +886,7 @@ makenv()
/* unexport any redefined instances */
for (l2 = l->next; l2 != NULL; l2 = l2->next) {
- vp2 = tsearch(&l2->vars, vp->name, h);
+ vp2 = mytsearch(&l2->vars, vp->name, h);
if (vp2 != NULL)
vp2->flag &= ~EXPORT;
}
@@ -926,7 +926,7 @@ special(name)
{
register struct tbl *tp;
- tp = tsearch(&specials, name, hash(name));
+ tp = mytsearch(&specials, name, hash(name));
return tp && (tp->flag & ISSET) ? tp->type : V_NONE;
}
@@ -937,7 +937,7 @@ unspecial(name)
{
register struct tbl *tp;
- tp = tsearch(&specials, name, hash(name));
+ tp = mytsearch(&specials, name, hash(name));
if (tp)
mytdelete(tp);
}
Index: src/bin/ksh/vi.c
diff -u src/bin/ksh/vi.c:1.18 src/bin/ksh/vi.c:1.19
--- src/bin/ksh/vi.c:1.18 Fri Jun 30 04:41:19 2017
+++ src/bin/ksh/vi.c Wed Jan 24 09:53:21 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.18 2017/06/30 04:41:19 kamil Exp $ */
+/* $NetBSD: vi.c,v 1.19 2018/01/24 09:53:21 kamil Exp $ */
/*
* vi command editing
@@ -9,7 +9,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: vi.c,v 1.18 2017/06/30 04:41:19 kamil Exp $");
+__RCSID("$NetBSD: vi.c,v 1.19 2018/01/24 09:53:21 kamil Exp $");
#endif
#include "config.h"
@@ -741,7 +741,7 @@ vi_cmd(argcnt, cmd)
/* lookup letter in alias list... */
alias[1] = cmd[1];
- ap = tsearch(&aliases, alias, hash(alias));
+ ap = mytsearch(&aliases, alias, hash(alias));
if (!cmd[1] || !ap || !(ap->flag & ISSET))
return -1;
/* check if this is a recursive call... */