diff options
author | se <se@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-30 15:43:52 +0000 |
---|---|---|
committer | se <se@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f> | 2020-10-30 15:43:52 +0000 |
commit | 26aca9c216db98c30ebff05cb31905f125ee76c6 (patch) | |
tree | edc6d77f2f3d597af695e2f640f676e8bb95e051 | |
parent | b587f0ccbab54aaa1f4cfbe296df3585588bac71 (diff) | |
download | freebsd-26aca9c216db98c30ebff05cb31905f125ee76c6.tar.gz freebsd-26aca9c216db98c30ebff05cb31905f125ee76c6.tar.bz2 |
Print calendar entries in the order they occur
The calendar program used to output entries in reverse order, due to the
way an internal linked list was built up.
A regression test with 2 entries for the same day has been adapted to the
now non-reversed order.
MFC after: 3 days
git-svn-id: http://svn.freebsd.org/base/head@367173 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
-rw-r--r-- | usr.bin/calendar/dates.c | 10 | ||||
-rw-r--r-- | usr.bin/calendar/tests/regress.s5.out | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/calendar/dates.c b/usr.bin/calendar/dates.c index e30e86485a6..6ba4e3a4a6f 100644 --- a/usr.bin/calendar/dates.c +++ b/usr.bin/calendar/dates.c @@ -64,6 +64,7 @@ struct cal_day { struct cal_month *month; /* points back */ struct cal_year *year; /* points back */ struct event *events; + struct event *lastevent; }; int debug_remember = 0; @@ -446,8 +447,13 @@ void addtodate(struct event *e, int year, int month, int day) { struct cal_day *d; + struct event *ee; d = find_day(year, month, day); - e->next = d->events; - d->events = e; + ee = d->lastevent; + if (ee != NULL) + ee->next = e; + else + d->events = e; + d->lastevent = e; } diff --git a/usr.bin/calendar/tests/regress.s5.out b/usr.bin/calendar/tests/regress.s5.out index 8ce6a0cab40..5134fde7b90 100644 --- a/usr.bin/calendar/tests/regress.s5.out +++ b/usr.bin/calendar/tests/regress.s5.out @@ -1,3 +1,3 @@ -Jun 21* sunthird Jun 21 jun 21 +Jun 21* sunthird Jun 22 jun 22 |