Skip to content

Commit

Permalink
Fix -Wundef warnings by using #ifdef instead of #if
Browse files Browse the repository at this point in the history
This also brings back the check for __func__ that was deleted in commit
9b41a09
  • Loading branch information
arichardson authored and westes committed Apr 25, 2024
1 parent a4abd73 commit bf23944
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ AC_CHECK_FUNCS([dup2 memset regcomp strcasecmp strchr strdup strtol], [],
# reallocarr - NetBSD function. Use reallocarray if not available.
# reallocarray - OpenBSD function. We have replacement if not available.
AC_CHECK_FUNCS([pow setlocale reallocarr reallocarray])
AC_CHECK_DECLS(__func__)

AS_IF([test "$cross_compiling" = yes],
[AC_CONFIG_FILES([src/config_for_build.h])])
Expand Down
2 changes: 1 addition & 1 deletion src/flexdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ extern void flexerror(const char *);
extern void flexfatal(const char *);

/* Report a fatal error with a pinpoint, and terminate */
#if HAVE_DECL___FUNC__
#ifdef HAVE_DECL___FUNC__
#define flex_die(msg) \
do{ \
fprintf (stderr,\
Expand Down
8 changes: 4 additions & 4 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ void add_action (const char *new_text)
void *allocate_array (int size, size_t element_size)
{
void *new_array;
#if HAVE_REALLOCARR
#ifdef HAVE_REALLOCARR
new_array = NULL;
if (reallocarr(&new_array, (size_t) size, element_size))
flexfatal (_("memory allocation failed in allocate_array()"));
#else
# if HAVE_REALLOCARRAY
# ifdef HAVE_REALLOCARRAY
new_array = reallocarray(NULL, (size_t) size, element_size);
# else
/* Do manual overflow detection */
Expand Down Expand Up @@ -580,12 +580,12 @@ char *readable_form (int c)
void *reallocate_array (void *array, int size, size_t element_size)
{
void *new_array;
#if HAVE_REALLOCARR
#ifdef HAVE_REALLOCARR
new_array = array;
if (reallocarr(&new_array, (size_t) size, element_size))
flexfatal (_("attempt to increase array size failed"));
#else
# if HAVE_REALLOCARRAY
# ifdef HAVE_REALLOCARRAY
new_array = reallocarray(array, (size_t) size, element_size);
# else
/* Do manual overflow detection */
Expand Down

0 comments on commit bf23944

Please # to comment.