Since Solaris 10 'locale.h' pulls in libintl.h, our '#define ngettext' clashes
with the ngettext function. I changed our #define to WG_NGETTEXT (WG_ for the
wget namespace).
Another option would be to completely avoid ngettext() - we just use it at two
places (spider.c and warc.c) (ngettext(s1,s2,n) --> n==1?s1:s2).

Please review and comment.

Tim
From 49944ea20a6886f078ba8770d00d3168c5005165 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim Rühsen?= <[email protected]>
Date: Thu, 11 Dec 2014 09:29:29 +0100
Subject: [PATCH] Fixed define 'ngettext' to WG_NGETTEXT (issue with Solaris
 10)

Fixes: #43785
Reported-by: Friedrich Haubensak <[email protected]>
---
 src/ChangeLog | 11 +++++++++++
 src/spider.c  |  5 +++--
 src/warc.c    |  6 +++---
 src/wget.h    |  9 +++++----
 4 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a53c589..9aaaeb7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2014-12-11  Tim Ruehsen <[email protected]>
+
+	* wget.h: Fixed define 'ngettext' to WG_NGETTEXT for Solaris 10
+	* spider.c, warc.c: Use WG_NGETTEXT instead of ngettext
+
+	On Solaris (10), libintl.h is included implicitly and thus conflicts with
+	our definition of ngettext in case NLS is disabled.
+
+	Fixes: #43785
+	Reported-by: Friedrich Haubensak <[email protected]>
+
 2014-12-05  Tim Ruehsen <[email protected]>

 	* Makefile.am: Removed reference to cmpt.c
diff --git a/src/spider.c b/src/spider.c
index 1508b87..96da356 100644
--- a/src/spider.c
+++ b/src/spider.c
@@ -79,8 +79,9 @@ print_broken_links (void)
   num_elems = hash_table_count (nonexisting_urls_set);
   assert (num_elems > 0);

-  logprintf (LOG_NOTQUIET, ngettext("Found %d broken link.\n\n",
-                                    "Found %d broken links.\n\n", num_elems),
+  logprintf (LOG_NOTQUIET, WG_NGETTEXT("Found %d broken link.\n\n",
+                                       "Found %d broken links.\n\n",
+                                       num_elems),
              num_elems);

   for (hash_table_iterate (nonexisting_urls_set, &iter);
diff --git a/src/warc.c b/src/warc.c
index 5bdda1b..6ad832c 100644
--- a/src/warc.c
+++ b/src/warc.c
@@ -1009,9 +1009,9 @@ _("CDX file does not list record ids. (Missing column 'u'.)\n"));

       /* Print results. */
       nrecords = hash_table_count (warc_cdx_dedup_table);
-      logprintf (LOG_VERBOSE, ngettext ("Loaded %d record from CDX.\n\n",
-                                        "Loaded %d records from CDX.\n\n",
-                                         nrecords),
+      logprintf (LOG_VERBOSE, WG_NGETTEXT("Loaded %d record from CDX.\n\n",
+                                          "Loaded %d records from CDX.\n\n",
+                                          nrecords),
                               nrecords);
     }

diff --git a/src/wget.h b/src/wget.h
index cddacdc..8fe2844 100644
--- a/src/wget.h
+++ b/src/wget.h
@@ -59,11 +59,12 @@ as that of the covered work.  */
 /* `gettext (FOO)' is long to write, so we use `_(FOO)'.  If NLS is
    unavailable, _(STRING) simply returns STRING.  */
 #if ENABLE_NLS
-#	include <libintl.h>
-#	define _(STRING) gettext(STRING)
+# include <libintl.h>
+# define _(STRING) gettext(STRING)
+# define WG_NGETTEXT(STRING1,STRING2,N) ngettext(STRING1,STRING2,N)
 #else
-#	define _(STRING) STRING
-#	define ngettext(STRING1,STRING2,N) STRING2
+# define _(STRING) STRING
+# define WG_NGETTEXT(STRING1,STRING2,N) ((N) == 1 ? STRING1 : STRING2)
 #endif

 /* A pseudo function call that serves as a marker for the automated
--
2.1.3

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to