Bug in zic.c?
Arthur David Olson
olsona at lecserver.nci.nih.gov
Wed Sep 29 12:55:19 UTC 2010
That is indeed a bug--in particular, in the DOWLEQ (<=) code.
The bug wasn't triggered up to now since all the distributed rules use
DOWGEQ (>=). Below is a proposed fix (and slight simplification).
Note that the checks are needed to ensure that rules specified in the
zic input are representable by POSIX environment variables.
--ado
------- zic.c -------
*** /tmp/geta23934 Wed Sep 29 08:45:01 2010
--- /tmp/getb23934 Wed Sep 29 08:45:01 2010
***************
*** 3,9 ****
** 2006-07-17 by Arthur David Olson.
*/
! static char elsieid[] = "@(#)zic.c 8.22";
#include "private.h"
#include "locale.h"
--- 3,9 ----
** 2006-07-17 by Arthur David Olson.
*/
! static char elsieid[] = "@(#)zic.c 8.23";
#include "private.h"
#include "locale.h"
***************
*** 1881,1896 ****
register int week;
if (rp->r_dycode == DC_DOWGEQ) {
! week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
! if ((week - 1) * DAYSPERWEEK + 1 != rp->r_dayofmonth)
return -1;
} else if (rp->r_dycode == DC_DOWLEQ) {
if (rp->r_dayofmonth == len_months[1][rp->r_month])
week = 5;
else {
! week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
! if (week * DAYSPERWEEK - 1 != rp->r_dayofmonth)
return -1;
}
} else return -1; /* "cannot happen" */
(void) sprintf(result, "M%d.%d.%d",
--- 1881,1896 ----
register int week;
if (rp->r_dycode == DC_DOWGEQ) {
! if ((rp->r_dayofmonth % DAYSPERWEEK) != 1)
return -1;
+ week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
} else if (rp->r_dycode == DC_DOWLEQ) {
if (rp->r_dayofmonth == len_months[1][rp->r_month])
week = 5;
else {
! if ((rp->r_dayofmonth % DAYSPERWEEK) != 0)
return -1;
+ week = rp->r_dayofmonth / DAYSPERWEEK;
}
} else return -1; /* "cannot happen" */
(void) sprintf(result, "M%d.%d.%d",
More information about the tz
mailing list