From wkb@freebie.xs4all.nl  Thu Jan 31 11:34:56 2002
Return-Path: <wkb@freebie.xs4all.nl>
Received: from freebie.xs4all.nl (freebie.xs4all.nl [213.84.32.253])
	by hub.freebsd.org (Postfix) with ESMTP id 5A10B37B404
	for <FreeBSD-gnats-submit@FreeBSD.org>; Thu, 31 Jan 2002 11:34:55 -0800 (PST)
Received: (from wkb@localhost)
	by freebie.xs4all.nl (8.11.6/8.11.6) id g0VJYs904520;
	Thu, 31 Jan 2002 20:34:54 +0100 (CET)
	(envelope-from wkb)
Message-Id: <200201311934.g0VJYs904520@freebie.xs4all.nl>
Date: Thu, 31 Jan 2002 20:34:54 +0100 (CET)
From: wilko@FreeBSD.org
Reply-To: wilko@FreeBSD.org
To: FreeBSD-gnats-submit@FreeBSD.org
Subject: calendar(1) does not understand calendars
X-Send-Pr-Version: 3.2

>Number:         34497
>Category:       bin
>Synopsis:       calendar(1) does not understand calendars
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 31 11:40:02 PST 2002
>Closed-Date:    Mon Mar 01 00:54:02 UTC 2010
>Last-Modified:  Mon Mar 01 00:54:02 UTC 2010
>Originator:     Wilko Bulte
>Release:        FreeBSD 4-STABLE i386
>Organization:
Private FreeBSD site - The Netherlands
>Environment:

FreeBSD freebie.xs4all.nl 4.5-STABLE FreeBSD 4.5-STABLE #5: Wed Jan 30 22:12:43 CET 2002     root@freebie.xs4all.nl:/usr/obj/usr/src/sys/FREEBIE  i386

>Description:

	calendar(1) does not understand calendars, has 33 days in 
 	January for example.

>How-To-Repeat:

Given the following calendar file:

Thursday        BAR
Friday 		FOO
Saturday	DUH

running calendar displays:

Jan 31* BAR
Jan 32* FOO
Jan 33* DUH

When run on Thu Jan 31 20:32:12 CET 2002

January with 33 days appears slightly odd.

>Fix:

>Release-Note:
>Audit-Trail:

From: David Taylor <davidt@yadt.co.uk>
To: wilko@FreeBSD.org
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/34497: calendar(1) does not understand calendars
Date: Thu, 31 Jan 2002 21:24:00 +0000

 --cNdxnHkX5QqsyA0e
 Content-Type: text/plain; charset=iso-8859-15
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Thu, 31 Jan 2002, wilko@FreeBSD.org wrote:
 >=20
 > >Number:         34497
 > >Category:       bin
 > >Synopsis:       calendar(1) does not understand calendars
 >=20
 > >Description:
 >=20
 > 	calendar(1) does not understand calendars, has 33 days in=20
 >  	January for example.
 >=20
 > >How-To-Repeat:
 >=20
 > Given the following calendar file:
 >=20
 > Thursday        BAR
 > Friday 		FOO
 > Saturday	DUH
 >=20
 > running calendar displays:
 >=20
 > Jan 31* BAR
 > Jan 32* FOO
 > Jan 33* DUH
 >=20
 > When run on Thu Jan 31 20:32:12 CET 2002
 >=20
 > January with 33 days appears slightly odd.
 >=20
 
 Yeah, it does.
 
 For some reason, I was bored and decided to look at the source to see if I
 could fix it.  I regret that move now :)
 
 First thing I noticed was the code for the -a option (to run as root, and
 loop through every user's calendar:
 
                 while ((pw =3D getpwent()) !=3D NULL) {
                         (void)setegid(pw->pw_gid);
                         (void)initgroups(pw->pw_name, pw->pw_gid);
                         (void)seteuid(pw->pw_uid);
                         if (!chdir(pw->pw_dir))
                                 cal();
                         (void)seteuid(0);
                 }
 
 Which helpfully casts the return value of setegid()/seteuid()/etc to
 (void) and ignores it, so if there _is_ an error, it will just read the
 user-definable calendar file (which can include arbitrary files) as
 root...  not sure that's a good idea.
 
 I was going to submit a patch for that along with a fix for the original
 problem, until I decided there was no way I was fixing the original
 problem.
 
 The code is rather weird and obfusciated, but I managed to create a fix
 for the specific problem reported, but that doesn't stop '2002-01-33'
 being misinterpreted, along with other problems that cropped up....
 
 The easiest way I can see to fix it (instead of adding yet more horrible
 code to an already messy program) would be to change the design from:
 
 for each entry in calendar file:
 	Assign date to entry.
 	If date is within user-specified range of dates to display:
 		Display date
 	endif
 loop
 
 (which currently results in assigning 'Jan 32' to 'Friday', and also means
 if you have something to do every Thursday (e.g. clean car, or something),
 and ask for every entry for the next 60 days, you will only get one 'clean
 car' entry, instead of 8 or 9)
 
 to
 
 for each date in user-specified range:
 	for each entry in calendar file:
 		if entry could represent current date:
 			Display date
 		endif
 	loop
 loop
 
 Thus, you'd have the date 'Feb 01' and the entry 'Thursday', and just have
 to check if 'Feb 01' is 'Thursday'.
 
 However, I don't have enough time to write a calendar(1) replacement from
 scratch..
 
 Personally, if I was a committer, I'd rip calendar(1) out of the cvs
 repo. :)   [although that may explain why i'm not a committer :)].
 
 Is there a similar program anywhere in /usr/ports?  I can see various
 replacements for cal(1), and a few programs that appear to be X-versions
 of calendar(1), but nothing that claims to be a better console version of
 calendar(1).  Bah.
 
 --=20
 David Taylor
 davidt@yadt.co.uk
 "The future just ain't what it used to be"
 
 --cNdxnHkX5QqsyA0e
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE8WbXvfIqKXSsJ/xERAnv/AJ9LiGkUiKRSdEvfPMgfepdt64TGdACfa7oG
 UzHO9enfjAXK5fTfz4SLFFQ=
 =+sv/
 -----END PGP SIGNATURE-----
 
 --cNdxnHkX5QqsyA0e--

From: Mike Makonnen <mike_makonnen@yahoo.com>
To: David Taylor <davidt@yadt.co.uk>
Cc: bug-followup@freebsd.org
Subject: Re: bin/34497: calendar(1) does not understand calendars
Date: Thu, 31 Jan 2002 17:14:48 -0800

 On Thu, 31 Jan 2002 13:30:02 -0800 (PST)
 David Taylor <davidt@yadt.co.uk> wrote:
 
 >  The code is rather weird and obfusciated, but I managed to create a
 fix
 >  for the specific problem reported, but that doesn't stop '2002-01-33'
 >  being misinterpreted, along with other problems that cropped up....
 
 Hah! That's an understatement! Calendar(1) could be used as a prime
 example of how *not* to write code.
 
 >  
 >  However, I don't have enough time to write a calendar(1) replacement
 from
 >  scratch..
 
 There's also a few other bugs in the code that I have come accross (i.e.
 - it can't handle 'the first Thursday of every month') and which I
 thought about fixing, but I've been putting it off because of the time
 it would take. I'm in agreement with you: any way you look at it the
 *only* solution IMO is to rewrite the damned thing. 
 
 Now that I know others would be interested in getting it fixed I'm
 willing to go ahead and do that if a committer is willing to take a look
 at my code.
 
 
 cheers,
 mike makonnen

From: Sheldon Hearn <sheldonh@starjuice.net>
To: David Taylor <davidt@yadt.co.uk>
Cc: bug-followup@freebsd.org
Subject: Re: bin/34497: calendar(1) does not understand calendars 
Date: Tue, 05 Feb 2002 11:47:16 +0200

 On Fri, 01 Feb 2002 16:20:58 GMT, David Taylor wrote:
 
 > OpenBSD does appear to have a fix for that problem (almost identical to my
 > fix, in fact).
 
 Could you post the patch from OpenBSD that fixes this problem?  While I
 appreciate that you put effort into your own patch, it's better to keep
 the differences between us and the other BSD's down to a minimum.
 
 Please copy your feedback to <bug-followup@freebsd.org>, using the
 subject line of this message.
 
 Ciao,
 Sheldon.

From: "Michael A. Dickerson" <mikey@singingtree.com>
To: freebsd-gnats-submit@freebsd.org, wilko@freebsd.org
Cc: sheldonh@starjuice.net
Subject: Re: bin/34497: calendar(1) does not understand calendars
Date: Fri, 15 Mar 2002 02:01:05 -0800 (PST)

 -----BEGIN PGP SIGNED MESSAGE-----
 
 (disclaimer: I haven't used gnats or contributed code before, so if I've
 gone about this all wrong, please accept my apologies.)
 
 I also encountered the calendar(1) problem where it doesn't understand
 recurring events such as 'the first Thursday of every month.' I fetched
 the OpenBSD calendar source and applied some minor hacks to get it to
 compile happily on FreeBSD.
 
 So, now I've got a calendar(1) that seems to understand recurring events
 correctly.  I was also able to reproduce the 'Jan 33' problem from the
 original PR and verified that it is fixed in the new calendar.  I've also
 created a patch and verified that it works against the
 /usr/src/usr.bin/calendar directory in my 4.5-STABLE source tree.
 
 However, this patch is rather large (at 60k, larger than the total size of
 the calendar sources).  This is partly because I favored OpenBSD changes
 in a lot of unnecessary instances, since Sheldon Hearn suggested that it
 would be best to minimize differences with the OpenBSD version.  Would
 someone please tell me the appropriate way to submit the patch?  Is it
 acceptable to post text attachments of that size here?
 
 Thanks,
 Michael Dickerson <mikey@singingtree.com>
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iQCVAwUBPJHGaUqseXnC5Ui5AQHxPwP/WHLneiwyTVt1mGF7G5w/LsPDYc/wkxfJ
 YhlaAPTgeesI1NzYwJ+QgzGkE2TCUBSke83gmb7MiVywEF5reMKRg/n530YzxARx
 lCXSaU8evmrZX1jOeq2LJXvVIXBsChsXPKgLj4xTrhXwKPRQmE7s1tN+cVru1QS5
 7ipvYb9fVpw=
 =BDFY
 -----END PGP SIGNATURE-----
 
Responsible-Changed-From-To: freebsd-bugs->grog 
Responsible-Changed-By: kris 
Responsible-Changed-When: Thu Nov 6 19:05:53 PST 2003 
Responsible-Changed-Why:  
Assign to calendar maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34497 
Responsible-Changed-From-To: grog->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Jun 25 02:12:49 UTC 2007 
Responsible-Changed-Why:  
grog@ asked me take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=4629 
Responsible-Changed-From-To: grog->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Jun 25 02:12:49 UTC 2007 
Responsible-Changed-Why:  
grog@ asked me to take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26658 
Responsible-Changed-From-To: grog->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Jun 25 02:12:49 UTC 2007 
Responsible-Changed-Why:  
grog@ asked me to take this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34497 
Responsible-Changed-From-To: edwin->freebsd-bugs 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Feb 14 10:27:36 UTC 2008 
Responsible-Changed-Why:  
Give back into the pool until later. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34497 
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Mon Mar 1 00:53:12 UTC 2010 
State-Changed-Why:  
Cannot reproduce this issue with a current calendar-file. 
It will most likely be resolved by the upcoming calendar anyway.  


Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Mar 1 00:53:12 UTC 2010 
Responsible-Changed-Why:  
My field. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=34497 
>Unformatted:
