Discussion:
[PATCH] nl_langinfo: pacify gcc -Wunused-function
Paul Eggert
2018-02-23 21:16:42 UTC
Permalink
* 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 bc80d0099..fcbda1271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2018-02-23 Paul 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 b93f7be25..d98f03462 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.14.3
Loading...