[tz] version information in tz binary file?

Paul Eggert eggert at cs.ucla.edu
Tue Sep 10 05:35:10 UTC 2013


Arthur David Olson wrote:
> That way folks who look for the POSIX string at the very end of the file
> will find it, and folks who look for it after the 64-bit data will too.

Thanks!  Here's a patch to implement that; I've pushed this
to the experimental repository.

>From d74d5b95008e7a00da6fc66afc618ea8296fd43e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert at cs.ucla.edu>
Date: Mon, 9 Sep 2013 22:32:56 -0700
Subject: [PATCH] * tzfile.5: Repeat the TZ string after the name-value pairs.

Suggested by Arthur David Olson in
<http://mm.icann.org/pipermail/tz/2013-September/020100.html>.
* zic.c (writezone): Implement this.
---
 tzfile.5 | 21 ++++++++++++---------
 zic.c    | 22 ++++++++++++----------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/tzfile.5 b/tzfile.5
index d609277..d9477eb 100644
--- a/tzfile.5
+++ b/tzfile.5
@@ -158,15 +158,18 @@ between daylight saving and standard time.
 Also, for version-3-format time zone files, the version-2 header and
 data are optionally followed by a section containing auxiliary
 meta-information that is not needed to process time stamps.  This
-section, if present, consists of the four magic bytes "=TZ\en"
-followed by zero or more newline-terminated byte strings, each
-containing a name-value pair separated by "=".  Names consist of ASCII
-letters, digits and underscores, and start with a letter; duplicate
-names are not allowed.  Two common names are "name", the Zone name for
-the data, and "version", the version number.  Values consist of any
-bytes except NUL, newline, and backslash; however, newline and
-backslash can represented via the two-byte strings "\en" and "\e\e"
-respectively.
+section, if present, consists of the four magic bytes "=TZ\en",
+followed by zero or more newline-terminated byte strings, followed by
+another copy of the newline-enclosed POSIX-TZ-style string (this last
+is for the benefit of any older clients that look for the TZ string at
+the very end of the file).  Each newline-terminated byte string
+consists of a name-value pair separated by "=" and terminated by
+newline.  Names consist of ASCII letters, digits and underscores, and
+start with a letter; duplicate names are not allowed.  Two common
+names are "name", the Zone name for the data, and "version", the
+version number.  Values consist of any bytes except NUL, newline, and
+backslash; however, newline and backslash can represented via the
+two-byte strings "\en" and "\e\e" respectively.
 .SH SEE ALSO
 newctime(3), newtzset(3)
 .\" This file is in the public domain, so clarified as of
diff --git a/zic.c b/zic.c
index eefa1fb..17b9e0e 100644
--- a/zic.c
+++ b/zic.c
@@ -1765,17 +1765,19 @@ writezone(const char *const name, const char *const string)
 				(void) putc(ttisgmts[i], fp);
 	}
 	(void) fprintf(fp, "\n%s\n", string);
-	if (genname || genoptions)
+	if (genname || genoptions) {
 		fprintf(fp, "=TZ\n");
-	if (genname) {
-		fprintf(fp, "name");
-		writevalue(fp, name);
-	}
-	for (i = 0; i < genoptions; i++) {
-		register char const *v = genoption[i];
-		register int namelen = strchr(v, '=') - v;
-		fprintf(fp, "%.*s", namelen, v);
-		writevalue(fp, v + namelen + 1);
+		if (genname) {
+			fprintf(fp, "name");
+			writevalue(fp, name);
+		}
+		for (i = 0; i < genoptions; i++) {
+			register char const *v = genoption[i];
+			register int namelen = strchr(v, '=') - v;
+			fprintf(fp, "%.*s", namelen, v);
+			writevalue(fp, v + namelen + 1);
+		}
+		fprintf(fp, "\n%s\n", string);
 	}
 	if (ferror(fp) || fclose(fp)) {
 		(void) fprintf(stderr, _("%s: Error writing %s\n"),
-- 
1.8.3.1




More information about the tz mailing list