diff mbox

[5/5] Support systems which do not have nl_langinfo()

Message ID 1459298887-21519-6-git-send-email-tytso@mit.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Theodore Ts'o March 30, 2016, 12:48 a.m. UTC
Add a configure check and skip use of nl_langinfo if it is not
present.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 configure.ac | 1 +
 warnquota.c  | 4 ++++
 2 files changed, 5 insertions(+)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index d17b18c..0d0ba57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,6 +32,7 @@  PKG_PROG_PKG_CONFIG([0.20])
 
 AC_C_CONST
 AC_C_INLINE
+AC_CHECK_FUNC(nl_langinfo)
 
 # ===============
 # Gettext support
diff --git a/warnquota.c b/warnquota.c
index e9868c1..0d911e4 100644
--- a/warnquota.c
+++ b/warnquota.c
@@ -30,7 +30,9 @@ 
 #include <time.h>
 #include <getopt.h>
 #include <locale.h>
+#ifdef HAVE_NL_LANGINFO
 #include <langinfo.h>
+#endif
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/utsname.h>
@@ -723,10 +725,12 @@  static int readconfigfile(const char *filename, struct configparams *config)
 	(config->charset)[0] = '\0';
 	setlocale(LC_ALL, NULL);
 	locale = setlocale(LC_MESSAGES, NULL);
+#ifdef HAVE_NL_LANGINFO
 	if (locale && strcasecmp(locale, "posix") && strcasecmp(locale, "c")) {
 		locale = nl_langinfo(CODESET);
 		sstrncpy(config->charset, locale, CNF_BUFFER);
 	}
+#endif
 	maildev[0] = 0;
 	config->user_signature = config->user_message = config->group_signature = config->group_message = NULL;
 	config->cc_before = -1;