From fd13571c626bac8f5bb90ad79543cefae0fef134 Mon Sep 17 00:00:00 2001 From: Paul Eggert 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