From 80cd4c155dd04fab346e3f61c6a7b67a802dab98 Mon Sep 17 00:00:00 2001 From: jpco Date: Sun, 29 Dec 2024 14:09:31 -0800 Subject: [PATCH] Fix -pedantic warnings as well --- main.c | 2 ++ match.c | 2 +- prim.c | 6 +++--- prim.h | 8 ++++++-- var.c | 4 +++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index fca2fe8b..90f8ef41 100644 --- a/main.c +++ b/main.c @@ -82,6 +82,8 @@ static Noreturn usage(void) { " -p don't load functions from the environment\n" " -o don't open stdin, stdout, and stderr if they were closed\n" " -d don't ignore SIGQUIT or SIGTERM\n" + ); + eprint( #if GCINFO " -I print garbage collector information\n" #endif diff --git a/match.c b/match.c index d419c8f1..1204cb67 100644 --- a/match.c +++ b/match.c @@ -28,7 +28,7 @@ static int rangematch(const char *p, const char *q, char c) { Boolean neg; Boolean matched = FALSE; Boolean advanceq = (q != QUOTED && q != UNQUOTED); -#define QX(expr) (advanceq ? (expr) : (void)0) +#define QX(expr) (advanceq ? (expr) : 0) if (*p == '~' && !ISQUOTED(q, 0)) { p++, QX(q++); neg = TRUE; diff --git a/prim.c b/prim.c index 13a66ae7..74d7866f 100644 --- a/prim.c +++ b/prim.c @@ -6,11 +6,11 @@ static Dict *prims; extern List *prim(char *s, List *list, Binding *binding, int evalflags) { - List *(*p)(List *, Binding *, int); - p = (List *(*)(List *, Binding *, int)) dictget(prims, s); + Prim *p; + p = (Prim *) dictget(prims, s); if (p == NULL) fail("es:prim", "unknown primitive: %s", s); - return (*p)(list, binding, evalflags); + return (p->prim)(list, binding, evalflags); } static char *list_prefix; diff --git a/prim.h b/prim.h index 68e346bf..a6a0db05 100644 --- a/prim.h +++ b/prim.h @@ -1,12 +1,16 @@ /* prim.h -- definitions for es primitives ($Revision: 1.1.1.1 $) */ +typedef struct { List *(*prim)(List *, Binding *, int); } Prim; + #define PRIM(name) static List *CONCAT(prim_,name)( \ List UNUSED *list, Binding UNUSED *binding, int UNUSED evalflags \ ) -#define X(name) (primdict = dictput( \ +#define X(name) STMT( \ + static Prim CONCAT(prim_struct_,name) = { CONCAT(prim_,name) }; \ + primdict = dictput( \ primdict, \ STRING(name), \ - (void *) CONCAT(prim_,name) \ + (void *) &CONCAT(prim_struct_,name) \ )) extern Dict *initprims_controlflow(Dict *primdict); /* prim-ctl.c */ diff --git a/var.c b/var.c index 94219653..a2f50e2f 100644 --- a/var.c +++ b/var.c @@ -114,6 +114,8 @@ static Boolean isexported(const char *name) { /* setnoexport -- mark a list of variable names not for export */ extern void setnoexport(List *list) { + static char noexportchar = '!'; + isdirty = TRUE; if (list == NULL) { noexport = NULL; @@ -121,7 +123,7 @@ extern void setnoexport(List *list) { } gcdisable(); for (noexport = mkdict(); list != NULL; list = list->next) - noexport = dictput(noexport, getstr(list->term), (void *) setnoexport); + noexport = dictput(noexport, getstr(list->term), &noexportchar); gcenable(); }