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>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010203070200050604080102
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
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
--------------010203070200050604080102
Content-Type: text/plain;
name="calendar.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="calendar.patch"
--- 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);
}
}
--------------010203070200050604080102--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EFEF589.2030304>
