[PROPOSED 1/2] zic has new ‘-l -’ and ‘-p -’ options
* NEWS, zic.8: Mention this. * zic.c (dolink): If fromfield is "-", simply remove tofield. --- NEWS | 3 +++ zic.8 | 12 ++++++++++++ zic.c | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3bcddd0..cdcdbc1 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ Unreleased, experimental changes Changes to code + zic's new '-l -' and '-p -' options uninstall any existing + localtime and posixrules files, respectively. + The undocumented and ineffective tzsetwall function has been removed. diff --git a/zic.8 b/zic.8 index b1bf437..a431311 100644 --- a/zic.8 +++ b/zic.8 @@ -85,6 +85,12 @@ will act as if the input contained a link line of the form .ti +.5i .ta \w'Link\0\0'u +\w'\fItimezone\fP\0\0'u Link \fItimezone\fP localtime +.sp +If +.I timezone +is +.BR \*- , +any already-existing link is removed. .TP .BI "\*-L " leapsecondfilename Read leap second information from the file with the given name. @@ -109,6 +115,12 @@ and it should not be combined with if .IR timezone 's transitions are at standard time or Universal Time (UT) instead of local time. +.sp +If +.I timezone +is +.BR \*- , +any already-existing link is removed. .TP .BR "\*-r " "[\fB@\fP\fIlo\fP][\fB/@\fP\fIhi\fP]" Reduce the size of output files by limiting their applicability diff --git a/zic.c b/zic.c index 2875b55..c874b04 100644 --- a/zic.c +++ b/zic.c @@ -981,6 +981,7 @@ hardlinkerr(char const *from, char const *to) static void dolink(char const *fromfield, char const *tofield, bool staysymlink) { + bool remove_only = strcmp(fromfield, "-") == 0; bool todirs_made = false; int link_errno; @@ -988,7 +989,7 @@ dolink(char const *fromfield, char const *tofield, bool staysymlink) ** We get to be careful here since ** there's a fair chance of root running us. */ - if (itsdir(fromfield)) { + if (!remove_only && itsdir(fromfield)) { fprintf(stderr, _("%s: link from %s/%s failed: %s\n"), progname, directory, fromfield, strerror(EPERM)); exit(EXIT_FAILURE); @@ -1003,6 +1004,8 @@ dolink(char const *fromfield, char const *tofield, bool staysymlink) progname, directory, tofield, e); exit(EXIT_FAILURE); } + if (remove_only) + return; link_errno = staysymlink ? ENOTSUP : hardlinkerr(fromfield, tofield); if (link_errno == ENOENT && !todirs_made) { mkdirs(tofield, true); -- 2.17.1
* Makefile (POSIXRULES): Default to '-'. * NEWS: Mention this. --- Makefile | 36 ++++++++++++++++-------------------- NEWS | 5 +++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 107f67e..0da7c3f 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,7 @@ DATAFORM= main # Change the line below for your timezone (after finding the one you want in # one of the $(TDATA) source files, or adding it to a source file). # Alternatively, if you discover you've got the wrong timezone, you can just -# zic -l rightzone -# to correct things. +# 'zic -l -' to remove it, or 'zic -l rightzone' to change it. # Use the command # make zonenames # to get a list of the values you can use for LOCALTIME. @@ -37,33 +36,30 @@ LOCALTIME= GMT # The POSIXRULES macro controls interpretation of nonstandard and obsolete # POSIX-like TZ settings like TZ='EET-2EEST' that lack DST transition rules. -# In the reference implementation, if you want something other than Eastern -# United States time as a template for handling these settings, you can -# change the line below (after finding the timezone you want in the -# one of the $(TDATA) source files, or adding it to a source file). -# A setting like TZ='EET-2EEST' is supposed to use the rules in the -# template file to determine "spring forward" and "fall back" days and -# times; the environment variable itself specifies UT offsets of standard and -# daylight saving time. -# Alternatively, if you discover you've got the wrong timezone, you can just -# zic -p rightzone -# to correct things. -# Use the command -# make zonenames -# to get a list of the values you can use for POSIXRULES. +# Such a setting uses the rules in a template file to determine +# "spring forward" and "fall back" days and times; the environment +# variable itself specifies UT offsets of standard and daylight saving time. # -# If POSIXRULES is empty, no template is installed; this is the intended -# future default for POSIXRULES. +# If POSIXRULES is '-', no template is installed; this is the default. # -# Nonempty POSIXRULES is obsolete and should not be relied on, because: +# Any other value for POSIXRULES is obsolete and should not be relied on, as: # * It does not work correctly in popular implementations such as GNU/Linux. # * It does not work in the tzdb implementation for timestamps after 2037. # * It is incompatible with 'zic -b slim' if POSIXRULES specifies transitions # at standard time or UT rather than at local time. # In short, software should avoid ruleless settings like TZ='EET-2EEST' # and so should not depend on the value of POSIXRULES. +# +# If, despite the above, you want a template for handling these settings, +# you can change the line below (after finding the timezone you want in the +# one of the $(TDATA) source files, or adding it to a source file). +# Alternatively, if you discover you've got the wrong timezone, you can just +# 'zic -p -' to remove it, or 'zic -p rightzone' to change it. +# Use the command +# make zonenames +# to get a list of the values you can use for POSIXRULES. -POSIXRULES= America/New_York +POSIXRULES= - # Also see TZDEFRULESTRING below, which takes effect only # if the time zone files cannot be accessed. diff --git a/NEWS b/NEWS index cdcdbc1..bfe02ea 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,11 @@ Unreleased, experimental changes The undocumented and ineffective tzsetwall function has been removed. + Changes to build procedure + + The Makefile now defaults POSIXRULES to '-', so the posixrules + feature (obsolete as of 2019b) is no longer installed by default. + Release 2020a - 2020-04-23 16:03:47 -0700 -- 2.17.1
participants (1)
-
Paul Eggert