[tz] [PROPOSED 5/5] Let builder specify default for zic -b

Paul Eggert eggert at cs.ucla.edu
Tue Jun 18 19:12:16 UTC 2019


* Makefile, NEWS: Document -DZIC_BLOAT_DEFAULT.
* zic.c (ZIC_BLOAT_DEFAULT): New macro.
(main): Use it.
---
 Makefile | 19 ++++++++++---------
 NEWS     |  7 ++++---
 zic.c    |  6 ++++++
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index 81d1e86..d305f68 100644
--- a/Makefile
+++ b/Makefile
@@ -244,6 +244,13 @@ LDLIBS=
 #	other than simply getting garbage data
 #  -DUSE_LTZ=0 to build zdump with the system time zone library
 #	Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
+#  -DZIC_BLOAT_DEFAULT=\"slim\" to default zic's -b option to "slim", and
+#	similarly for "fat".  Fat TZif files work around incompatibilities
+#	and bugs in some TZif readers, notably readers that mishandle 64-bit
+#	data in TZif files.  Slim TZif files are more efficient and do not
+#	work around these incompatibilities and bugs.  If not given, the
+#	current default is "fat" but this is intended to change as readers
+#	requiring fat files often mishandle timestamps after 2037 anyway.
 #  -DZIC_MAX_ABBR_LEN_WO_WARN=3
 #	(or some other number) to set the maximum time zone abbreviation length
 #	that zic will accept without a warning (the default is 6)
@@ -375,16 +382,10 @@ LEAPSECONDS=
 zic=		./zic
 ZIC=		$(zic) $(ZFLAGS)
 
-# Append "-b fat" to install larger TZif files that work around
-# incompatiblities and bugs in some TZif readers, notably readers that
-# mishandle 64-bit data in TZif files.  Append "-b slim" to install
-# smaller TZif files that test for these year-2038 bugs.  If no -b
-# option is given, the current default is "-b fat", but this is
-# intended to change as buggy readers often mishandle timestamps
-# after 2038 anyway.
-#
-# To shrink the size of installed TZif files even further,
+# To shrink the size of installed TZif files,
 # append "-r @N" to omit data before N-seconds-after-the-Epoch.
+# You can also append "-b slim" if that is not already the default;
+# see ZIC_BLOAT_DEFAULT above.
 # See the zic man page for more about -b and -r.
 ZFLAGS=
 
diff --git a/NEWS b/NEWS
index 53c440c..76db493 100644
--- a/NEWS
+++ b/NEWS
@@ -53,9 +53,10 @@ Unreleased, experimental changes
     older software, notably software that mishandles 64-bit TZif data
     or uses obsolete TZ strings like "EET-2EEST" that lack DST rules.
     Slim format is more efficient and does not work around 64-bit bugs
-    or obsolete TZ strings.  Currently zic defaults to fat format,
-    although this is intended to change in future zic versions, as the
-    buggy software often mishandles timestamps anyway.
+    or obsolete TZ strings.  Currently zic defaults to fat format
+    unless you compile with -DZIC_BLOAT_DEFAULT=\"slim\"; this
+    out-of-the-box default is intended to change in future releases
+    as the buggy software often mishandles timestamps anyway.
 
     zic no longer treats a set of rules ending in 2037 specially.
     Previously, zic assumed that such a ruleset meant that future
diff --git a/zic.c b/zic.c
index 5da3ca4..8bf5628 100644
--- a/zic.c
+++ b/zic.c
@@ -659,6 +659,10 @@ want_bloat(void)
   return 0 <= bloat;
 }
 
+#ifndef ZIC_BLOAT_DEFAULT
+# define ZIC_BLOAT_DEFAULT "fat"
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -791,6 +795,8 @@ _("%s: invalid time range: %s\n"),
 		}
 	if (optind == argc - 1 && strcmp(argv[optind], "=") == 0)
 		usage(stderr, EXIT_FAILURE);	/* usage message by request */
+	if (bloat == 0)
+	  bloat = strcmp(ZIC_BLOAT_DEFAULT, "slim") == 0 ? -1 : 1;
 	if (directory == NULL)
 		directory = TZDIR;
 	if (tzdefault == NULL)
-- 
2.21.0



More information about the tz mailing list