[net.bugs.v7] Bug in calendar

mjs (01/12/83)

One of the users on my 4.1 BSD machine has been complaining that his
calendar hasn't been working since the 1st of the year, and after a bit
of head scratching and a cup of coffee, I discovered that calendar
doesn't care for a specification like `01/01 Happy New Year! (hic)' due
to the leading `0' in the month.
So, I patched /usr/src/cmd/calendar/calendar.c thusly:

*** /usr/src/cmd/calendar/calendar.c	Sat Feb 28 23:49:36 1981
--- calendar.c	Tue Jan 11 17:42:14 1983
***************
*** 30,36
  {
  	struct tm *tm;
  	tm = localtime(&t);
! 	printf("(^|[ (,;])((%s[^ ]* *|%d/)0*%d)([^0123456789]|$)\n",
  		month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
  	printf("(^|[ (,;])((\\* *)0*%d)([^0123456789]|$)\n",
  		tm->tm_mday);

--- 30,36 -----
  {
  	struct tm *tm;
  	tm = localtime(&t);
! 	printf("(^|[ (,;])((%s[^ ]* *|0*%d/)0*%d)([^0123456789]|$)\n",
  		month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
  	printf("(^|[ (,;])((\\* *)0*%d)([^0123456789]|$)\n",
  		tm->tm_mday);
***************

	Marty Shannon, Jr.
	BTL MH 5F-120 x3199