=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/calendar/day.c,v retrieving revision 1.29 retrieving revision 1.31 diff -u -r1.29 -r1.31 --- src/usr.bin/calendar/day.c 2015/03/17 19:31:30 1.29 +++ src/usr.bin/calendar/day.c 2015/12/07 18:46:35 1.31 @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.29 2015/03/17 19:31:30 millert Exp $ */ +/* $OpenBSD: day.c,v 1.31 2015/12/07 18:46:35 espie Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -78,6 +78,14 @@ static struct fixs nmonths[13]; /* short national month names */ void +fill_print_date(struct match *m, struct tm *tm) +{ + if (strftime(m->print_date, sizeof(m->print_date), + daynames ? "%a %b %d" : "%b %d", tm) == 0) + m->print_date[sizeof(m->print_date) - 1] = '\0'; +} + +void setnnames(void) { char buf[80]; @@ -286,7 +294,7 @@ /* adjust bodun rate */ if (bodun && !bodun_always) bodun = !arc4random_uniform(3); - + /* Easter or Easter depending days */ if (flags & F_SPECIAL) vwd = v1; @@ -455,12 +463,7 @@ } (void)mktime(&tmtmp); - if (strftime(tmp->print_date, - sizeof(tmp->print_date), - /* "%a %b %d", &tm); Skip weekdays */ - "%b %d", &tmtmp) == 0) - tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; - + fill_print_date(tmp, &tmtmp); tmp->var = varp; tmp->next = NULL; return(tmp); @@ -549,11 +552,7 @@ if ((tmp = malloc(sizeof(struct match))) == NULL) err(1, NULL); tmp->when = ttmp; - if (strftime(tmp->print_date, - sizeof(tmp->print_date), - /* "%a %b %d", &tm); Skip weekdays */ - "%b %d", &tmtmp) == 0) - tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; + fill_print_date(tmp, &tmtmp); tmp->bodun = bodun && tdiff == -1; tmp->var = varp; tmp->next = NULL;