Sun Jun 3 12:18:29 2018 UTC ()
ksh: Remove symbol clash with libc

Rename local function twalk() to ksh_twak().
This is needed for installing interceptors in sanitizers.

Sponsored by <The NetBSD Foundation>


(kamil)
diff -r1.28 -r1.29 src/bin/ksh/c_ksh.c
diff -r1.34 -r1.35 src/bin/ksh/edit.c
diff -r1.27 -r1.28 src/bin/ksh/exec.c
diff -r1.12 -r1.13 src/bin/ksh/proto.h
diff -r1.7 -r1.8 src/bin/ksh/table.c
diff -r1.3 -r1.4 src/bin/ksh/table.h

cvs diff -r1.28 -r1.29 src/bin/ksh/c_ksh.c (expand / switch to unified diff)

--- src/bin/ksh/c_ksh.c 2018/05/08 16:37:59 1.28
+++ src/bin/ksh/c_ksh.c 2018/06/03 12:18:29 1.29
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: c_ksh.c,v 1.28 2018/05/08 16:37:59 kamil Exp $ */ 1/* $NetBSD: c_ksh.c,v 1.29 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * built-in Korn commands: c_* 4 * built-in Korn commands: c_*
5 */ 5 */
6#include <sys/cdefs.h> 6#include <sys/cdefs.h>
7 7
8#ifndef lint 8#ifndef lint
9__RCSID("$NetBSD: c_ksh.c,v 1.28 2018/05/08 16:37:59 kamil Exp $"); 9__RCSID("$NetBSD: c_ksh.c,v 1.29 2018/06/03 12:18:29 kamil Exp $");
10#endif 10#endif
11 11
12#include <sys/stat.h> 12#include <sys/stat.h>
13#include <ctype.h> 13#include <ctype.h>
14 14
15#include "sh.h" 15#include "sh.h"
16 16
17int 17int
18c_cd(wp) 18c_cd(wp)
19 char **wp; 19 char **wp;
20{ 20{
21 int optc; 21 int optc;
22 int physical = Flag(FPHYSICAL); 22 int physical = Flag(FPHYSICAL);
@@ -1022,27 +1022,27 @@ c_unalias(wp) @@ -1022,27 +1022,27 @@ c_unalias(wp)
1022 rv = 1; /* POSIX */ 1022 rv = 1; /* POSIX */
1023 continue; 1023 continue;
1024 } 1024 }
1025 if (ap->flag&ALLOC) { 1025 if (ap->flag&ALLOC) {
1026 ap->flag &= ~(ALLOC|ISSET); 1026 ap->flag &= ~(ALLOC|ISSET);
1027 afree((void*)ap->val.s, APERM); 1027 afree((void*)ap->val.s, APERM);
1028 } 1028 }
1029 ap->flag &= ~(DEFINED|ISSET|EXPORT); 1029 ap->flag &= ~(DEFINED|ISSET|EXPORT);
1030 } 1030 }
1031 1031
1032 if (all) { 1032 if (all) {
1033 struct tstate ts; 1033 struct tstate ts;
1034 1034
1035 for (twalk(&ts, t); (ap = tnext(&ts)); ) { 1035 for (ksh_twalk(&ts, t); (ap = tnext(&ts)); ) {
1036 if (ap->flag&ALLOC) { 1036 if (ap->flag&ALLOC) {
1037 ap->flag &= ~(ALLOC|ISSET); 1037 ap->flag &= ~(ALLOC|ISSET);
1038 afree((void*)ap->val.s, APERM); 1038 afree((void*)ap->val.s, APERM);
1039 } 1039 }
1040 ap->flag &= ~(DEFINED|ISSET|EXPORT); 1040 ap->flag &= ~(DEFINED|ISSET|EXPORT);
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 return rv; 1044 return rv;
1045} 1045}
1046 1046
1047#ifdef KSH 1047#ifdef KSH
1048int 1048int

cvs diff -r1.34 -r1.35 src/bin/ksh/edit.c (expand / switch to unified diff)

--- src/bin/ksh/edit.c 2017/07/01 23:12:08 1.34
+++ src/bin/ksh/edit.c 2018/06/03 12:18:29 1.35
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: edit.c,v 1.34 2017/07/01 23:12:08 joerg Exp $ */ 1/* $NetBSD: edit.c,v 1.35 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * Command line editing - common code 4 * Command line editing - common code
5 * 5 *
6 */ 6 */
7#include <sys/cdefs.h> 7#include <sys/cdefs.h>
8 8
9#ifndef lint 9#ifndef lint
10__RCSID("$NetBSD: edit.c,v 1.34 2017/07/01 23:12:08 joerg Exp $"); 10__RCSID("$NetBSD: edit.c,v 1.35 2018/06/03 12:18:29 kamil Exp $");
11#endif 11#endif
12 12
13#include <stdbool.h> 13#include <stdbool.h>
14 14
15#include "config.h" 15#include "config.h"
16#ifdef EDIT 16#ifdef EDIT
17 17
18#include "sh.h" 18#include "sh.h"
19#include "tty.h" 19#include "tty.h"
20#define EXTERN 20#define EXTERN
21#include "edit.h" 21#include "edit.h"
22#undef EXTERN 22#undef EXTERN
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
@@ -928,27 +928,27 @@ x_basename(s, se) @@ -928,27 +928,27 @@ x_basename(s, se)
928/* 928/*
929 * Apply pattern matching to a table: all table entries that match a pattern 929 * Apply pattern matching to a table: all table entries that match a pattern
930 * are added to wp. 930 * are added to wp.
931 */ 931 */
932static void 932static void
933glob_table(pat, wp, tp) 933glob_table(pat, wp, tp)
934 const char *pat; 934 const char *pat;
935 XPtrV *wp; 935 XPtrV *wp;
936 struct table *tp; 936 struct table *tp;
937{ 937{
938 struct tstate ts; 938 struct tstate ts;
939 struct tbl *te; 939 struct tbl *te;
940 940
941 for (twalk(&ts, tp); (te = tnext(&ts)); ) { 941 for (ksh_twalk(&ts, tp); (te = tnext(&ts)); ) {
942 if (gmatch(te->name, pat, false)) 942 if (gmatch(te->name, pat, false))
943 XPput(*wp, str_save(te->name, ATEMP)); 943 XPput(*wp, str_save(te->name, ATEMP));
944 } 944 }
945} 945}
946 946
947static void 947static void
948glob_path(flags, pat, wp, xpath) 948glob_path(flags, pat, wp, xpath)
949 int flags; 949 int flags;
950 const char *pat; 950 const char *pat;
951 XPtrV *wp; 951 XPtrV *wp;
952 const char *xpath; 952 const char *xpath;
953{ 953{
954 const char *sp, *p; 954 const char *sp, *p;

cvs diff -r1.27 -r1.28 src/bin/ksh/exec.c (expand / switch to unified diff)

--- src/bin/ksh/exec.c 2018/05/08 16:37:59 1.27
+++ src/bin/ksh/exec.c 2018/06/03 12:18:29 1.28
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: exec.c,v 1.27 2018/05/08 16:37:59 kamil Exp $ */ 1/* $NetBSD: exec.c,v 1.28 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * execute command tree 4 * execute command tree
5 */ 5 */
6#include <sys/cdefs.h> 6#include <sys/cdefs.h>
7 7
8#ifndef lint 8#ifndef lint
9__RCSID("$NetBSD: exec.c,v 1.27 2018/05/08 16:37:59 kamil Exp $"); 9__RCSID("$NetBSD: exec.c,v 1.28 2018/06/03 12:18:29 kamil Exp $");
10#endif 10#endif
11 11
12#include <sys/stat.h> 12#include <sys/stat.h>
13#include <ctype.h> 13#include <ctype.h>
14#include <stdbool.h> 14#include <stdbool.h>
15 15
16#include "sh.h" 16#include "sh.h"
17#include "c_test.h" 17#include "c_test.h"
18 18
19/* Does ps4 get parameter substitutions done? */ 19/* Does ps4 get parameter substitutions done? */
20#ifdef KSH 20#ifdef KSH
21# define PS4_SUBSTITUTE(s) substitute((s), 0) 21# define PS4_SUBSTITUTE(s) substitute((s), 0)
22#else 22#else
@@ -989,27 +989,27 @@ findcom(name, flags) @@ -989,27 +989,27 @@ findcom(name, flags)
989 return tp; 989 return tp;
990} 990}
991 991
992/* 992/*
993 * flush executable commands with relative paths 993 * flush executable commands with relative paths
994 */ 994 */
995void 995void
996flushcom(all) 996flushcom(all)
997 int all; /* just relative or all */ 997 int all; /* just relative or all */
998{ 998{
999 struct tbl *tp; 999 struct tbl *tp;
1000 struct tstate ts; 1000 struct tstate ts;
1001 1001
1002 for (twalk(&ts, &taliases); (tp = tnext(&ts)) != NULL; ) 1002 for (ksh_twalk(&ts, &taliases); (tp = tnext(&ts)) != NULL; )
1003 if ((tp->flag&ISSET) && (all || !ISDIRSEP(tp->val.s[0]))) { 1003 if ((tp->flag&ISSET) && (all || !ISDIRSEP(tp->val.s[0]))) {
1004 if (tp->flag&ALLOC) { 1004 if (tp->flag&ALLOC) {
1005 tp->flag &= ~(ALLOC|ISSET); 1005 tp->flag &= ~(ALLOC|ISSET);
1006 afree(tp->val.s, APERM); 1006 afree(tp->val.s, APERM);
1007 } 1007 }
1008 tp->flag &= ~ISSET; 1008 tp->flag &= ~ISSET;
1009 } 1009 }
1010} 1010}
1011 1011
1012/* Check if path is something we want to find. Returns -1 for failure. */ 1012/* Check if path is something we want to find. Returns -1 for failure. */
1013int 1013int
1014search_access(pathx, mode, errnop) 1014search_access(pathx, mode, errnop)
1015 const char *pathx; 1015 const char *pathx;

cvs diff -r1.12 -r1.13 src/bin/ksh/proto.h (expand / switch to unified diff)

--- src/bin/ksh/proto.h 2018/01/24 09:53:21 1.12
+++ src/bin/ksh/proto.h 2018/06/03 12:18:29 1.13
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1/* $NetBSD: proto.h,v 1.12 2018/01/24 09:53:21 kamil Exp $ */ 1/* $NetBSD: proto.h,v 1.13 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * prototypes for PD-KSH 4 * prototypes for PD-KSH
5 * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang " 5 * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
6 * $Id: proto.h,v 1.12 2018/01/24 09:53:21 kamil Exp $ 6 * $Id: proto.h,v 1.13 2018/06/03 12:18:29 kamil Exp $
7 */ 7 */
8 8
9#include <stdbool.h> 9#include <stdbool.h>
10 10
11/* alloc.c */ 11/* alloc.c */
12Area * ainit ARGS((Area *)); 12Area * ainit ARGS((Area *));
13void afreeall ARGS((Area *)); 13void afreeall ARGS((Area *));
14void * alloc ARGS((size_t, Area *)); 14void * alloc ARGS((size_t, Area *));
15void * aresize ARGS((void *, size_t, Area *)); 15void * aresize ARGS((void *, size_t, Area *));
16void afree ARGS((void *, Area *)); 16void afree ARGS((void *, Area *));
17/* c_ksh.c */ 17/* c_ksh.c */
18int c_hash ARGS((char **)); 18int c_hash ARGS((char **));
19int c_cd ARGS((char **)); 19int c_cd ARGS((char **));
@@ -209,27 +209,27 @@ int make_path ARGS((const char *, const  @@ -209,27 +209,27 @@ int make_path ARGS((const char *, const
209 char **, XString *, int *)); 209 char **, XString *, int *));
210void simplify_path ARGS((char *)); 210void simplify_path ARGS((char *));
211char *get_phys_path ARGS((const char *)); 211char *get_phys_path ARGS((const char *));
212void set_current_wd ARGS((char *)); 212void set_current_wd ARGS((char *));
213/* syn.c */ 213/* syn.c */
214void initkeywords ARGS((void)); 214void initkeywords ARGS((void));
215struct op * compile ARGS((Source *)); 215struct op * compile ARGS((Source *));
216/* table.c */ 216/* table.c */
217unsigned int hash ARGS((const char *)); 217unsigned int hash ARGS((const char *));
218void tinit ARGS((struct table *, Area *, int)); 218void tinit ARGS((struct table *, Area *, int));
219struct tbl * mytsearch ARGS((struct table *, const char *, unsigned int)); 219struct tbl * mytsearch ARGS((struct table *, const char *, unsigned int));
220struct tbl * tenter ARGS((struct table *, const char *, unsigned int)); 220struct tbl * tenter ARGS((struct table *, const char *, unsigned int));
221void mytdelete ARGS((struct tbl *)); 221void mytdelete ARGS((struct tbl *));
222void twalk ARGS((struct tstate *, struct table *)); 222void ksh_twalk ARGS((struct tstate *, struct table *));
223struct tbl * tnext ARGS((struct tstate *)); 223struct tbl * tnext ARGS((struct tstate *));
224struct tbl ** tsort ARGS((struct table *)); 224struct tbl ** tsort ARGS((struct table *));
225/* trace.c */ 225/* trace.c */
226/* trap.c */ 226/* trap.c */
227void inittraps ARGS((void)); 227void inittraps ARGS((void));
228#ifdef KSH 228#ifdef KSH
229void alarm_init ARGS((void)); 229void alarm_init ARGS((void));
230#endif /* KSH */ 230#endif /* KSH */
231Trap * gettrap ARGS((const char *, int)); 231Trap * gettrap ARGS((const char *, int));
232RETSIGTYPE trapsig ARGS((int)); 232RETSIGTYPE trapsig ARGS((int));
233void intrcheck ARGS((void)); 233void intrcheck ARGS((void));
234int fatal_trap_check ARGS((void)); 234int fatal_trap_check ARGS((void));
235int trap_pending ARGS((void)); 235int trap_pending ARGS((void));

cvs diff -r1.7 -r1.8 src/bin/ksh/table.c (expand / switch to unified diff)

--- src/bin/ksh/table.c 2018/05/08 16:37:59 1.7
+++ src/bin/ksh/table.c 2018/06/03 12:18:29 1.8
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1/* $NetBSD: table.c,v 1.7 2018/05/08 16:37:59 kamil Exp $ */ 1/* $NetBSD: table.c,v 1.8 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * dynamic hashed associative table for commands and variables 4 * dynamic hashed associative table for commands and variables
5 */ 5 */
6#include <sys/cdefs.h> 6#include <sys/cdefs.h>
7 7
8#ifndef lint 8#ifndef lint
9__RCSID("$NetBSD: table.c,v 1.7 2018/05/08 16:37:59 kamil Exp $"); 9__RCSID("$NetBSD: table.c,v 1.8 2018/06/03 12:18:29 kamil Exp $");
10#endif 10#endif
11 11
12 12
13#include "sh.h" 13#include "sh.h"
14 14
15#define INIT_TBLS 8 /* initial table size (power of 2) */ 15#define INIT_TBLS 8 /* initial table size (power of 2) */
16 16
17static void texpand ARGS((struct table *tp, int nsize)); 17static void texpand ARGS((struct table *tp, int nsize));
18static int tnamecmp ARGS((void *p1, void *p2)); 18static int tnamecmp ARGS((void *p1, void *p2));
19 19
20 20
21unsigned int 21unsigned int
22hash(n) 22hash(n)
@@ -141,27 +141,27 @@ tenter(tp, n, h) @@ -141,27 +141,27 @@ tenter(tp, n, h)
141 tp->nfree--; 141 tp->nfree--;
142 *pp = p; 142 *pp = p;
143 return p; 143 return p;
144} 144}
145 145
146void 146void
147mytdelete(p) 147mytdelete(p)
148 struct tbl *p; 148 struct tbl *p;
149{ 149{
150 p->flag = 0; 150 p->flag = 0;
151} 151}
152 152
153void 153void
154twalk(ts, tp) 154ksh_twalk(ts, tp)
155 struct tstate *ts; 155 struct tstate *ts;
156 struct table *tp; 156 struct table *tp;
157{ 157{
158 ts->left = tp->size; 158 ts->left = tp->size;
159 ts->next = tp->tbls; 159 ts->next = tp->tbls;
160} 160}
161 161
162struct tbl * 162struct tbl *
163tnext(ts) 163tnext(ts)
164 struct tstate *ts; 164 struct tstate *ts;
165{ 165{
166 while (--ts->left >= 0) { 166 while (--ts->left >= 0) {
167 struct tbl *p = *ts->next++; 167 struct tbl *p = *ts->next++;
@@ -206,27 +206,27 @@ void @@ -206,27 +206,27 @@ void
206tprintinfo(tp) 206tprintinfo(tp)
207 struct table *tp; 207 struct table *tp;
208{ 208{
209 struct tbl *te; 209 struct tbl *te;
210 char *n; 210 char *n;
211 unsigned int h; 211 unsigned int h;
212 int ncmp; 212 int ncmp;
213 int totncmp = 0, maxncmp = 0; 213 int totncmp = 0, maxncmp = 0;
214 int nentries = 0; 214 int nentries = 0;
215 struct tstate ts; 215 struct tstate ts;
216 216
217 shellf("table size %d, nfree %d\n", tp->size, tp->nfree); 217 shellf("table size %d, nfree %d\n", tp->size, tp->nfree);
218 shellf(" Ncmp name\n"); 218 shellf(" Ncmp name\n");
219 twalk(&ts, tp); 219 ksh_twalk(&ts, tp);
220 while ((te = tnext(&ts))) { 220 while ((te = tnext(&ts))) {
221 struct tbl **pp, *p; 221 struct tbl **pp, *p;
222 222
223 h = hash(n = te->name); 223 h = hash(n = te->name);
224 ncmp = 0; 224 ncmp = 0;
225 225
226 /* taken from mytsearch() and added counter */ 226 /* taken from mytsearch() and added counter */
227 for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp); pp--) { 227 for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp); pp--) {
228 ncmp++; 228 ncmp++;
229 if (*p->name == *n && strcmp(p->name, n) == 0 229 if (*p->name == *n && strcmp(p->name, n) == 0
230 && (p->flag&DEFINED)) 230 && (p->flag&DEFINED))
231 break; /* return p; */ 231 break; /* return p; */
232 if (pp == tp->tbls) /* wrap */ 232 if (pp == tp->tbls) /* wrap */

cvs diff -r1.3 -r1.4 src/bin/ksh/table.h (expand / switch to unified diff)

--- src/bin/ksh/table.h 1999/10/20 15:10:00 1.3
+++ src/bin/ksh/table.h 2018/06/03 12:18:29 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: table.h,v 1.3 1999/10/20 15:10:00 hubertf Exp $ */ 1/* $NetBSD: table.h,v 1.4 2018/06/03 12:18:29 kamil Exp $ */
2 2
3/* 3/*
4 * generic hashed associative table for commands and variables. 4 * generic hashed associative table for commands and variables.
5 */ 5 */
6 6
7struct table { 7struct table {
8 Area *areap; /* area to allocate entries */ 8 Area *areap; /* area to allocate entries */
9 short size, nfree; /* hash size (always 2^^n), free entries */ 9 short size, nfree; /* hash size (always 2^^n), free entries */
10 struct tbl **tbls; /* hashed table items */ 10 struct tbl **tbls; /* hashed table items */
11}; 11};
12 12
13struct tbl { /* table item */ 13struct tbl { /* table item */
14 Tflag flag; /* flags */ 14 Tflag flag; /* flags */
@@ -117,27 +117,27 @@ struct block { @@ -117,27 +117,27 @@ struct block {
117#if 1 117#if 1
118 char * error; /* error handler */ 118 char * error; /* error handler */
119 char * exit; /* exit handler */ 119 char * exit; /* exit handler */
120#else 120#else
121 Trap error, exit; 121 Trap error, exit;
122#endif 122#endif
123 struct block *next; /* enclosing block */ 123 struct block *next; /* enclosing block */
124}; 124};
125 125
126/* Values for struct block.flags */ 126/* Values for struct block.flags */
127#define BF_DOGETOPTS BIT(0) /* save/restore getopts state */ 127#define BF_DOGETOPTS BIT(0) /* save/restore getopts state */
128 128
129/* 129/*
130 * Used by twalk() and tnext() routines. 130 * Used by ksh_twalk() and tnext() routines.
131 */ 131 */
132struct tstate { 132struct tstate {
133 int left; 133 int left;
134 struct tbl **next; 134 struct tbl **next;
135}; 135};
136 136
137 137
138EXTERN struct table taliases; /* tracked aliases */ 138EXTERN struct table taliases; /* tracked aliases */
139EXTERN struct table builtins; /* built-in commands */ 139EXTERN struct table builtins; /* built-in commands */
140EXTERN struct table aliases; /* aliases */ 140EXTERN struct table aliases; /* aliases */
141EXTERN struct table keywords; /* keywords */ 141EXTERN struct table keywords; /* keywords */
142EXTERN struct table homedirs; /* homedir() cache */ 142EXTERN struct table homedirs; /* homedir() cache */
143 143