diff -u /usr/src/usr.bin/calendar/calendar.c ./calendar.c --- /usr/src/usr.bin/calendar/calendar.c 2014-03-03 19:22:25.000000000 +0100 +++ ./calendar.c 2014-03-12 23:36:31.000000000 +0100 @@ -209,8 +209,10 @@ (void)setegid(pw->pw_gid); (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); - if (!chdir(pw->pw_dir)) + if (!chdir(pw->pw_dir)) { cal(); + remove_all_events(); + } (void)seteuid(0); } else diff -u /usr/src/usr.bin/calendar/calendar.h ./calendar.h --- /usr/src/usr.bin/calendar/calendar.h 2014-03-03 19:22:25.000000000 +0100 +++ ./calendar.h 2014-03-12 23:53:24.000000000 +0100 @@ -120,6 +120,7 @@ struct event *event_add(int, int, int, char *, int, char *, char *); void event_continue(struct event *events, char *txt); void event_print_all(FILE *fp); + struct event { int year; int month; @@ -183,6 +184,8 @@ extern int debug_remember; void generatedates(struct tm *tp1, struct tm *tp2); void dumpdates(void); +void remove_all_events(void); +void remove_eventlist(struct event **list); int remember_ymd(int y, int m, int d); int remember_yd(int y, int d, int *rm, int *rd); int first_dayofweek_of_year(int y); @@ -190,6 +193,7 @@ int walkthrough_dates(struct event **e); void addtodate(struct event *e, int year, int month, int day); + /* pom.c */ #define MAXMOONS 18 void pom(int year, double UTCoffset, int *fms, int *nms); Common subdirectories: /usr/src/usr.bin/calendar/calendars and ./calendars diff -u /usr/src/usr.bin/calendar/dates.c ./dates.c --- /usr/src/usr.bin/calendar/dates.c 2014-02-19 00:43:47.000000000 +0100 +++ ./dates.c 2014-03-13 00:44:43.000000000 +0100 @@ -256,6 +256,45 @@ } } + +void +remove_eventlist(struct event **head) +{ + struct event *del; + del = *head; + while(del != NULL) { + *head = (*head)->next; + free(del); + del = *head; + } + free(*head); +} + + +void +remove_all_events(void) +{ + struct cal_year *y; + struct cal_month *m; + struct cal_day *d; + + y = hyear; + while (y != NULL) { + m = y->months; + while (m != NULL) { + d = m->days; + while (d != NULL) { + remove_eventlist(&d->events); + d->events = NULL; + d = d->nextday; + } + m = m->nextmonth; + } + y = y->nextyear; + } +} + + int remember_ymd(int yy, int mm, int dd) { @@ -368,6 +407,7 @@ return (-1); } + int walkthrough_dates(struct event **e) { @@ -401,6 +441,7 @@ return (1); } + y = NULL; return (0); }