[tz] tzcode error handling (patch 4 of 4)

Steve Summit scs at eskimo.com
Mon Dec 11 12:38:20 UTC 2017


Patch 4 adds the ability to print a few extra messages having to
do with tzcode's logic for determining how to interpret a requested
time zone.  There are only two messages so far: "trying %s", when
the code is attempting to open a zoneinfo file; and "parsing '%s'
as Posix tz string", when it, well, attempts to parse a Posix-style
timezone string.  That's not much, but it lets you watch, for
example, TZ=EST5EDT try both ways but TZ=:EST5EDT only try the file.

To enable "verbose debugging", call tz_set_verbose_debug(1),
and call tz_set_verbose_debug(0) to turn it off again.

Like the rest, this patch is with respect to 2017c.
It also depends on Patch 1 (but not 2 or 3).

					Steve Summit
					scs at eskimo.com
-------------- next part --------------
--- a/localtime.c	2017-12-07 22:48:24.000000000 -0500
+++ b/localtime.c	2017-12-07 22:49:05.000000000 -0500
@@ -209,6 +209,8 @@
 
 static void (*wrnfunc)(char const *, ...) = NULL;
 
+static int verbose_debug = 0;
+
 /* Initialize *S to a value based on GMTOFF, ISDST, and ABBRIND.  */
 static void
 init_ttinfo(struct ttinfo *s, int_fast32_t gmtoff, bool isdst, int abbrind)
@@ -439,6 +441,8 @@
 			doaccess = true;
 		name = lsp->fullname;
 	}
+	if(verbose_debug && wrnfunc)
+	  (*wrnfunc)("trying %s", name);
 	if (doaccess && access(name, R_OK) != 0)
 	  return errno;
 	fid = open(name, OPEN_MODE);
@@ -1062,6 +1066,9 @@
 	register bool			load_ok;
 	struct local_storage		ls;  /* need to malloc if ALL_STATE? */
 
+	if(verbose_debug && wrnfunc)
+		(*wrnfunc)("parsing \"%s\" as Posix tz string", name);
+
 	stdname = name;
 	if (lastditch) {
 		stdlen = sizeof gmt - 1;
-------------- next part --------------
--- a/private.h	2017-12-06 19:47:49.000000000 -0500
+++ b/private.h	2017-12-06 19:50:06.000000000 -0500
@@ -465,6 +465,7 @@
 #endif
 void tz_set_warn_func(void (*)(char const *, ...));
 void tz_set_stderr_warn_func(void);
+void tz_set_verbose_debug(int);
 
 #if !HAVE_DECL_ASCTIME_R && !defined asctime_r
 extern char *asctime_r(struct tm const *restrict, char *restrict);


More information about the tz mailing list