From 88cfbe67e7d2e3a4f944f8dc23e88520eca3f6dd Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 23 Feb 2018 13:15:24 -0800
Subject: [PATCH] nl_langinfo: pacify gcc -Wunused-function

* lib/nl_langinfo.c (ctype_codeset): Do not define if
REPLACE_NL_LANGINFO && !GNULIB_defined_CODESET, as it is unused in
this case.  Without this change, I got a diagnostic when building
coreutils on Fedora 27 with gcc 7.3.1 20180130.
---
 ChangeLog         | 6 ++++++
 lib/nl_langinfo.c | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc80d00999..fcbda12718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-02-23  Paul Eggert  <eggert@cs.ucla.edu>
 
+	nl_langinfo: pacify gcc -Wunused-function
+	* lib/nl_langinfo.c (ctype_codeset): Do not define if
+	REPLACE_NL_LANGINFO && !GNULIB_defined_CODESET, as it is unused in
+	this case.  Without this change, I got a diagnostic when building
+	coreutils on Fedora 27 with gcc 7.3.1 20180130.
+
 	same: pacify gcc -Wunused-variable
 	* lib/same.c (same_nameat) [!CHECK_TRUNCATION]:
 	Omit unused variable.
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index b93f7be25b..d98f034623 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -28,6 +28,7 @@
 # include <stdio.h>
 #endif
 
+#if !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET
 /* Return the codeset of the current locale, if this is easily deducible.
    Otherwise, return "".  */
 static char *
@@ -64,7 +65,7 @@ ctype_codeset (void)
         }
     }
 
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
   /* If setlocale is successful, it returns the number of the
      codepage, as a string.  Otherwise, fall back on Windows API
      GetACP, which returns the locale's codepage as a number (although
@@ -76,9 +77,10 @@ ctype_codeset (void)
   else
     sprintf (buf + 2, "%u", GetACP ());
   codeset = memcpy (buf, "CP", 2);
-#endif
+# endif
   return codeset;
 }
+#endif
 
 
 #if REPLACE_NL_LANGINFO
-- 
2.39.5