diff options
Diffstat (limited to 'src/usr.bin/calendar')
-rw-r--r-- | src/usr.bin/calendar/calendar.1 | 12 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendar.c | 20 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendar.h | 9 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.all | 4 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.holiday | 11 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.music | 3 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.nz | 48 | ||||
-rw-r--r-- | src/usr.bin/calendar/day.c | 35 | ||||
-rw-r--r-- | src/usr.bin/calendar/io.c | 14 |
9 files changed, 108 insertions, 48 deletions
diff --git a/src/usr.bin/calendar/calendar.1 b/src/usr.bin/calendar/calendar.1 index f0a9596..a270eee 100644 --- a/src/usr.bin/calendar/calendar.1 +++ b/src/usr.bin/calendar/calendar.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: calendar.1,v 1.39 2015/10/23 11:01:30 zhuk Exp $ +.\" $OpenBSD: calendar.1,v 1.42 2016/01/20 19:12:28 jmc Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)calendar.1 8.1 (Berkeley) 6/29/93 .\" -.Dd $Mdocdate: October 23 2015 $ +.Dd $Mdocdate: January 20 2016 $ .Dt CALENDAR 1 .Os .Sh NAME @@ -37,7 +37,7 @@ .Nd reminder service .Sh SYNOPSIS .Nm calendar -.Op Fl ab +.Op Fl abw .Op Fl A Ar num .Op Fl B Ar num .Op Fl f Ar calendarfile @@ -82,6 +82,8 @@ instead of using the current date. If yy is specified, but cc is not, a value for yy between 69 and 99 results in a cc value of 19. Otherwise, a cc value of 20 is used. +.It Fl w +Print day of the week name in front of each event. .El .Pp To handle calendars in your national code table you can specify @@ -226,6 +228,8 @@ Jewish holidays (should be updated yearly by the local system administrator so that roving holidays are set correctly for the current year). .It Pa calendar.music Musical events, births, and deaths (strongly oriented toward rock n' roll). +.It Pa calendar.nz +New Zealand calendar. .It Pa calendar.openbsd .Ox related events. @@ -235,6 +239,8 @@ Pagan holidays, celebrations and festivals. Russian calendar. .It Pa calendar.space Cosmic history. +.It Pa calendar.uk +UK calendar. .It Pa calendar.ushistory U.S. history. .It Pa calendar.usholiday diff --git a/src/usr.bin/calendar/calendar.c b/src/usr.bin/calendar/calendar.c index 094001f..547ba08 100644 --- a/src/usr.bin/calendar/calendar.c +++ b/src/usr.bin/calendar/calendar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.c,v 1.32 2015/10/23 11:43:16 zhuk Exp $ */ +/* $OpenBSD: calendar.c,v 1.35 2015/12/07 18:46:35 espie Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -53,6 +53,7 @@ char *calendarNoMail = "nomail"; /* don't sent mail if this file exists */ struct passwd *pw; int doall = 0; +int daynames = 0; time_t f_time = 0; int bodun_always = 0; @@ -73,7 +74,7 @@ main(int argc, char *argv[]) (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "abf:t:A:B:-")) != -1) + while ((ch = getopt(argc, argv, "abwf:t:A:B:-")) != -1) switch (ch) { case '-': /* backward contemptible */ case 'a': @@ -108,6 +109,10 @@ main(int argc, char *argv[]) errx(1, "-B %s: %s", optarg, errstr); break; + case 'w': + daynames = 1; + break; + default: usage(); } @@ -117,6 +122,15 @@ main(int argc, char *argv[]) if (argc) usage(); + if (doall) { + if (pledge("stdio rpath tmppath fattr getpw id proc exec", NULL) + == -1) + err(1, "pledge"); + } else { + if (pledge("stdio rpath proc exec", NULL) == -1) + err(1, "pledge"); + } + /* use current time */ if (f_time <= 0) (void)time(&f_time); @@ -249,7 +263,7 @@ void usage(void) { (void)fprintf(stderr, - "usage: calendar [-ab] [-A num] [-B num] [-f calendarfile] " + "usage: calendar [-abw] [-A num] [-B num] [-f calendarfile] " "[-t [[[cc]yy]mm]dd]\n"); exit(1); } diff --git a/src/usr.bin/calendar/calendar.h b/src/usr.bin/calendar/calendar.h index b54d0b2..ac33b0d 100644 --- a/src/usr.bin/calendar/calendar.h +++ b/src/usr.bin/calendar/calendar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.h,v 1.14 2015/03/15 00:41:28 millert Exp $ */ +/* $OpenBSD: calendar.h,v 1.15 2015/12/07 18:46:35 espie Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -34,6 +34,7 @@ extern struct passwd *pw; extern int doall; +extern int daynames; extern int bodun_always; extern time_t f_time; extern struct tm *tp; @@ -46,9 +47,11 @@ struct fixs { int len; }; +#define PRINT_DATE_BASE_LEN 35 + struct event { time_t when; - char print_date[31]; + char print_date[PRINT_DATE_BASE_LEN+1]; char **desc; char *ldesc; struct event *next; @@ -56,7 +59,7 @@ struct event { struct match { time_t when; - char print_date[30]; + char print_date[PRINT_DATE_BASE_LEN]; int bodun; int var; struct match *next; diff --git a/src/usr.bin/calendar/calendars/calendar.all b/src/usr.bin/calendar/calendars/calendar.all index 172357d..9e759bf 100644 --- a/src/usr.bin/calendar/calendars/calendar.all +++ b/src/usr.bin/calendar/calendars/calendar.all @@ -1,7 +1,7 @@ /* * International and national calendar files * - * $OpenBSD: calendar.all,v 1.5 2013/03/15 08:37:10 jmc Exp $ + * $OpenBSD: calendar.all,v 1.7 2016/01/20 19:12:28 jmc Exp $ */ #ifndef _calendar_all_ @@ -17,5 +17,7 @@ #include <calendar.ushistory> #include <calendar.space> #include <calendar.canada> +#include <calendar.uk> +#include <calendar.nz> #endif /* !_calendar_all_ */ diff --git a/src/usr.bin/calendar/calendars/calendar.holiday b/src/usr.bin/calendar/calendars/calendar.holiday index ca9e5e0..4f87ead 100644 --- a/src/usr.bin/calendar/calendars/calendar.holiday +++ b/src/usr.bin/calendar/calendars/calendar.holiday @@ -1,7 +1,7 @@ /* * Holiday * - * $OpenBSD: calendar.holiday,v 1.32 2015/10/12 06:33:21 jmc Exp $ + * $OpenBSD: calendar.holiday,v 1.35 2016/01/20 19:12:28 jmc Exp $ */ #ifndef _calendar_holiday_ @@ -12,7 +12,6 @@ 01/01 Universal Fraternity Day in Mozambique 01/02 Ancestry Day in Haiti 01/02 St. Berchtold's Day in Switzerland -01/03 New Year's Holiday in Scotland 01/03 Revolution Day in Upper Volta 01/04 Independence Day in Burma 01/04 Martyrs Day in Zaire @@ -45,7 +44,6 @@ 02/02 Candlemas 02/04 Independence Commemoration Day in Sri Lanka 02/05 Constitution Day in Mexico -02/06 New Zealand Day 02/07 Independence Day in Grenada 02/08 Preseren Day (Cultural Holiday) in Slovenia 02/09 St. Maron's Day in Lebanon @@ -138,7 +136,7 @@ 04/22 Oklahoma Day in Oklahoma 04/24 Victory Day in Togo 04/24* Pesach - First Day of Passover - Festival of Freedom -04/25 Anzac Day in Australia, New Zealand, Tonga, Western Samoa +04/25* ANZAC Day in Australia, New Zealand, and various other influenced places 04/25 Liberation Day in Italy 04/25 National Flag Day in Swaziland 04/26 Confederate Memorial Day in Florida & Georgia @@ -285,7 +283,6 @@ 08/03 Independence Day in Jamaica, Niger 08/03 Memorial Day of Archbishop Makarios in Cyprus 08/04 Freedom Day in Guyana -08/05* Bank Holiday in Scotland and Northern Ireland 08/06 Bank Holiday in Australia, British Columbia, Fiji, Iceland, Ireland, Ontario 08/06 Emancipation Day in Bahamas @@ -393,7 +390,6 @@ 10/23 Chulalongkron's Day in Thailand 10/24 Independence Day in Zambia 10/24 United Nations Day -10/25 Labor Day in New Zealand 10/25 Taiwan Restoration Day in Taiwan 10/26 Agam Day in Nauru 10/26 Armed Forces Day in Benin, Rwanda @@ -435,7 +431,7 @@ 11/30 Independence Day in Barbados, People's Democratic Yemen Republic 11/30 National Day in Benin 11/30 National Heroes Day in Philippines -11/30 St. Andrew's Day +11/30 Saint Andrew's Day (also a bank holiday in Scotland) 12/01 Independence Day in Central African Republic 12/01 World AIDS Day 12/01 National Day in Romania @@ -490,7 +486,6 @@ 06/02 Corpus Christi in Paraguay 06/MonFirst Jefferson Davis's Birthday in Alabama & Mississippi (1st Monday) 06/MonFirst Jefferson Davis's Birthday in Florida, Georgia, & S. Carolina -06/04 Queen's Birthday in New Zealand 06/06 His Majesty, Yang Di-Pertuan Agong's Birthday in Malaysia 06/11 Queen's Birthday 06/12 Peace with Bolivia in Paraguay diff --git a/src/usr.bin/calendar/calendars/calendar.music b/src/usr.bin/calendar/calendars/calendar.music index 68bb1a7..d4bd30a 100644 --- a/src/usr.bin/calendar/calendars/calendar.music +++ b/src/usr.bin/calendar/calendars/calendar.music @@ -1,7 +1,7 @@ /* * Music * - * $OpenBSD: calendar.music,v 1.32 2015/05/21 10:42:30 jmc Exp $ + * $OpenBSD: calendar.music,v 1.33 2016/01/11 07:46:37 sthen Exp $ */ #ifndef _calendar_music_ @@ -23,6 +23,7 @@ 01/10 Jim Croce is born in Philadelphia, 1943 01/10 Pat Benatar is born in Long Island, 1952 01/10 Rod Stewart is born in Glasgow, Scotland, 1945 +01/11 David Bowie dies, 2016 01/11 Maurice Durufle is born in Louviers, France, 1902 01/11 Reinhold Gliere is born in Kiev, Russia, 1875 01/13 Eric Clapton plays the "Rainbow Concert" in London, 1973 diff --git a/src/usr.bin/calendar/calendars/calendar.nz b/src/usr.bin/calendar/calendars/calendar.nz new file mode 100644 index 0000000..619b980 --- /dev/null +++ b/src/usr.bin/calendar/calendars/calendar.nz @@ -0,0 +1,48 @@ +/* + * New Zealand holiday + * + * $OpenBSD: calendar.nz,v 1.1 2016/01/20 19:12:28 jmc Exp $ + */ + +#ifndef _calendar_nz_ +#define _calendar_nz_ + +01/01 New Year's Day +01/02 Day after New Year's Day (public holiday) +02/06* New Zealand/Waitangi Day (public holiday) +02/14 Saint Valentine's Day +04/01 April Fools' Day +04/SunFirst Daylight Saving Time ends; clocks move back (first Sunday of April) +05/SunSecond Mother's Day (2nd Sunday in May) +06/MonFirst Queen's Birthday (public holiday, ski season begins) +09/SunFirst Father's Day (1st Sunday of September) +09/26 Dominion Day +09/SunLast Daylight Saving Time starts; clocks move forward (last Sunday in September) +10/MonFourth Labour Day (public holiday) +10/31 Halloween +11/05 Guy Fawkes' Night +12/25 Christmas Day +12/26 Boxing Day +12/31 New Year's Eve + +/* Provincial anniversary days */ +01/22* Wellington Anniversary Day +01/29* Auckland and Northland Anniversary Days +02/01* Nelson Anniversary Day +03/23* Otago Anniversary Day +03/MonSecond New Plymouth Anniversary Day +Easter+2 Southland Anniversary Day +09/MonFourth South Canterbury Anniversary Day +09/FriThird Hawke's Bay Anniversary Day +11/01* Marlborough Anniversary Day +11/30* Chatham Islands Anniversary Day +12/01* Westland Anniversary Day +12/16* South Canterbury Anniversary Day + +/* Seasonal days */ +03/20* Autumnal Equinox +06/21* Winter Solstice +09/22* Vernal Equinox +12/21* Summer Solstice + +#endif /* !_calendar_nz_ */ diff --git a/src/usr.bin/calendar/day.c b/src/usr.bin/calendar/day.c index 0d73aae..cea9709 100644 --- a/src/usr.bin/calendar/day.c +++ b/src/usr.bin/calendar/day.c @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.30 2015/10/23 11:43:16 zhuk Exp $ */ +/* $OpenBSD: day.c,v 1.32 2015/12/08 19:04:50 mmcc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -78,6 +78,14 @@ static struct fixs fnmonths[13]; /* full national months names */ 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]; @@ -90,8 +98,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (ndays[i].name != NULL) - free(ndays[i].name); + free(ndays[i].name); if ((ndays[i].name = strdup(buf)) == NULL) err(1, NULL); ndays[i].len = strlen(buf); @@ -100,8 +107,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (fndays[i].name != NULL) - free(fndays[i].name); + free(fndays[i].name); if ((fndays[i].name = strdup(buf)) == NULL) err(1, NULL); fndays[i].len = strlen(buf); @@ -113,8 +119,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (nmonths[i].name != NULL) - free(nmonths[i].name); + free(nmonths[i].name); if ((nmonths[i].name = strdup(buf)) == NULL) err(1, NULL); nmonths[i].len = strlen(buf); @@ -123,8 +128,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (fnmonths[i].name != NULL) - free(fnmonths[i].name); + free(fnmonths[i].name); if ((fnmonths[i].name = strdup(buf)) == NULL) err(1, NULL); fnmonths[i].len = strlen(buf); @@ -455,12 +459,7 @@ isnow(char *endp, int bodun) } (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 +548,7 @@ isnow(char *endp, int bodun) 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; diff --git a/src/usr.bin/calendar/io.c b/src/usr.bin/calendar/io.c index 05fe7ae..f17cacb 100644 --- a/src/usr.bin/calendar/io.c +++ b/src/usr.bin/calendar/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.42 2015/10/23 12:36:23 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.43 2015/12/08 19:04:50 mmcc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -98,8 +98,7 @@ cal(void) !strcmp(buf + 5, "by_BY.KOI8-B")) { bodun_maybe++; bodun = 0; - if (prefix) - free(prefix); + free(prefix); prefix = NULL; } else bodun_maybe = 0; @@ -124,8 +123,7 @@ cal(void) calendar = LUNAR; } else if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) { bodun++; - if (prefix) - free(prefix); + free(prefix); if ((prefix = strdup(buf + 6)) == NULL) err(1, NULL); continue; @@ -138,8 +136,7 @@ cal(void) (p - buf == spev[i].nlen) && buf[spev[i].nlen + 1]) { p++; - if (spev[i].uname != NULL) - free(spev[i].uname); + free(spev[i].uname); if ((spev[i].uname = strdup(p)) == NULL) err(1, NULL); spev[i].ulen = strlen(p); @@ -211,8 +208,7 @@ cal(void) tmp = events; while (tmp) { events = tmp; - if (tmp->ldesc) - free(tmp->ldesc); + free(tmp->ldesc); tmp = tmp->next; free(events); } |