diff options
Diffstat (limited to 'src/usr.bin/calendar')
-rw-r--r-- | src/usr.bin/calendar/calendar.c | 13 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendar.h | 5 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.birthday | 7 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.music | 4 | ||||
-rw-r--r-- | src/usr.bin/calendar/day.c | 26 | ||||
-rw-r--r-- | src/usr.bin/calendar/io.c | 13 | ||||
-rw-r--r-- | src/usr.bin/calendar/ostern.c | 5 | ||||
-rw-r--r-- | src/usr.bin/calendar/paskha.c | 3 | ||||
-rw-r--r-- | src/usr.bin/calendar/pesach.c | 3 |
9 files changed, 43 insertions, 36 deletions
diff --git a/src/usr.bin/calendar/calendar.c b/src/usr.bin/calendar/calendar.c index b5da818..b4605b0 100644 --- a/src/usr.bin/calendar/calendar.c +++ b/src/usr.bin/calendar/calendar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.c,v 1.29 2015/02/08 23:40:34 deraadt Exp $ */ +/* $OpenBSD: calendar.c,v 1.31 2015/04/18 18:28:37 deraadt Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -40,8 +40,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <time.h> -#include <tzfile.h> #include <unistd.h> #include "pathnames.h" @@ -68,6 +68,7 @@ int main(int argc, char *argv[]) { int ch; + const char *errstr; char *caldir; (void)setlocale(LC_ALL, ""); @@ -95,12 +96,16 @@ main(int argc, char *argv[]) break; case 'A': /* days after current date */ - f_dayAfter = atoi(optarg); + f_dayAfter = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-A %s: %s", optarg, errstr); f_SetdayAfter = 1; break; case 'B': /* days before current date */ - f_dayBefore = atoi(optarg); + f_dayBefore = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-B %s: %s", optarg, errstr); break; default: diff --git a/src/usr.bin/calendar/calendar.h b/src/usr.bin/calendar/calendar.h index b6ea817..f329a07 100644 --- a/src/usr.bin/calendar/calendar.h +++ b/src/usr.bin/calendar/calendar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.h,v 1.13 2010/04/28 18:20:15 jsg Exp $ */ +/* $OpenBSD: calendar.h,v 1.14 2015/03/15 00:41:28 millert Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -95,6 +95,9 @@ void setnnames(void); * calendar time--e.g. Easter or easter depending * days */ +#define SECSPERDAY (24 * 60 * 60) +#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) + extern int f_dayAfter; /* days after current date */ extern int f_dayBefore; /* days before current date */ extern int f_SetdayAfter; /* calendar invoked with -A */ diff --git a/src/usr.bin/calendar/calendars/calendar.birthday b/src/usr.bin/calendar/calendars/calendar.birthday index 8657e9c..0f1940c 100644 --- a/src/usr.bin/calendar/calendars/calendar.birthday +++ b/src/usr.bin/calendar/calendars/calendar.birthday @@ -1,7 +1,7 @@ /* * Birthday * - * $OpenBSD: calendar.birthday,v 1.58 2014/03/06 17:36:28 jmc Exp $ + * $OpenBSD: calendar.birthday,v 1.60 2015/04/30 09:12:49 jmc Exp $ */ #ifndef _calendar_birthday_ @@ -107,6 +107,7 @@ 03/11 Robert Treat Paine born, 1731 03/11 Vannevar Bush born, 1890 03/12 Gustav Robert Kirchhoff born, 1824, physicist +03/12 Terry Pratchett (Sir) dies, 2015, author 03/14 Albert Einstein born, 1879 03/14 Casey Jones born, 1864 03/14 Giovanni Virginio Schiaparelli born, 1835, astronomer; @@ -154,17 +155,17 @@ 04/15 Jean Genet died in Paris, 1986 04/16 Charles (Charlie) Chaplin (Sir) born in London, 1889 04/19 Andre Rene the Giant (Roussimoff) born in Grenoble, France, 1946 -04/20 Adolph Hitler born, 1889 +04/20 Adolf Hitler born, 1889 04/22 Kant born, 1724 04/22 Lenin born, the best friend of all the children, 1870 04/23 Shakespeare born, 1564 04/28 James Monroe born, 1758 04/28 Mussolini executed, 1945 +04/28 Terry Pratchett (Sir) born, 1948, author 04/29 Jules Henri Poincare born, 1854, founder of topology 04/29 William Randolph Hearst born in San Francisco, 1863 04/29 Albert Hofmann died, 2008 04/30 Karl Friedrich Gauss born, 1777, mathematician & astronomer -04/30 Adolph Hitler committed suicide, 1945 05/01 Little Walter (Marion Walter Jacobs) is born in Alexandria, Louisiana, 1930 05/02 Dr. Benjamin Spock born, 1903 diff --git a/src/usr.bin/calendar/calendars/calendar.music b/src/usr.bin/calendar/calendars/calendar.music index 58b963f..67a5dc3 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.30 2013/11/26 15:25:56 sobrado Exp $ + * $OpenBSD: calendar.music,v 1.31 2015/03/13 16:38:46 sthen Exp $ */ #ifndef _calendar_music_ @@ -26,6 +26,7 @@ 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 +01/13 Daevid Allen (Gong) is born in Melbourne, 1938 01/17 Led Zeppelin's first album is released, 1969 01/19 Janis Joplin is born in Port Arthur, Texas, 1943 01/20 Walter Piston is born in Rockland, Maine, 1894 @@ -123,6 +124,7 @@ 03/13 Cesar Cui dies in Smolensk, Russia, 1918 03/14 Georg Philipp Telemann is born in Magdeburg, 1681 03/15 Sly Stone born, 1944 +03/15 Daevid Allen (Gong) dies, 2015 03/16 Enrique Granados drowns in the English Channel, 1916 03/17 Paul Kantner (Jefferson Airplane) is born in San Francisco, 1942 03/18 Nikolai Rimsky-Korsakov is born Tikhvin, Russia, 1844 diff --git a/src/usr.bin/calendar/day.c b/src/usr.bin/calendar/day.c index 4a164ba..703be4d 100644 --- a/src/usr.bin/calendar/day.c +++ b/src/usr.bin/calendar/day.c @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.27 2013/11/26 13:18:53 deraadt Exp $ */ +/* $OpenBSD: day.c,v 1.29 2015/03/17 19:31:30 millert Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -39,7 +39,6 @@ #include <stdlib.h> #include <string.h> #include <time.h> -#include <tzfile.h> #include "pathnames.h" #include "calendar.h" @@ -157,7 +156,7 @@ settime(time_t *now) tp->tm_isdst = 0; tp->tm_hour = 12; *now = mktime(tp); - if (isleap(tp->tm_year + TM_YEAR_BASE)) + if (isleap(tp->tm_year + 1900)) cumdays = daytab[1]; else cumdays = daytab[0]; @@ -215,13 +214,10 @@ Mktime(char *date) *(date + len - 4) = '\0'; tm.tm_year = atoi(date); - /* tm_year up TM_YEAR_BASE ... */ if (tm.tm_year < 69) /* Y2K */ - tm.tm_year += 2000 - TM_YEAR_BASE; - else if (tm.tm_year < 100) - tm.tm_year += 1900 - TM_YEAR_BASE; - else if (tm.tm_year > TM_YEAR_BASE) - tm.tm_year -= TM_YEAR_BASE; + tm.tm_year += 100; + else if (tm.tm_year > 1900) + tm.tm_year -= 1900; } #if DEBUG @@ -431,16 +427,16 @@ isnow(char *endp, int bodun) */ if (tp->tm_yday > 300 && tmtmp.tm_mon <= 1) variable_weekday(&vwd, tmtmp.tm_mon + 1, - tmtmp.tm_year + TM_YEAR_BASE + 1); + tmtmp.tm_year + 1900 + 1); else variable_weekday(&vwd, tmtmp.tm_mon + 1, - tmtmp.tm_year + TM_YEAR_BASE); + tmtmp.tm_year + 1900); day = cumdays[tmtmp.tm_mon + 1] + vwd; tmtmp.tm_mday = vwd; } v2 = day - tp->tm_yday; if ((v2 > v1) || (v2 < 0)) { - if ((v2 += isleap(tp->tm_year + TM_YEAR_BASE) ? 366 : 365) + if ((v2 += isleap(tp->tm_year + 1900) ? 366 : 365) <= v1) tmtmp.tm_year++; else if(!bodun || (day - tp->tm_yday) != -1) @@ -516,7 +512,7 @@ isnow(char *endp, int bodun) if (vwd) { v1 = vwd; variable_weekday(&v1, tmtmp.tm_mon + 1, - tmtmp.tm_year + TM_YEAR_BASE); + tmtmp.tm_year + 1900); tmtmp.tm_mday = v1; } else tmtmp.tm_mday = dayp; @@ -527,11 +523,11 @@ isnow(char *endp, int bodun) if (flags & F_SPECIAL) { tmtmp.tm_mon = 0; /* Gee, mktime() is nice */ tmtmp.tm_mday = spev[v1].getev(tmtmp.tm_year + - TM_YEAR_BASE) + vwd; + 1900) + vwd; } else if (vwd) { v1 = vwd; variable_weekday(&v1, tmtmp.tm_mon + 1, - tmtmp.tm_year + TM_YEAR_BASE); + tmtmp.tm_year + 1900); tmtmp.tm_mday = v1; } else { /* Need the following to keep Feb 29 from diff --git a/src/usr.bin/calendar/io.c b/src/usr.bin/calendar/io.c index 31c413b..1e1950b 100644 --- a/src/usr.bin/calendar/io.c +++ b/src/usr.bin/calendar/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.37 2015/01/16 06:40:06 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.39 2015/04/18 18:28:37 deraadt Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -44,7 +44,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <tzfile.h> #include <unistd.h> #include <limits.h> @@ -282,12 +281,16 @@ getfield(char *p, char **endp, int *flags) } } if (i > NUMEV) { - switch(*start) { + const char *errstr; + + switch (*start) { case '-': case '+': - var = atoi(start); - if (var > 365 || var < -365) + var = strtonum(start + 1, 0, 365, &errstr); + if (errstr) return (0); /* Someone is just being silly */ + if (*start == '-') + var = -var; val += (NUMEV + 1) * var; /* We add one to the matching event and multiply by * (NUMEV + 1) so as not to return 0 if there's a match. diff --git a/src/usr.bin/calendar/ostern.c b/src/usr.bin/calendar/ostern.c index c86c577..85d4d47 100644 --- a/src/usr.bin/calendar/ostern.c +++ b/src/usr.bin/calendar/ostern.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ostern.c,v 1.7 2009/10/27 23:59:36 deraadt Exp $ */ +/* $OpenBSD: ostern.c,v 1.8 2015/03/15 00:41:28 millert Exp $ */ /* * Copyright (c) 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. @@ -25,12 +25,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ostern.c,v 1.7 2009/10/27 23:59:36 deraadt Exp $ + * $Id: ostern.c,v 1.8 2015/03/15 00:41:28 millert Exp $ */ #include <stdio.h> #include <time.h> -#include <tzfile.h> #include "calendar.h" diff --git a/src/usr.bin/calendar/paskha.c b/src/usr.bin/calendar/paskha.c index fb958cd..4d817eb 100644 --- a/src/usr.bin/calendar/paskha.c +++ b/src/usr.bin/calendar/paskha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paskha.c,v 1.6 2009/10/27 23:59:36 deraadt Exp $ */ +/* $OpenBSD: paskha.c,v 1.7 2015/03/15 00:41:28 millert Exp $ */ /* * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. @@ -27,7 +27,6 @@ */ #include <stdio.h> -#include <tzfile.h> #include "calendar.h" diff --git a/src/usr.bin/calendar/pesach.c b/src/usr.bin/calendar/pesach.c index 70bbff2..c44d336 100644 --- a/src/usr.bin/calendar/pesach.c +++ b/src/usr.bin/calendar/pesach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pesach.c,v 1.3 2009/10/27 23:59:36 deraadt Exp $ */ +/* $OpenBSD: pesach.c,v 1.4 2015/03/15 00:41:28 millert Exp $ */ /* * Copyright (c) 2004 Michael Shalayeff @@ -18,7 +18,6 @@ */ #include <stdio.h> -#include <tzfile.h> #include "calendar.h" |