Date: Sat, 31 Dec 2011 12:44:09 +0100 From: Marco Steinbach <coco@executive-computing.de> To: freebsd-current@freebsd.org Subject: [cft] Small patch for calendar(1) Message-ID: <4EFEF589.2030304@executive-computing.de>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi,
for a while now, calendar(1) seems to have forgotten how to handle what
the man page describes as: 'A month without a day matches the first of
that month.'
A notable result of this is, that the output of 'calendar -f
/usr/share/calendar/calendar.all' is always headed by 'Unprocessed'
error messages.
The attached patch tries to help calendar(1) remember how to do this as
is described in the man page.
Since I'm not an avid calendar(1) user, I'd very much like others to
review and try out the patch, before I go pester commiters by opening a PR.
MfG CoCo
[-- Attachment #2 --]
--- src/usr.bin/calendar/parsedata.c.orig 2011-12-31 11:36:40.000000000 +0100
+++ src/usr.bin/calendar/parsedata.c 2011-12-31 11:57:55.000000000 +0100
@@ -174,11 +174,22 @@
}
if (isonlydigits(date, 1)) {
/* Assume month number only */
- *flags |= F_MONTH;
+ *flags |= (F_MONTH | F_DAYOFMONTH);
+ *idayofmonth = 1;
*imonth = (int)strtol(date, (char **)NULL, 10);
strcpy(month, getmonthname(*imonth));
return(1);
}
+ if ((checkmonth(date, &len, &offset, &pmonth) != 0)) {
+ /* Assume month name only */
+ *flags |= (F_MONTH | F_DAYOFMONTH);
+ *idayofmonth = 1;
+ *imonth = offset;
+ strcpy(month, getmonthname(*imonth));
+ return(1);
+ }
+
+
return (0);
}
}
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EFEF589.2030304>
