[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hbday bug
- To: http://www.repbot.org/~mike (Michael Abbott), http://www.comcast.net/~mja63 (Michael Abbott)
- Subject: Re: hbday bug
- From: http://dummy.us.eu.org/robert (Robert)
- Date: Tue, 18 Jan 2005 07:16:47 -0800
- Keywords: http://www.comcast.net/~mja63
> From: Mike Abbott <http://www.comcast.net/~mja63>
> Date: Sun, 16 Jan 2005 20:23:00 -0800 (PST)
>
> > I need another feature in hbday.
>
> OK. Let me know when you have implemented it and I'll merge in your
> change!
OK, I implemented the change. I think it's correct. The patch is below.
-------------------------------------------------------------------------------
--- hbday.c.orig Fri Jan 5 10:19:31 2001
+++ hbday.c Mon Jan 17 16:02:51 2005
@@ -93,7 +93,7 @@
register int c;
register struct tm *tp;
register char **dbl;
- int daysahead, today, readlibdb = 1, readhomedb = 1;
+ int daysahead1, daysahead2, today, readlibdb = 1, readhomedb = 1;
time_t now;
char database[128];
extern char *optarg;
@@ -134,16 +134,24 @@
readhomedb = 0;
break;
default:
- fprintf(stderr, "Usage: %s [-behln] [-f database] [daysahead]\n",
+ fprintf(stderr, "Usage: %s [-behln] [-f database] [[firstdaysahead] daysahead]\n",
argv[0]);
exit(1);
}
}
+ daysahead1 = 0;
+ /* Parse the days ahead argument, if there is one. */
+ if (optind > 0 && optind < argc - 1) {
+ if ((daysahead1 = atoi(argv[optind])) < 0)
+ daysahead1 = 0;
+ optind++;
+ }
+
/* Parse the days ahead argument, if there is one. */
if (optind > 0 && optind < argc &&
- (daysahead = atoi(argv[optind])) < 0)
- daysahead = 0;
+ (daysahead2 = atoi(argv[optind])) < 0)
+ daysahead2 = 0;
dbl = &dblist[1];
/* Read the personal database ($HOME/.hbdays) unless -n given */
@@ -198,7 +206,7 @@
* Scan once for both today's and upcoming holidays and
* birthdays.
*/
- hbscan(fp, today, daysahead);
+ hbscan(fp, today, daysahead1, daysahead2);
fclose(fp);
}
@@ -291,9 +299,9 @@
* Scan the file fp for events that occur either today or daysahead days from
* today, and print them.
*/
-hbscan(fp, today, daysahead)
+hbscan(fp, today, daysahead1, daysahead2)
register FILE *fp;
-int today, daysahead;
+int today, daysahead1, daysahead2;
{
register char *bp;
char buf[BUFSIZ], *xp;
@@ -351,8 +359,8 @@
em + 1, ed, ey, diff);
if (entdate != -1 && diff >= 0 &&
- (countdown || (diff <= daysahead &&
- (!exact || diff == 0 || diff == daysahead) &&
+ (countdown || (diff >= daysahead1 && diff <= daysahead2 &&
+ (!exact || diff == 0 || diff == daysahead2) &&
(diff == 0 || (!noadvance &&
(holidahead || type != Holiday)))))) {
if (debug)
--- hbday.1.orig Wed Dec 8 12:18:44 1999
+++ hbday.1 Mon Jan 17 16:09:58 2005
@@ -5,7 +5,9 @@
.B hbday
[ \-behln ] [ \-f
.B database
-] [
+] [[
+.B firstdaysahead
+]
.B daysahead
]
.SH DESCRIPTION
@@ -29,7 +31,13 @@
argument is given, advance notice will be given under the heading "Coming
up" for up to
.I daysahead
-days prior to the date of the event. (It is not possible to list events in
+days prior to the date of the event. When
+.I firstdaysahead
+is also given, advance notice will only be given for events on or after
+.I firstdayshead
+days prior to the date of the event in addition to being limited by
+.I dayshead
+as described previously. (It is not possible to list events in
the past.) Advance notice is given only of upcoming birthdays and
anniversaries unless the
.I \-h