From 161ed15f7241f671731fa7a84c1458d40e9e2bd1 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Jun 13 2014 13:20:32 +0000 Subject: Rebase to the version of 'calendar' from OpenBSD 5.5 --- diff --git a/.gitignore b/.gitignore index eda4caf..68ec361 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ calendar-1.26-20110531cvs.tar.gz +/calendar-1.28-20140613cvs.tar.gz diff --git a/calendar-1.26-coding.patch b/calendar-1.26-coding.patch deleted file mode 100644 index c7e94fe..0000000 --- a/calendar-1.26-coding.patch +++ /dev/null @@ -1,176 +0,0 @@ -diff -up calendar-1.26-20110115cvs/calendar.h.coding calendar-1.26-20110115cvs/calendar.h ---- calendar-1.26-20110115cvs/calendar.h.coding 2011-01-15 17:27:14.000000000 -1000 -+++ calendar-1.26-20110115cvs/calendar.h 2011-01-15 17:27:52.000000000 -1000 -@@ -31,6 +31,8 @@ - - #include - -+#include -+ - extern struct passwd *pw; - extern int doall; - extern int bodun_always; -@@ -69,6 +71,7 @@ struct specialev { - int (*getev)(int); - }; - -+void convprint(FILE *, iconv_t, char *); - void cal(void); - void closecal(FILE *); - int getday(char *); -diff -up calendar-1.26-20110115cvs/io.c.coding calendar-1.26-20110115cvs/io.c ---- calendar-1.26-20110115cvs/io.c.coding 2011-01-15 17:27:14.000000000 -1000 -+++ calendar-1.26-20110115cvs/io.c 2011-01-15 17:27:52.000000000 -1000 -@@ -47,10 +47,17 @@ - #include - #include - -+#include -+#include -+ - #include "pathnames.h" - #include "calendar.h" - - -+#define ICONV_TRANSLIT "/" "/" "TRANSLIT" -+#define ICONV_FROMCODE "UTF-8" -+#define ICONV_BUFSIZ (128) -+ - struct iovec header[] = { - { "From: ", 6 }, - { NULL, 0 }, -@@ -62,6 +69,39 @@ struct iovec header[] = { - { "Auto-Submitted: auto-generated\n\n", 32 }, - }; - -+void -+convprint(FILE *fp, iconv_t ic, char *inputbuf) -+{ -+ char *iconv_input; -+ char *iconv_output; -+ char outputbuf[ICONV_BUFSIZ]; -+ size_t inputsz; -+ size_t outputsz; -+ size_t iconv_result; -+ -+ iconv_input = inputbuf; -+ inputsz = strlen(inputbuf); -+ -+ while (inputsz > 0) -+ { -+ iconv_output = outputbuf; -+ outputsz = sizeof(outputbuf) - 1; -+ -+ iconv_result = iconv( -+ ic, -+ &iconv_input, -+ &inputsz, -+ &iconv_output, -+ &outputsz -+ ); -+ if ((((size_t) -1) == iconv_result) && (E2BIG != errno)) -+ { -+ return; -+ } -+ outputbuf[sizeof(outputbuf) - outputsz - 1] = '\0'; -+ (void)fprintf(fp, "%s", outputbuf); -+ } -+} - - void - cal(void) -@@ -72,6 +112,42 @@ cal(void) - struct match *m; - FILE *fp; - -+ char *langinfo_coding; -+ char *iconv_coding; -+ iconv_t ic; -+ int use_iconv; -+ -+ use_iconv = 1; -+ iconv_coding = NULL; -+ ic = (iconv_t) -1; -+ (void)setlocale(LC_ALL, ""); -+ langinfo_coding = nl_langinfo(CODESET); -+ if ((NULL == langinfo_coding) || ('\0' == *langinfo_coding)) -+ { -+ use_iconv = 0; -+ } -+ else -+ { -+ iconv_coding = malloc( -+ strlen(langinfo_coding) + sizeof(ICONV_TRANSLIT) -+ ); -+ } -+ -+ if (NULL == iconv_coding) -+ { -+ use_iconv = 0; -+ } -+ else -+ { -+ sprintf(iconv_coding, "%s%s", langinfo_coding, ICONV_TRANSLIT); -+ ic = iconv_open(iconv_coding, ICONV_FROMCODE); -+ } -+ -+ if (((iconv_t) -1) == ic) -+ { -+ use_iconv = 0; -+ } -+ - events = NULL; - cur_evt = NULL; - if ((fp = opencal()) == NULL) -@@ -87,6 +163,14 @@ cal(void) - if (buf[0] == '\0') - continue; - if (strncmp(buf, "LANG=", 5) == 0) { -+ if (use_iconv) -+ { -+ char *coding_start = strchr(buf, '.'); -+ if (NULL != coding_start) -+ { -+ strcpy(coding_start, ".UTF-8"); -+ } -+ } - (void) setlocale(LC_ALL, buf + 5); - setnnames(); - if (!strcmp(buf + 5, "ru_RU.KOI8-R") || -@@ -201,8 +285,17 @@ cal(void) - } - tmp = events; - while (tmp) { -+ if (use_iconv) -+ { -+ convprint(fp, ic, tmp->print_date); -+ convprint(fp, ic, *(tmp->desc)); -+ (void)fputc((int) '\n', fp); -+ } -+ else -+ { - (void)fprintf(fp, "%s%s\n", tmp->print_date, *(tmp->desc)); -- tmp = tmp->next; -+ } -+ tmp = tmp->next; - } - tmp = events; - while (tmp) { -@@ -212,6 +305,17 @@ cal(void) - tmp = tmp->next; - free(events); - } -+ -+ if (NULL != iconv_coding) -+ { -+ free(iconv_coding); -+ } -+ -+ if (((iconv_t) -1) != ic) -+ { -+ iconv_close(ic); -+ } -+ - closecal(fp); - } - diff --git a/calendar-1.26-linux.patch b/calendar-1.26-linux.patch deleted file mode 100644 index 01f8b64..0000000 --- a/calendar-1.26-linux.patch +++ /dev/null @@ -1,186 +0,0 @@ -diff -up calendar-1.26-20110115cvs/calendar.c.linux calendar-1.26-20110115cvs/calendar.c ---- calendar-1.26-20110115cvs/calendar.c.linux 2009-10-27 13:59:36.000000000 -1000 -+++ calendar-1.26-20110115cvs/calendar.c 2011-01-15 17:27:14.000000000 -1000 -@@ -35,14 +35,12 @@ - #include - #include - #include --#include - #include - #include - #include - #include - #include - #include --#include - #include - - #include "pathnames.h" -@@ -170,10 +168,6 @@ main(int argc, char *argv[]) - continue; - case 0: /* child */ - (void)setlocale(LC_ALL, ""); -- if (setusercontext(NULL, pw, pw->pw_uid, -- LOGIN_SETALL ^ LOGIN_SETLOGIN)) -- err(1, "unable to set user context (uid %u)", -- pw->pw_uid); - if (acstat) { - if (chdir(pw->pw_dir) || - stat(calendarFile, &sbuf) != 0 || -diff -up calendar-1.26-20110115cvs/calendar.h.linux calendar-1.26-20110115cvs/calendar.h ---- calendar-1.26-20110115cvs/calendar.h.linux 2010-04-28 08:20:15.000000000 -1000 -+++ calendar-1.26-20110115cvs/calendar.h 2011-01-15 17:27:14.000000000 -1000 -@@ -29,6 +29,7 @@ - * SUCH DAMAGE. - */ - -+#include - - extern struct passwd *pw; - extern int doall; -@@ -110,7 +111,7 @@ extern int f_SetdayAfter; /* calendar in - - /* calendars */ - extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar; --extern u_long julian; -+extern unsigned long julian; - - #define NUMEV 3 /* Total number of such special events */ - extern struct specialev spev[NUMEV]; -@@ -120,3 +121,5 @@ extern struct specialev spev[NUMEV]; - * (e.g. by using named pipes) - */ - #define USERTIMEOUT 20 -+ -+#define SECSPERDAY 86400 -diff -up calendar-1.26-20110115cvs/day.c.linux calendar-1.26-20110115cvs/day.c ---- calendar-1.26-20110115cvs/day.c.linux 2010-04-28 08:20:15.000000000 -1000 -+++ calendar-1.26-20110115cvs/day.c 2011-01-15 17:27:14.000000000 -1000 -@@ -39,7 +39,6 @@ - #include - #include - #include --#include - - #include "pathnames.h" - #include "calendar.h" -@@ -158,7 +157,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 + TM_YEAR_BASE)) - cumdays = daytab[1]; - else - cumdays = daytab[0]; -@@ -288,8 +287,10 @@ isnow(char *endp, int bodun) - return (NULL); - - /* adjust bodun rate */ -- if (bodun && !bodun_always) -- bodun = !arc4random_uniform(3); -+ if (bodun && !bodun_always) { -+ srandom(3); -+ bodun = random(); -+ } - - /* Easter or Easter depending days */ - if (flags & F_SPECIAL) -@@ -440,7 +441,7 @@ isnow(char *endp, int bodun) - } - 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 + TM_YEAR_BASE) ? 366 : 365) - <= v1) - tmtmp.tm_year++; - else if(!bodun || (day - tp->tm_yday) != -1) -@@ -676,7 +677,7 @@ variable_weekday(int *day, int month, in - int *cumdays; - int day1; - -- if (isleap(year)) -+ if (__isleap(year)) - cumdays = daytab[1]; - else - cumdays = daytab[0]; -diff -up calendar-1.26-20110115cvs/io.c.linux calendar-1.26-20110115cvs/io.c ---- calendar-1.26-20110115cvs/io.c.linux 2009-10-27 13:59:36.000000000 -1000 -+++ calendar-1.26-20110115cvs/io.c 2011-01-15 17:27:14.000000000 -1000 -@@ -45,7 +45,6 @@ - #include - #include - #include --#include - #include - - #include "pathnames.h" -@@ -68,7 +67,7 @@ void - cal(void) - { - int ch, l, i, bodun = 0, bodun_maybe = 0, var, printing; -- struct event *events, *cur_evt, *ev1, *tmp; -+ struct event *events = NULL, *cur_evt = NULL, *ev1 = NULL, *tmp = NULL; - char buf[2048 + 1], *prefix = NULL, *p; - struct match *m; - FILE *fp; -diff -up calendar-1.26-20110115cvs/ostern.c.linux calendar-1.26-20110115cvs/ostern.c ---- calendar-1.26-20110115cvs/ostern.c.linux 2009-10-27 13:59:36.000000000 -1000 -+++ calendar-1.26-20110115cvs/ostern.c 2011-01-15 17:27:14.000000000 -1000 -@@ -30,7 +30,6 @@ - - #include - #include --#include - - #include "calendar.h" - -@@ -61,7 +60,7 @@ easter(int year) /* 0 ... abcd, NOT sinc - e_p = e_p + 1; - - e_q = 31 + 28 + e_p; -- if (isleap(year)) -+ if (__isleap(year)) - e_q++; - - if (e_n == 4) -diff -up calendar-1.26-20110115cvs/paskha.c.linux calendar-1.26-20110115cvs/paskha.c ---- calendar-1.26-20110115cvs/paskha.c.linux 2009-10-27 13:59:36.000000000 -1000 -+++ calendar-1.26-20110115cvs/paskha.c 2011-01-15 17:27:14.000000000 -1000 -@@ -27,7 +27,7 @@ - */ - - #include --#include -+#include - - #include "calendar.h" - -@@ -48,7 +48,7 @@ paskha(int R) /*year*/ - d = (19*a + x) % 30; - e = (2*b + 4*c + 6*d + y) % 7; - cumdays = 31 + 28; -- if (isleap(R)) -+ if (__isleap(R)) - cumdays++; - return ((cumdays + 22) + (d + e) + 13); - } -diff -up calendar-1.26-20110115cvs/pesach.c.linux calendar-1.26-20110115cvs/pesach.c ---- calendar-1.26-20110115cvs/pesach.c.linux 2009-10-27 13:59:36.000000000 -1000 -+++ calendar-1.26-20110115cvs/pesach.c 2011-01-15 17:27:14.000000000 -1000 -@@ -18,7 +18,7 @@ - */ - - #include --#include -+#include - - #include "calendar.h" - -@@ -62,5 +62,5 @@ pesach(int R) - if (R > 1582) - cumdays += R / 100 - R /400 - 2; - -- return (31 + 28 + cumdays + (isleap(R)? 1 : 0)); -+ return (31 + 28 + cumdays + (__isleap(R)? 1 : 0)); - } diff --git a/calendar-1.28-linux.patch b/calendar-1.28-linux.patch new file mode 100644 index 0000000..7d681c5 --- /dev/null +++ b/calendar-1.28-linux.patch @@ -0,0 +1,176 @@ +diff -up calendar-1.28-20140613cvs/calendar.c.linux calendar-1.28-20140613cvs/calendar.c +--- calendar-1.28-20140613cvs/calendar.c.linux 2012-01-31 03:29:25.000000000 -0500 ++++ calendar-1.28-20140613cvs/calendar.c 2014-06-13 09:10:21.083747232 -0400 +@@ -35,14 +35,12 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + #include +-#include + #include + + #include "pathnames.h" +@@ -171,10 +169,6 @@ main(int argc, char *argv[]) + case 0: /* child */ + (void)setpgid(getpid(), getpid()); + (void)setlocale(LC_ALL, ""); +- if (setusercontext(NULL, pw, pw->pw_uid, +- LOGIN_SETALL ^ LOGIN_SETLOGIN)) +- err(1, "unable to set user context (uid %u)", +- pw->pw_uid); + if (acstat) { + if (chdir(pw->pw_dir) || + stat(calendarFile, &sbuf) != 0 || +diff -up calendar-1.28-20140613cvs/calendar.h.linux calendar-1.28-20140613cvs/calendar.h +--- calendar-1.28-20140613cvs/calendar.h.linux 2010-04-28 14:20:15.000000000 -0400 ++++ calendar-1.28-20140613cvs/calendar.h 2014-06-13 09:11:26.447747232 -0400 +@@ -110,7 +110,7 @@ extern int f_SetdayAfter; /* calendar in + + /* calendars */ + extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar; +-extern u_long julian; ++extern unsigned long julian; + + #define NUMEV 3 /* Total number of such special events */ + extern struct specialev spev[NUMEV]; +@@ -120,3 +120,5 @@ extern struct specialev spev[NUMEV]; + * (e.g. by using named pipes) + */ + #define USERTIMEOUT 20 ++ ++#define SECSPERDAY 86400 +diff -up calendar-1.28-20140613cvs/day.c.linux calendar-1.28-20140613cvs/day.c +--- calendar-1.28-20140613cvs/day.c.linux 2013-11-26 08:18:53.000000000 -0500 ++++ calendar-1.28-20140613cvs/day.c 2014-06-13 09:12:57.023747232 -0400 +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + + #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 + TM_YEAR_BASE)) + cumdays = daytab[1]; + else + cumdays = daytab[0]; +@@ -288,8 +287,10 @@ isnow(char *endp, int bodun) + return (NULL); + + /* adjust bodun rate */ +- if (bodun && !bodun_always) +- bodun = !arc4random_uniform(3); ++ if (bodun && !bodun_always) { ++ srandom(3); ++ bodun = random(); ++ } + + /* Easter or Easter depending days */ + if (flags & F_SPECIAL) +@@ -440,7 +441,7 @@ isnow(char *endp, int bodun) + } + 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 + TM_YEAR_BASE) ? 366 : 365) + <= v1) + tmtmp.tm_year++; + else if(!bodun || (day - tp->tm_yday) != -1) +@@ -676,7 +677,7 @@ variable_weekday(int *day, int month, in + int *cumdays; + int day1; + +- if (isleap(year)) ++ if (__isleap(year)) + cumdays = daytab[1]; + else + cumdays = daytab[0]; +diff -up calendar-1.28-20140613cvs/io.c.linux calendar-1.28-20140613cvs/io.c +--- calendar-1.28-20140613cvs/io.c.linux 2013-11-26 08:18:53.000000000 -0500 ++++ calendar-1.28-20140613cvs/io.c 2014-06-13 09:13:48.874747232 -0400 +@@ -45,7 +45,6 @@ + #include + #include + #include +-#include + #include + + #include "pathnames.h" +@@ -68,7 +67,7 @@ void + cal(void) + { + int ch, l, i, bodun = 0, bodun_maybe = 0, var, printing; +- struct event *events, *cur_evt, *ev1, *tmp; ++ struct event *events = NULL, *cur_evt = NULL, *ev1 = NULL, *tmp = NULL; + char buf[2048 + 1], *prefix = NULL, *p; + struct match *m; + FILE *fp; +diff -up calendar-1.28-20140613cvs/ostern.c.linux calendar-1.28-20140613cvs/ostern.c +--- calendar-1.28-20140613cvs/ostern.c.linux 2009-10-27 19:59:36.000000000 -0400 ++++ calendar-1.28-20140613cvs/ostern.c 2014-06-13 09:14:04.746747232 -0400 +@@ -30,7 +30,6 @@ + + #include + #include +-#include + + #include "calendar.h" + +@@ -61,7 +60,7 @@ easter(int year) /* 0 ... abcd, NOT sinc + e_p = e_p + 1; + + e_q = 31 + 28 + e_p; +- if (isleap(year)) ++ if (__isleap(year)) + e_q++; + + if (e_n == 4) +diff -up calendar-1.28-20140613cvs/paskha.c.linux calendar-1.28-20140613cvs/paskha.c +--- calendar-1.28-20140613cvs/paskha.c.linux 2009-10-27 19:59:36.000000000 -0400 ++++ calendar-1.28-20140613cvs/paskha.c 2014-06-13 09:14:28.434747232 -0400 +@@ -27,7 +27,6 @@ + */ + + #include +-#include + + #include "calendar.h" + +@@ -48,7 +47,7 @@ paskha(int R) /*year*/ + d = (19*a + x) % 30; + e = (2*b + 4*c + 6*d + y) % 7; + cumdays = 31 + 28; +- if (isleap(R)) ++ if (__isleap(R)) + cumdays++; + return ((cumdays + 22) + (d + e) + 13); + } +diff -up calendar-1.28-20140613cvs/pesach.c.linux calendar-1.28-20140613cvs/pesach.c +--- calendar-1.28-20140613cvs/pesach.c.linux 2009-10-27 19:59:36.000000000 -0400 ++++ calendar-1.28-20140613cvs/pesach.c 2014-06-13 09:14:50.290747232 -0400 +@@ -18,7 +18,6 @@ + */ + + #include +-#include + + #include "calendar.h" + +@@ -62,5 +61,5 @@ pesach(int R) + if (R > 1582) + cumdays += R / 100 - R /400 - 2; + +- return (31 + 28 + cumdays + (isleap(R)? 1 : 0)); ++ return (31 + 28 + cumdays + (__isleap(R)? 1 : 0)); + } diff --git a/calendar.spec b/calendar.spec index 965deab..d431917 100644 --- a/calendar.spec +++ b/calendar.spec @@ -1,9 +1,9 @@ -%define alphatag 20110531cvs +%define alphatag 20140613cvs Summary: Reminder utility Name: calendar -Version: 1.26 -Release: 8.%{alphatag}%{?dist} +Version: 1.28 +Release: 1.%{alphatag}%{?dist} License: BSD Group: Applications/Productivity URL: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/calendar @@ -17,8 +17,7 @@ Source0: %{name}-%{version}-%{alphatag}.tar.gz Source1: Makefile.linux Source2: export-calendar-source.sh -Patch0: %{name}-1.26-linux.patch -Patch1: %{name}-1.26-coding.patch +Patch0: %{name}-1.28-linux.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -u -n) @@ -34,7 +33,6 @@ week. %prep %setup -q -n %{name}-%{version}-%{alphatag} %patch0 -p1 -%patch1 -p1 cp %{SOURCE1} Makefile for c in calendars/*.*/* ; do @@ -62,6 +60,9 @@ rm -rf %{buildroot} %{_datadir}/calendar %changelog +* Fri Jun 13 2014 David Cantrell - 1.28-1.20140613cvs +- Rebase to the version of 'calendar' from OpenBSD 5.5 + * Sat Jun 07 2014 Fedora Release Engineering - 1.26-8.20110531cvs - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild @@ -77,7 +78,7 @@ rm -rf %{buildroot} * Thu Jan 12 2012 Fedora Release Engineering - 1.26-4.20110531cvs - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild -* Fri Jun 02 2011 David Cantrell - 1.26-3.20110531cvs +* Thu Jun 02 2011 David Cantrell - 1.26-3.20110531cvs - Must increment release number regardless of cvstag * Tue May 31 2011 David Cantrell - 1.26-1.20110531cvs diff --git a/export-calendar-source.sh b/export-calendar-source.sh index 7552116..7e547e9 100644 --- a/export-calendar-source.sh +++ b/export-calendar-source.sh @@ -1,7 +1,7 @@ #!/bin/sh #TAG=HEAD -TAG=OPENBSD_4_9 +TAG=OPENBSD_5_5 CWD=$(pwd) CVS_RSH=ssh ; export CVS_RSH diff --git a/sources b/sources index d9444b3..9f9c144 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -a1e54e4430c34bfecc7a86bec5786e48 calendar-1.26-20110531cvs.tar.gz +016045f29b283c4267e525de6d5cc1fd calendar-1.28-20140613cvs.tar.gz