NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/41945: calendar(1) doesn't recognize days of the week correctly sometimes
The following reply was made to PR bin/41945; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/41945: calendar(1) doesn't recognize days of the week
correctly sometimes
Date: Wed, 14 Oct 2009 18:58:59 +0700
Try this patch (against current) instead of the nonsense I sent
before, it turns out another logic change that was added to the isnow()
function caused this bug to reappear even though the (f & (A|B)) stuff
had been fixed.
Solution this time is to separate out the concept of day of month from
day of the week, and treat them differently. This means that you can
no longer write
6 entry
and have it mean "every friday" which you (sort of) could before, now
if you mean friday you have to use the name, and if you mean a date,
you have to use its number.
kre
--- /release/current/usr/src/usr.bin/calendar/calendar.c 2008-09-30
12:51:41.000000000 +0700
+++ calendar.c 2009-10-14 18:48:27.000000000 +0700
@@ -251,6 +251,7 @@
#define F_ISDAY 0x02
#define F_WILDMONTH 0x04
#define F_WILDDAY 0x08
+#define F_ISDOW 0x10
flags = 0;
@@ -258,7 +259,7 @@
if (!(v1 = getfield(endp, &endp, &flags)))
return false;
- if (flags & F_ISDAY || v1 > 12) {
+ if ((flags & (F_ISDAY|F_ISDOW)) || v1 > 12) {
/* found a day */
day = v1;
/* if no recognizable month, assume wildcard ('*') month */
@@ -295,10 +296,17 @@
if (flags & F_WILDMONTH && flags & F_ISDAY && day == tp->tm_mday)
return true;
+ if (flags & F_WILDMONTH && flags & F_ISDOW && day == tp->tm_wday)
+ return true;
+
if (flags & F_ISMONTH && flags & F_WILDDAY && month == tp->tm_mon + 1)
return true;
- if (flags & F_ISDAY)
+ if (flags & F_ISMONTH && flags & F_ISDOW && month == tp->tm_mon + 1 &&
+ day == tp->tm_wday)
+ return true;
+
+ if (flags & F_ISDOW)
day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7);
day = cumdays[month] + day;
@@ -350,7 +358,7 @@
if ((val = getmonth(start)) != 0)
*flags |= F_ISMONTH;
else if ((val = getday(start)) != 0)
- *flags |= F_ISDAY;
+ *flags |= F_ISDOW;
else {
*p = savech;
return 0;
Home |
Main Index |
Thread Index |
Old Index