nut/nut-c99-ax_c_printf_null.patch
Michal Hlavinka 3aa7b876a5 fix STATEPATH location and creation (#2024651)
merged C99 related changes to configure from fedora
2022-12-06 22:53:51 +01:00

60 lines
2.2 KiB
Diff

Fix several issues with the AX_C_PRINTF_STRING_NULL check:
Adjust quoting in the AX_C_PRINTF_STRING_NULL definition. Switch to
strstr from strcasestr (a GNU extension, requires -D_GNU_SOURCE)
and include <string.h> instead of <strings.h>. Add missing braces
and parentheses. Use double-quote for string literals.
Submitted upstream: <https://github.com/networkupstools/nut/pull/1720>
diff --git a/m4/ax_c_pragmas.m4 b/m4/ax_c_pragmas.m4
index 53c1aebf8ea35a1e..14ecd596d3b36573 100644
--- a/m4/ax_c_pragmas.m4
+++ b/m4/ax_c_pragmas.m4
@@ -943,32 +943,32 @@ if test -z "${nut_have_ax_c_printf_string_null_seen}"; then
dnl ### To be sure, bolt the language
AC_LANG_PUSH([C])
- AC_CACHE_CHECK([for practical support to pritnf("%s", NULL)],
+ AC_CACHE_CHECK([for practical support to printf("%s", NULL)],
[ax_cv__printf_string_null],
[AX_RUN_OR_LINK_IFELSE(
[AC_LANG_PROGRAM([dnl
#include <stdio.h>
-#include <strings.h>
-], [dnl
+#include <string.h>
+], [[
char buf[128];
char *s = NULL;
int res = snprintf(buf, sizeof(buf), "%s", s);
buf[sizeof(buf)-1] = '\0';
if (res < 0) {
- printf(stderr, "FAILED to snprintf() a NULL string argument");
- exit 1;
+ fprintf(stderr, "FAILED to snprintf() a NULL string argument\n");
+ return 1;
}
-if (buf[0] == '\0')
- printf(stderr, "RETURNED empty string from snprintf() with a NULL string argument");
- exit 0;
+if (buf[0] == '\0') {
+ fprintf(stderr, "RETURNED empty string from snprintf() with a NULL string argument\n");
+ return 0;
}
-if (strcasestr(buf, 'null') == NULL)
- printf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'", buf);
- exit 0;
+if (strstr(buf, "null") == NULL) {
+ fprintf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'\n", buf);
+ return 0;
}
-printf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'", buf);
-exit 0;
- ])],
+fprintf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'\n", buf);
+return 0;
+ ]])],
[ax_cv__printf_string_null=yes],
[ax_cv__printf_string_null=no]
)]