Skip to content

Commit

Permalink
zic has new ‘-l -’ and ‘-p -’ options
Browse files Browse the repository at this point in the history
* NEWS, zic.8: Mention this.
* zic.c (dolink): If fromfield is "-", simply remove tofield.
  • Loading branch information
eggert committed Jun 13, 2020
1 parent c9e3778 commit 180f76a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
12 changes: 12 additions & 0 deletions zic.8
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion zic.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,14 +981,15 @@ 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;

/*
** 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);
Expand All @@ -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);
Expand Down

0 comments on commit 180f76a

Please sign in to comment.