From 9f5768106fd43935bc2725ec1b2ecce5c69f1a34 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 13 Nov 2018 10:05:21 +1100 Subject: [PATCH] replace: Add check for variable program_invocation_short_name It appears that wafsamba's configure() defines _GNU_SOURCE unconditionally, so checking _GNU_SOURCE isn't enough to know if this variable is available. For example, it isn't available on AIX with the xlc compiler: [ 6/10] Compiling lib/replace/replace.c ... "../../lib/replace/replace.c", line 991.16: 1506-045 (S) Undeclared identifier program_invocation_short_name. Instead, add a configure check for program_invocation_short_name and use it. Signed-off-by: Martin Schwenke Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Tue Nov 13 11:11:11 CET 2018 on sn-devel-144 --- lib/replace/replace.c | 10 +++++----- lib/replace/wscript | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/replace/replace.c b/lib/replace/replace.c index 9b1df3dc3bd..a14322b8e57 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -980,16 +980,16 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count) #endif /* HAVE_MEMSET_S */ #ifndef HAVE_GETPROGNAME -# ifndef _GNU_SOURCE +# ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME # define PROGNAME_SIZE 32 static char rep_progname[PROGNAME_SIZE]; -# endif /* _GNU_SOURCE */ +# endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */ const char *rep_getprogname(void) { -#ifdef _GNU_SOURCE +#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME return program_invocation_short_name; -#else /* _GNU_SOURCE */ +#else /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */ FILE *fp = NULL; char cmdline[4096] = {0}; char *p = NULL; @@ -1053,6 +1053,6 @@ const char *rep_getprogname(void) (void)snprintf(rep_progname, sizeof(rep_progname), "%s", p); return rep_progname; -#endif /* _GNU_SOURCE */ +#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */ } #endif /* HAVE_GETPROGNAME */ diff --git a/lib/replace/wscript b/lib/replace/wscript index c8693a3f2e1..ff918146ffa 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -607,6 +607,7 @@ def configure(conf): conf.CHECK_VARIABLE('rl_event_hook', define='HAVE_DECL_RL_EVENT_HOOK', always=True, headers='readline.h readline/readline.h readline/history.h') + conf.CHECK_VARIABLE('program_invocation_short_name', headers='errno.h') conf.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')