Subject: bin/30107: calendar reports non-matching days.
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <bsd@allegory.demon.co.uk>
List: netbsd-bugs
Date: 05/01/2005 10:13:00
>Number:         30107
>Category:       bin
>Synopsis:       calendar reports non-matching days.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 01 10:13:00 +0000 2005
>Originator:     Bob Kemp
>Release:        NetBSD 3.99.3
>Organization:
>Environment:
	
	
System: NetBSD tenebres.loc 3.99.3 NetBSD 3.99.3 (TENEBRES) #0: Sat Apr 16 15:34:57 BST 2005 rob@tenebres.loc:/vol1/obj/sys/arch/i386/compile/TENEBRES i386
Architecture: i386
Machine: i386
>Description:

    The calendar(1) man page explicitly allows dates of the form "June 15"
    but it now shows the entry for every day of that month.

    I think the problem lies with some bit tests, as detailed in the patch below

    BTW, I've set it to serious because it does stop calendar from functioning correctly.
    Feel free to change that, if appropriate.


>How-To-Repeat:

    Create a file called "test" containing

Apr 1           April Fools day

    then type

	calendar -f $PWD/test -d 0420

    and

	calendar -f $PWD/test -d 0401

    Only the second call should produce output but for me they both do.


>Fix:

cvs diff: Diffing .
Index: calendar.c
===================================================================
RCS file: /cvsroot/src/usr.bin/calendar/calendar.c,v
retrieving revision 1.36
diff -b -c -r1.36 calendar.c
*** calendar.c  7 Dec 2004 16:47:32 -0000       1.36
--- calendar.c  1 May 2005 10:02:31 -0000
***************
*** 275,287 ****
                }
        }
  
!       if (flags & (F_WILDMONTH|F_WILDDAY))
                return (1);
  
!       if ((flags & (F_WILDMONTH|F_ISDAY)) && (day == tp->tm_mday))
                return (1);
  
!       if ((flags & (F_ISMONTH|F_WILDDAY)) && (month == tp->tm_mon + 1))
                return (1);
  
        if (flags & F_ISDAY)
--- 275,287 ----
                }
        }
  
!       if ((flags & (F_WILDMONTH|F_WILDDAY)) == (F_WILDMONTH|F_WILDDAY))
                return (1);
  
!       if (((flags & (F_WILDMONTH|F_ISDAY)) == (F_WILDMONTH|F_ISDAY)) && (day == tp->tm_mday))
                return (1);
  
!       if (((flags & (F_ISMONTH|F_WILDDAY)) == (F_ISMONTH|F_WILDDAY)) && (month == tp->tm_mon + 1))
                return (1);
  
        if (flags & F_ISDAY)
cvs diff: Diffing calendars


>Unformatted: