diff --git a/src/cmd/ksh93/include/name.h b/src/cmd/ksh93/include/name.h index 05efa74d6..fd9c34f1d 100644 --- a/src/cmd/ksh93/include/name.h +++ b/src/cmd/ksh93/include/name.h @@ -31,9 +31,6 @@ #include #include -typedef struct Shbltin_s Shbltin_t; -typedef int (*Shbltin_f)(int, char**, Shbltin_t*); - /* Nodes can have all kinds of values */ union Value { @@ -55,7 +52,7 @@ union Value struct Ufunction *rp; /* shell user defined functions */ struct Namfun *funp; /* discipline pointer */ struct Namref *nrp; /* name reference */ - Shbltin_f bfp; /* builtin entry point function pointer */ + void *bfp; /* pointer to built-in command's entry function (typecast to Shbltin_f) */ }; #include "nval.h" @@ -150,7 +147,6 @@ struct Ufunction #define is_abuiltin(n) (nv_isattr(n,NV_BLTIN|NV_INTEGER)==NV_BLTIN) #define is_afunction(n) (nv_isattr(n,NV_FUNCTION|NV_REF)==NV_FUNCTION) #define nv_funtree(n) ((n)->nvalue.rp->ptree) -#define funptr(n) ((n)->nvalue.bfp) /* NAMNOD MACROS */ /* ... for attributes */ diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h index da2e426a5..96ad0ca73 100644 --- a/src/cmd/ksh93/include/shell.h +++ b/src/cmd/ksh93/include/shell.h @@ -52,6 +52,9 @@ typedef struct Shell_s Shell_t; #include +/* get pointer to a built-in command's entry function */ +#define funptr(n) ((Shbltin_f)(n)->nvalue.bfp) + typedef void (*Shinit_f)(Shell_t*, int); #ifndef SH_wait_f_defined typedef int (*Shwait_f)(int, long, int); diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index e35922f0d..217b9d223 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -1992,7 +1992,7 @@ Dt_t *sh_inittree(const struct shtable2 *name_vals) } np->nvenv = 0; if(name_vals==(const struct shtable2*)shtab_builtins) - np->nvalue.bfp = ((struct shtable3*)tp)->sh_value; + np->nvalue.bfp = (void*)((struct shtable3*)tp)->sh_value; else { if(name_vals == shtab_variables) diff --git a/src/cmd/ksh93/sh/nvdisc.c b/src/cmd/ksh93/sh/nvdisc.c index b2fa557f1..f4c5a02f2 100644 --- a/src/cmd/ksh93/sh/nvdisc.c +++ b/src/cmd/ksh93/sh/nvdisc.c @@ -1173,7 +1173,7 @@ Namval_t *sh_addbuiltin(const char *path, Shbltin_f bltin, void *extra) np->nvfun = 0; if(bltin) { - np->nvalue.bfp = bltin; + np->nvalue.bfp = (void*)bltin; nv_onattr(np,NV_BLTIN|NV_NOFREE); np->nvfun = (Namfun_t*)extra; } diff --git a/src/lib/libast/include/shcmd.h b/src/lib/libast/include/shcmd.h index 09f1e128c..4d40cb073 100644 --- a/src/lib/libast/include/shcmd.h +++ b/src/lib/libast/include/shcmd.h @@ -69,7 +69,7 @@ struct Shbltin_s int invariant; }; -#if defined(SH_VERSION) || defined(_SH_PRIVATE) +#if defined(shell_h_defined) || defined(defs_h_defined) # undef Shell_t # undef Namval_t #else