mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
restore C90 compat: do not repeat a typedef (re: 3e0da770)
We try to stay compatibile with C90. Turns out that repeating a typedef is valid only from C11 onwards, as a feature taken from C++. So I goofed and broke the build on old or strict compilers. src/cmd/ksh93/include/{name,shell}.h: - union Value: Since we will now once again have to typecast to use nvalue.bfp in any case, just make it a void pointer; that is how pointers that require typecasts are handled in every other case. - Since the funptr() macro needs a typecast to Shbltin_f which is defined in libast's shcmd.h, move this macro to shell.h which (unlike name.h) includes that header. src/cmd/ksh93/sh/{init,nvdisc}.c: - Typecast to void* when assigning to *->nvalue.bfp. src/lib/libast/include/shcmd.h: - Use shell_h_defined (introduced in 4491bc6a) and defs_h_defined to check if ksh's shell.h or defs.h were included before shcmd.h, instead of random macros defined by them; much clearer.
This commit is contained in:
parent
24c3d77e3c
commit
366efa4b06
5 changed files with 7 additions and 8 deletions
|
@ -31,9 +31,6 @@
|
|||
#include <ast.h>
|
||||
#include <cdt.h>
|
||||
|
||||
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 */
|
||||
|
|
|
@ -52,6 +52,9 @@ typedef struct Shell_s Shell_t;
|
|||
|
||||
#include <shcmd.h>
|
||||
|
||||
/* 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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue