This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libc-2.25.90.pot


On 07/20/2017 07:57 AM, Siddhesh Poyarekar wrote:
Oh I meant PRIdLINENO, not PRIdMAX.  I suppose using PRIdMAX directly
might work since gettext seems to recognize the other PRI* macros.

Yes, PRIdMAX should work. The zic.c code uses the macro (as opposed to just %jd) to be portable to pre-C99 libraries. I installed the attached patch into the upstream tzdb sources; the zic.c part of it should work for glibc too. Thanks for reporting the problem.

>From fd13571c626bac8f5bb90ad79543cefae0fef134 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 20 Jul 2017 12:34:12 -0700
Subject: [PATCH] Fix zic.c incompatibility with xgettext

Problem reported by Benno Schulenberg in:
https://sourceware.org/ml/libc-alpha/2017-07/msg00653.html
* NEWS: Document this.
* zic.c (PRIdLINENO): Remove.  All uses replaced with definiens.
---
 NEWS  |  3 +++
 zic.c | 11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 5f79225..64d5c91 100644
--- a/NEWS
+++ b/NEWS
@@ -102,6 +102,9 @@ Unreleased, experimental changes
     Calculation of time_t extrema works around a bug in GCC 4.8.4
     (Reported by Stan Shebs and Joseph Myers.)
 
+    zic.c no longer mistranslates formats of line numbers in non-English
+    locales.  (Problem reported by Benno Schulenberg.)
+
     Several minor changes have been made to the code to make it a
     bit easier to port to MS-Windows and Solaris.  (Thanks to Kees
     Dekker for reporting the problems.)
diff --git a/zic.c b/zic.c
index 300d563..765fe7d 100644
--- a/zic.c
+++ b/zic.c
@@ -58,9 +58,10 @@ typedef int_fast64_t	zic_t;
 static ptrdiff_t const PTRDIFF_MAX = MAXVAL(ptrdiff_t, TYPE_BIT(ptrdiff_t));
 #endif
 
-/* The type and printf format for line numbers.  */
+/* The type for line numbers.  Use PRIdMAX to format them; formerly
+   there was also "#define PRIdLINENO PRIdMAX" and formats used
+   PRIdLINENO, but xgettext cannot grok that.  */
 typedef intmax_t lineno;
-#define PRIdLINENO PRIdMAX
 
 struct rule {
 	const char *	r_filename;
@@ -499,10 +500,10 @@ verror(const char *const string, va_list args)
 	** on BSD systems.
 	*/
 	if (filename)
-	  fprintf(stderr, _("\"%s\", line %"PRIdLINENO": "), filename, linenum);
+	  fprintf(stderr, _("\"%s\", line %"PRIdMAX": "), filename, linenum);
 	vfprintf(stderr, string, args);
 	if (rfilename != NULL)
-		fprintf(stderr, _(" (rule from \"%s\", line %"PRIdLINENO")"),
+		fprintf(stderr, _(" (rule from \"%s\", line %"PRIdMAX")"),
 			rfilename, rlinenum);
 	fprintf(stderr, "\n");
 }
@@ -1264,7 +1265,7 @@ _("\"Zone %s\" line and -p option are mutually exclusive"),
 		if (zones[i].z_name != NULL &&
 			strcmp(zones[i].z_name, fields[ZF_NAME]) == 0) {
 				error(_("duplicate zone name %s"
-					" (file \"%s\", line %"PRIdLINENO")"),
+					" (file \"%s\", line %"PRIdMAX")"),
 					fields[ZF_NAME],
 					zones[i].z_filename,
 					zones[i].z_linenum);
-- 
2.13.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]