svn commit: r367173 - in head/usr.bin/calendar: . tests
Stefan Eßer
se at FreeBSD.org
Fri Oct 30 15:43:53 UTC 2020
Author: se
Date: Fri Oct 30 15:43:52 2020
New Revision: 367173
URL: https://svnweb.freebsd.org/changeset/base/367173
Log:
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
Modified:
head/usr.bin/calendar/dates.c
head/usr.bin/calendar/tests/regress.s5.out
Modified: head/usr.bin/calendar/dates.c
==============================================================================
--- head/usr.bin/calendar/dates.c Fri Oct 30 14:42:02 2020 (r367172)
+++ head/usr.bin/calendar/dates.c Fri Oct 30 15:43:52 2020 (r367173)
@@ -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;
}
Modified: head/usr.bin/calendar/tests/regress.s5.out
==============================================================================
--- head/usr.bin/calendar/tests/regress.s5.out Fri Oct 30 14:42:02 2020 (r367172)
+++ head/usr.bin/calendar/tests/regress.s5.out Fri Oct 30 15:43:52 2020 (r367173)
@@ -1,3 +1,3 @@
-Jun 21* sunthird
Jun 21 jun 21
+Jun 21* sunthird
Jun 22 jun 22
More information about the svn-src-all
mailing list