From c7a34802238313f1be2ae275ebea676e8465483b Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Thu, 27 Mar 2003 18:50:14 +0000 Subject: [PATCH] Allow wpp users to undefine previously defined symbols. --- tools/wpp/preproc.c | 6 +++--- tools/wpp/wpp.c | 7 +++++++ tools/wpp/wpp.h | 1 + tools/wpp/wpp_private.h | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/wpp/preproc.c b/tools/wpp/preproc.c index 868a2b0bb84..90561c01f3a 100644 --- a/tools/wpp/preproc.c +++ b/tools/wpp/preproc.c @@ -99,7 +99,7 @@ char *pp_xstrdup(const char *str) } /* Don't comment on the hash, its primitive but functional... */ -int pphash(char *str) +static int pphash(const char *str) { int sum = 0; while(*str) @@ -107,7 +107,7 @@ int pphash(char *str) return sum % HASHKEY; } -pp_entry_t *pplookup(char *ident) +pp_entry_t *pplookup(const char *ident) { int idx = pphash(ident); pp_entry_t *ppp; @@ -120,7 +120,7 @@ pp_entry_t *pplookup(char *ident) return NULL; } -void pp_del_define(char *name) +void pp_del_define(const char *name) { int idx; pp_entry_t *ppp; diff --git a/tools/wpp/wpp.c b/tools/wpp/wpp.c index 49c2395f424..04a98ab3a12 100644 --- a/tools/wpp/wpp.c +++ b/tools/wpp/wpp.c @@ -58,6 +58,13 @@ void wpp_add_define( const char *name, const char *value ) } +/* undefine a previously added definition */ +void wpp_del_define( const char *value ) +{ + pp_del_define( value ); +} + + /* add a command-line define of the form NAME=VALUE */ void wpp_add_cmdline_define( const char *value ) { diff --git a/tools/wpp/wpp.h b/tools/wpp/wpp.h index 79abf72eeec..681dca78620 100644 --- a/tools/wpp/wpp.h +++ b/tools/wpp/wpp.h @@ -24,6 +24,7 @@ #include extern void wpp_add_define( const char *name, const char *value ); +extern void wpp_del_define( const char *name ); extern void wpp_add_cmdline_define( const char *value ); extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug ); extern void wpp_set_pedantic( int on ); diff --git a/tools/wpp/wpp_private.h b/tools/wpp/wpp_private.h index 19b7e51c262..aa241048733 100644 --- a/tools/wpp/wpp_private.h +++ b/tools/wpp/wpp_private.h @@ -194,10 +194,10 @@ typedef struct cval { void *pp_xmalloc(size_t); void *pp_xrealloc(void *, size_t); char *pp_xstrdup(const char *str); -pp_entry_t *pplookup(char *ident); +pp_entry_t *pplookup(const char *ident); pp_entry_t *pp_add_define(char *def, char *text); pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp); -void pp_del_define(char *name); +void pp_del_define(const char *name); FILE *pp_open_include(const char *name, int search, char **newpath); void pp_push_if(pp_if_state_t s); void pp_next_if_state(int);