[tz] proposed changes for Win32 and a improved mktime() algorithm

Paul Eggert eggert at cs.ucla.edu
Wed May 10 05:09:15 UTC 2017


Thanks for writing up that patch. I installed the attached patches, which I hope 
addresses a few of the issues you raised. I'll comment below on the issues that 
the attached patches don't address.

Kees Dekker wrote:

> 1.       Win32/Visual Studio (2015) port. Related to including header files + handling of the Windows style backslash (by adding some macros)

In thinking about the problem with MS-Windows file name syntax, I would like to 
avoid complicating tzcode in areas where the complication isn't really needed. 
The zic man page already says that portable time zone names should not use 
constructs like leading "C:" and/or backslash. It shouldn't be tzcode's job to 
worry about the limitations of DOS file names, any more than it's tzcode's job 
to worry about file name restrictions imposed by VMS, z/OS, ISO 9660, etc.

zic's -v option already warns about drive letters and backslashes in time zone 
names, and such names are so rare in practice that I don't see us as needing to 
do anything further here.

So, instead of adding a bunch of code to deal with backslashes and drive 
letters, I'd like to remove the couple of stray lines of code that attempt to 
deal with this issue and which (obviously) do not suffice to solve the problem.

For the other proposed changes:

* My previous messages discussed the proposed mktime redo.

* I think Robert Elz covered the putenv issue fairly well: that is, the problem 
has already been solved, in a different way.

* I would rather not add pragmas to pacify a compiler that is generating false 
alarms. We don't have the resources to pacify the dozens of C compilers out 
there, and pacifying them all would contort the code. Keeping GCC happy is as 
much as I want to take on. Similarly, I'd rather not add INITIALIZE calls to 
pacify older versions of GCC, or to pacify other compilers that can't keep track 
of locals well.

> -#define HAVE_SYMLINK		1
> +#define HAVE_SYMLINK		DEFAULT_FOR_UNIX

For changes like this you should be able to invoke 'make' with arguments 
suitable for your platform, and that way we don't need to modify the source 
code. E.g., you can run this:

    make CFLAGS='-DHAVE_LINK=0 -DHAVE_SYMLINK=0 -Dssize_t=long -Dlint'

and similarly for the other flags you need to set for your platform.

> +#ifndef TYPE_BIT

I didn't see the need for this #ifndef, and others like it. How could TYPE_BIT 
already be defined?

> +#ifdef _MSC_VER
> +	/* Windows does not have shell scripts */
> +	const char *getoptopt = "d:l:p:L:vs";
> +#else
> +	const char *getoptopt = "d:l:p:L:vsy:";
> +#endif

If MS-Windows does not have shell scripts, then calling 'system' always fails, 
right? That should be good enough. (While we're on the topic, I wouldn't mind 
deprecating the 'y' option on all platforms, as it hasn't been needed for years 
and it has security implications.)

> +#else
> +		/* for systems that do not support symlinks, there is no need to call relname() (=alloc) + free,
> +		but the to directory need to be created */
> +		symlink_errno = ENOTSUP;

As far as I can tell, this merely improves zic's performance a bit on platforms 
lacking the symlink system call. I wouldn't worry about this. It's better to 
keep the code simpler and easier to maintain, than to worry about 
barely-significant tuning of a rarely-used and plenty-fast program, a tuning 
that helps only nonstandard platforms.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Avoid-non-null-terminated-const-char-arrays.patch
Type: text/x-diff
Size: 2949 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0001-Avoid-non-null-terminated-const-char-arrays-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Remove-unnecessary-code-for-DOS-file-names-in-zic.patch
Type: text/x-diff
Size: 2186 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0002-Remove-unnecessary-code-for-DOS-file-names-in-zic-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-New-macro-HAVE_DECL_ENVIRON.patch
Type: text/x-diff
Size: 5896 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0003-New-macro-HAVE_DECL_ENVIRON-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Makefile-Mention-ssize_t-on-MS-Windows.patch
Type: text/x-diff
Size: 891 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0004-Makefile-Mention-ssize_t-on-MS-Windows-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-New-macro-HAVE_STDBOOL_H.patch
Type: text/x-diff
Size: 2421 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0005-New-macro-HAVE_STDBOOL_H-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-A-couple-of-other-MS-Windows-comments.patch
Type: text/x-diff
Size: 1287 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20170509/725cfd65/0006-A-couple-of-other-MS-Windows-comments-0001.patch>


More information about the tz mailing list