aboutsummaryrefslogtreecommitdiff
path: root/deskutils/calendar
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-11-07 11:41:24 +0000
committerStefan Eßer <se@FreeBSD.org>2020-11-07 11:41:24 +0000
commit1a3491f23b6647effb6b448d9a2276b57923430e (patch)
tree854eb674095337ff1efa0b782dcbfefd5aab1474 /deskutils/calendar
parent10f826356eaf54268f9d5d3c023fd4b14c7e715c (diff)
downloadports-1a3491f23b6647effb6b448d9a2276b57923430e.tar.gz
ports-1a3491f23b6647effb6b448d9a2276b57923430e.zip
Fetch from my repository to simplify port
Instead of fetching from a repository that was created based on a version that did not include the pre-processor enhancements applied to -CURRENT and patching to include them, fetch from a repository that has a copy of the latest sources. This change allows to remove the large number of complex patch files from the port and will simplify further updates. It is planned to make the port fetch from an official FreeBSD repository as soon as it is available with up-to-date sources from -CURRENT. No port revision bump since this is only a change to the build process and not the generated package.
Notes
Notes: svn path=/head/; revision=554387
Diffstat (limited to 'deskutils/calendar')
-rw-r--r--deskutils/calendar/Makefile3
-rw-r--r--deskutils/calendar/distinfo6
-rw-r--r--deskutils/calendar/files/patch-Makefile107
-rw-r--r--deskutils/calendar/files/patch-calendar.1101
-rw-r--r--deskutils/calendar/files/patch-calendar.c10
-rw-r--r--deskutils/calendar/files/patch-calendar.h28
-rw-r--r--deskutils/calendar/files/patch-dates.c31
-rw-r--r--deskutils/calendar/files/patch-events.c75
-rw-r--r--deskutils/calendar/files/patch-io.c555
-rw-r--r--deskutils/calendar/files/patch-parsedata.c23
-rw-r--r--deskutils/calendar/files/patch-pathnames.h7
-rw-r--r--deskutils/calendar/files/patch-tests_Makefile21
-rw-r--r--deskutils/calendar/files/patch-tests_regress.s5.out7
13 files changed, 25 insertions, 949 deletions
diff --git a/deskutils/calendar/Makefile b/deskutils/calendar/Makefile
index 053e4249efe5..479da02704d9 100644
--- a/deskutils/calendar/Makefile
+++ b/deskutils/calendar/Makefile
@@ -12,8 +12,7 @@ LICENSE= BSD3CLAUSE
RUN_DEPENDS= ${LOCALBASE}/share/calendar/calendar.all:deskutils/calendar-data
USE_GITHUB= yes
-GH_ACCOUNT= bsdimp
-GH_TAGNAME= fcc5d31
+GH_ACCOUNT= stesser
CFLAGS+= -D_PATH_LOCALBASE='\"${LOCALBASE}\"'
LDFLAGS+= -lm -lutil
diff --git a/deskutils/calendar/distinfo b/deskutils/calendar/distinfo
index bc612ed201ff..ea6635085400 100644
--- a/deskutils/calendar/distinfo
+++ b/deskutils/calendar/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1604699934
-SHA256 (bsdimp-calendar-0.9-fcc5d31_GH0.tar.gz) = ad7d0b51c4b834241aebbf6c50d187e5720f6c46c02615b27841a923e082aebc
-SIZE (bsdimp-calendar-0.9-fcc5d31_GH0.tar.gz) = 132824
+TIMESTAMP = 1604748457
+SHA256 (stesser-calendar-0.9_GH0.tar.gz) = fc1c9befed9c103843c83fae3774e34873fa8b20dc1b9d6041dce8e1f7f4e7ac
+SIZE (stesser-calendar-0.9_GH0.tar.gz) = 45355
diff --git a/deskutils/calendar/files/patch-Makefile b/deskutils/calendar/files/patch-Makefile
index a92539de7665..66b26d0d3f73 100644
--- a/deskutils/calendar/files/patch-Makefile
+++ b/deskutils/calendar/files/patch-Makefile
@@ -1,8 +1,8 @@
---- Makefile.orig 2020-10-18 03:01:26 UTC
+--- Makefile.orig 2020-11-07 11:15:40 UTC
+++ Makefile
-@@ -1,117 +1,14 @@
+@@ -1,22 +1,14 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
- # $FreeBSD$
+ # $FreeBSD: head/usr.bin/calendar/Makefile 367051 2020-10-26 03:26:18Z imp $
-.include <src.opts.mk>
-
@@ -10,11 +10,6 @@
-SRCS= calendar.c locale.c events.c dates.c parsedata.c io.c day.c \
- ostern.c paskha.c pom.c sunpos.c
-LIBADD= m util
--INTER= de_AT.ISO_8859-15 de_DE.ISO8859-1 fr_FR.ISO8859-1 \
-- hr_HR.ISO8859-2 hu_HU.ISO8859-2 pt_BR.ISO8859-1 \
-- pt_BR.UTF-8 ru_RU.KOI8-R ru_RU.UTF-8 uk_UA.KOI8-U
--DE_LINKS= de_DE.ISO8859-15
--FR_LINKS= fr_FR.ISO8859-15
-.if ${MK_ICONV} == "yes"
-CFLAGS+= -DWITH_ICONV
@@ -23,104 +18,14 @@
+ ostern.o paskha.o pom.o sunpos.o
-FILESGROUPS+= CALS
--CALS= calendars/calendar.all \
-- calendars/calendar.australia \
-- calendars/calendar.birthday \
-- calendars/calendar.brazilian \
-- calendars/calendar.christian \
-- calendars/calendar.computer \
-- calendars/calendar.croatian \
-- calendars/calendar.dutch \
-- calendars/calendar.freebsd \
-- calendars/calendar.french \
-- calendars/calendar.german \
-- calendars/calendar.history \
-- calendars/calendar.holiday \
-- calendars/calendar.hungarian \
-- calendars/calendar.judaic \
-- calendars/calendar.lotr \
-- calendars/calendar.music \
-- calendars/calendar.newzealand \
-- calendars/calendar.russian \
-- calendars/calendar.southafrica \
-- calendars/calendar.ukrainian \
-- calendars/calendar.usholiday \
-- calendars/calendar.world
+-CALS= calendars/calendar.freebsd
-CALSDIR= ${SHAREDIR}/calendar
+LDFLAGS= -lm -lutil
--CAL_de_AT.ISO_8859-15= calendar.feiertag
-+all: ${PROG}
-
--CAL_de_DE.ISO8859-1= calendar.all \
-- calendar.feiertag \
-- calendar.geschichte \
-- calendar.kirche \
-- calendar.literatur \
-- calendar.musik \
-- calendar.wissenschaft
--
--CAL_fr_FR.ISO8859-1= calendar.all \
-- calendar.fetes \
-- calendar.french \
-- calendar.jferies \
-- calendar.proverbes
--
--CAL_hr_HR.ISO8859-2= calendar.all \
-- calendar.praznici
--
--CAL_hu_HU.ISO8859-2= calendar.all \
-- calendar.nevnapok \
-- calendar.unnepek
--
--CAL_pt_BR.ISO8859-1= calendar.all \
-- calendar.commemorative \
-- calendar.holidays \
-- calendar.mcommemorative
--
--CAL_pt_BR.UTF-8= calendar.all \
-- calendar.commemorative \
-- calendar.holidays \
-- calendar.mcommemorative
--
--CAL_ru_RU.KOI8-R= calendar.all \
-- calendar.common \
-- calendar.holiday \
-- calendar.military \
-- calendar.orthodox \
-- calendar.pagan
--
--CAL_ru_RU.UTF-8= calendar.all \
-- calendar.common \
-- calendar.holiday \
-- calendar.military \
-- calendar.orthodox \
-- calendar.pagan
--
--CAL_uk_UA.KOI8-U= calendar.all \
-- calendar.holiday \
-- calendar.misc \
-- calendar.orthodox
--
--.for lang in ${INTER}
--FILESGROUPS+= CALS_${lang}
--CALS_${lang}DIR= ${SHAREDIR}/calendar/${lang}
--.for file in ${CAL_${lang}}
--CALS_${lang}+= ${file:S@^@calendars/${lang}/@}
--.endfor
--.endfor
--
--
--.for link in ${DE_LINKS}
--SYMLINKS+= de_DE.ISO8859-1 ${SHAREDIR}/calendar/${link}
--.endfor
--.for link in ${FR_LINKS}
--SYMLINKS+= fr_FR.ISO8859-1 ${SHAREDIR}/calendar/${link}
--.endfor
--
-HAS_TESTS=
-SUBDIR.${MK_TESTS}+= tests
--
++all: ${PROG}
+
-.include <bsd.prog.mk>
+${PROG}: ${OBJS}
+ ${CC} ${OBJS} ${LDFLAGS} -o ${PROG}
diff --git a/deskutils/calendar/files/patch-calendar.1 b/deskutils/calendar/files/patch-calendar.1
deleted file mode 100644
index a104e3455374..000000000000
--- a/deskutils/calendar/files/patch-calendar.1
+++ /dev/null
@@ -1,101 +0,0 @@
---- calendar.1.orig 2020-10-18 03:01:26 UTC
-+++ calendar.1
-@@ -28,7 +28,7 @@
- .\" @(#)calendar.1 8.1 (Berkeley) 6/29/93
- .\" $FreeBSD$
- .\"
--.Dd September 29, 2020
-+.Dd November 5, 2020
- .Dt CALENDAR 1
- .Os
- .Sh NAME
-@@ -198,18 +198,35 @@ file is preprocessed by a limited subset of
- .Xr cpp 1
- internally, allowing the inclusion of shared files such as
- lists of company holidays or meetings.
--This limited subset consists of \fB#include #ifndef #endif\fR and \fB#define\fR.
-+This limited subset consists of \fB#include\fR, \fB#define\fR,
-+\fB#undef\fR, \fB#ifdef\fR, \fB#ifndef\fR, \fB#else\fR, \fB#warning\fR,
-+and \fB#error\fR.
-+.Pp
-+Conditions can be nested and the consistency of opening and closing
-+instructions is checked.
-+Only the first word after #define is used as the name of the
-+condition variable being defined.
-+More than word following #ifdef, #ifndef, or #undef is considered a syntax
-+error, since names cannot include white-space.
-+Included files are parsed in a global scope with regard to the condition
-+variables being defined or tested therein.
-+All conditional blocks are implicitly closed at the end of a file,
-+and missing #endif instructions are assumed to be present on implied
-+succeeding lines.
-+.Pp
- If the shared file is not referenced by a full pathname,
- .Nm
- searches in the current (or home) directory first, and then in the
- directory
- .Pa /usr/share/calendar .
--Empty lines and lines protected by the C commenting syntax
-+Empty lines and text protected by the C commenting syntax
- .Pq Li /* ... */
-+or
-+.Pq Li //
- are ignored.
- .Pp
- Some possible calendar entries (<tab> characters highlighted by
--\fB\et\fR sequence)
-+\fB\et\fR sequence):
- .Bd -unfilled -offset indent
- LANG=C
- Easter=Ostern
-@@ -245,11 +262,19 @@ A chdir is done into this directory if it exists.
- calendar file to use if no calendar file exists in the current directory.
- .It Pa ~/.calendar/nomail
- do not send mail if this file exists.
-+.It Pa /usr/share/calendar
-+system wide location of calendar files provided as part of the base system.
-+.It Pa /usr/local/share/calendar
-+system wide location for calendar files provided by a port or package.
- .El
- .Pp
--The following default calendar files are provided in
--.Pa /usr/share/calendar :
-+The order of precedence in searches for a calendar file is:
-+current directory, ~/.calendar, /usr/local/share/calendar, /usr/share/calendar.
-+Files of similar names are ignored in lower precedence locations.
- .Pp
-+The following default calendar files are provided by the
-+deskutils/calendar-data port.
-+.Pp
- .Bl -tag -width calendar.southafrica -compact
- .It Pa calendar.all
- File which includes all the default files.
-@@ -283,8 +308,8 @@ Other holidays, including the not-well-known, obscure,
- obscure.
- .It Pa calendar.judaic
- Jewish holidays.
--The entries for this calendar have been obtained from the port
--deskutils/hebcal.
-+The entries for this calendar have been obtained from the
-+deskutils/hebcal port.
- .It Pa calendar.music
- Musical events, births, and deaths.
- Strongly oriented toward rock 'n' roll.
-@@ -338,11 +363,12 @@ double-check the start and end time of solar and lunar
- .Sh BUGS
- The
- .Nm
--internal cpp does not correctly do #ifndef and will discard the rest
--of the file if a #ifndef is triggered.
--It also has a maximum of 50 include file and/or 100 #defines
--and only recognises #include, #define and
--#ifndef.
-+does only recognise the cpp directives #include, #define, #ifdef,
-+#ifndef and #else.
-+It supports nested conditions, but does not perform any validation
-+on the correct use and nesting of conditions.
-+#endif without prior #ifdef or #define is ignored and #else outside
-+a conditional section skips input lines up to the next #endif.
- .Pp
- There is no possibility to properly specify the local position
- needed for solar and lunar calculations.
diff --git a/deskutils/calendar/files/patch-calendar.c b/deskutils/calendar/files/patch-calendar.c
deleted file mode 100644
index 4ae3614b7de6..000000000000
--- a/deskutils/calendar/files/patch-calendar.c
+++ /dev/null
@@ -1,10 +0,0 @@
---- calendar.c.orig 2020-10-18 03:01:26 UTC
-+++ calendar.c
-@@ -228,6 +228,7 @@ main(int argc, char *argv[])
- if (setusercontext(lc, pw, pw->pw_uid,
- LOGIN_SETALL) != 0)
- errx(1, "setusercontext");
-+ setenv("HOME", pw->pw_dir, 1);
- cal();
- exit(0);
- }
diff --git a/deskutils/calendar/files/patch-calendar.h b/deskutils/calendar/files/patch-calendar.h
deleted file mode 100644
index fe9f3e52b4e8..000000000000
--- a/deskutils/calendar/files/patch-calendar.h
+++ /dev/null
@@ -1,28 +0,0 @@
---- calendar.h.orig 2020-10-18 03:01:26 UTC
-+++ calendar.h
-@@ -122,7 +122,7 @@ extern int year1, year2;
- * - Use event_continue() to add more text to the last added event
- * - Use event_print_all() to display them in time chronological order
- */
--struct event *event_add(int, int, int, char *, int, char *, char *);
-+struct event *event_add(int, int, int, int, char *, char *);
- void event_continue(struct event *events, char *txt);
- void event_print_all(FILE *fp);
- struct event {
-@@ -130,7 +130,6 @@ struct event {
- int month;
- int day;
- int var;
-- char *date;
- char *text;
- char *extra;
- struct event *next;
-@@ -189,7 +188,7 @@ int remember_yd(int y, int d, int *rm, int *rd);
- int first_dayofweek_of_year(int y);
- int first_dayofweek_of_month(int y, int m);
- int walkthrough_dates(struct event **e);
--void addtodate(struct event *e, int year, int month, int day);
-+void addtodate(struct event *e);
-
- /* pom.c */
- #define MAXMOONS 18
diff --git a/deskutils/calendar/files/patch-dates.c b/deskutils/calendar/files/patch-dates.c
deleted file mode 100644
index 0b4626b4b02b..000000000000
--- a/deskutils/calendar/files/patch-dates.c
+++ /dev/null
@@ -1,31 +0,0 @@
---- dates.c.orig 2020-10-18 03:01:26 UTC
-+++ dates.c
-@@ -64,6 +64,7 @@ struct cal_day {
- struct cal_month *month; /* points back */
- struct cal_year *year; /* points back */
- struct event *events;
-+ struct event *lastevent;
- };
-
- int debug_remember = 0;
-@@ -443,11 +444,16 @@ find_day(int yy, int mm, int dd)
- }
-
- void
--addtodate(struct event *e, int year, int month, int day)
-+addtodate(struct event *e)
- {
- struct cal_day *d;
-+ struct event *ee;
-
-- d = find_day(year, month, day);
-- e->next = d->events;
-- d->events = e;
-+ d = find_day(e->year, e->month, e->day);
-+ ee = d->lastevent;
-+ if (ee != NULL)
-+ ee->next = e;
-+ else
-+ d->events = e;
-+ d->lastevent = e;
- }
diff --git a/deskutils/calendar/files/patch-events.c b/deskutils/calendar/files/patch-events.c
deleted file mode 100644
index 28ed45aba976..000000000000
--- a/deskutils/calendar/files/patch-events.c
+++ /dev/null
@@ -1,75 +0,0 @@
---- events.c.orig 2020-10-18 03:01:26 UTC
-+++ events.c
-@@ -150,8 +150,7 @@ convert(char *input)
- }
-
- struct event *
--event_add(int year, int month, int day, char *date, int var, char *txt,
-- char *extra)
-+event_add(int year, int month, int day, int var, char *txt, char *extra)
- {
- struct event *e;
-
-@@ -159,25 +158,22 @@ event_add(int year, int month, int day, char *date, in
- * Creating a new event:
- * - Create a new event
- * - Copy the machine readable day and month
-- * - Copy the human readable and language specific date
- * - Copy the text of the event
- */
- e = (struct event *)calloc(1, sizeof(struct event));
- if (e == NULL)
- errx(1, "event_add: cannot allocate memory");
-+ e->year = year;
- e->month = month;
- e->day = day;
- e->var = var;
-- e->date = convert(date);
-- if (e->date == NULL)
-- errx(1, "event_add: cannot allocate memory");
- e->text = convert(txt);
- if (e->text == NULL)
- errx(1, "event_add: cannot allocate memory");
- e->extra = NULL;
- if (extra != NULL && extra[0] != '\0')
- e->extra = convert(extra);
-- addtodate(e, year, month, day);
-+ addtodate(e);
- return (e);
- }
-
-@@ -204,19 +200,31 @@ void
- event_print_all(FILE *fp)
- {
- struct event *e;
-+ struct tm tm;
-+ char dbuf[80];
-+ static int d_first;
-
-+ d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
-+
- while (walkthrough_dates(&e) != 0) {
-+ if (e) {
- #ifdef DEBUG
-- fprintf(stderr, "event_print_allmonth: %d, day: %d\n",
-- month, day);
-+ fprintf(stderr, "event_print_all month: %d, day: %d\n",
-+ e->month, e->day);
- #endif
-+ memset(&tm, 0, sizeof(struct tm));
-+ tm.tm_mday = e->day;
-+ tm.tm_mon = e->month - 1;
-+ tm.tm_year = e->year - 1900;
-+ (void)strftime(dbuf, sizeof(dbuf), d_first ? "%e %b" : "%b %e", &tm);
-+ }
-
- /*
- * Go through all events and print the text of the matching
- * dates
- */
- while (e != NULL) {
-- (void)fprintf(fp, "%s%c%s%s%s%s\n", e->date,
-+ (void)fprintf(fp, "%s%c%s%s%s%s\n", dbuf,
- e->var ? '*' : ' ', e->text,
- e->extra != NULL ? " (" : "",
- e->extra != NULL ? e->extra : "",
diff --git a/deskutils/calendar/files/patch-io.c b/deskutils/calendar/files/patch-io.c
index 713f9073c330..cece21c2bc5f 100644
--- a/deskutils/calendar/files/patch-io.c
+++ b/deskutils/calendar/files/patch-io.c
@@ -1,547 +1,22 @@
---- io.c.orig 2020-10-18 03:01:26 UTC
+--- io.c.orig 2020-11-07 11:15:40 UTC
+++ io.c
-@@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
- #include <ctype.h>
- #include <err.h>
- #include <errno.h>
--#include <langinfo.h>
- #include <locale.h>
- #include <pwd.h>
- #include <stdbool.h>
-@@ -71,10 +70,14 @@ enum {
- };
+@@ -119,8 +119,6 @@ cal_fopen(const char *file)
+ FILE *fp;
+ char *home = getenv("HOME");
+ unsigned int i;
+- struct stat sb;
+- static bool warned = false;
- const char *calendarFile = "calendar"; /* default calendar file */
--static const char *calendarHomes[] = {".calendar", _PATH_INCLUDE}; /* HOME */
-+static const char *calendarHomes[] = {".calendar", _PATH_INCLUDE_LOCAL, _PATH_INCLUDE}; /* HOME */
- static const char *calendarNoMail = "nomail";/* don't sent mail if file exist */
-
- static char path[MAXPATHLEN];
-+static const char *cal_home;
-+static const char *cal_dir;
-+static const char *cal_file;
-+static int cal_line;
-
- struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
- struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice;
-@@ -85,22 +88,29 @@ static StringList *definitions = NULL;
- static struct event *events[MAXCOUNT];
- static char *extradata[MAXCOUNT];
-
--static void
-+static char *
- trimlr(char **buf)
- {
- char *walk = *buf;
-+ char *sep;
- char *last;
-
- while (isspace(*walk))
- walk++;
-- if (*walk != '\0') {
-- last = walk + strlen(walk) - 1;
-+ *buf = walk;
-+
-+ sep = walk;
-+ while (*sep != '\0' && !isspace(*sep))
-+ sep++;
-+
-+ if (*sep != '\0') {
-+ last = sep + strlen(sep) - 1;
- while (last > walk && isspace(*last))
- last--;
- *(last+1) = 0;
- }
-
-- *buf = walk;
-+ return (sep);
- }
-
- static FILE *
-@@ -116,7 +126,7 @@ cal_fopen(const char *file)
- }
-
- if (chdir(home) != 0) {
-- warnx("Cannot enter home directory");
-+ warnx("Cannot enter home directory \"%s\"", home);
- return (NULL);
- }
-
-@@ -124,8 +134,12 @@ cal_fopen(const char *file)
- if (chdir(calendarHomes[i]) != 0)
- continue;
-
-- if ((fp = fopen(file, "r")) != NULL)
-+ if ((fp = fopen(file, "r")) != NULL) {
-+ cal_home = home;
-+ cal_dir = calendarHomes[i];
-+ cal_file = file;
- return (fp);
-+ }
+ if (home == NULL || *home == '\0') {
+ warnx("Cannot get home directory");
+@@ -145,10 +143,6 @@ cal_fopen(const char *file)
}
warnx("can't open calendar file \"%s\"", file);
-@@ -133,96 +147,236 @@ cal_fopen(const char *file)
- return (NULL);
- }
-
-+static char*
-+cal_path(void)
-+{
-+ static char buffer[MAXPATHLEN + 10];
-+
-+ if (cal_dir == NULL)
-+ snprintf(buffer, sizeof(buffer), "%s", cal_file);
-+ else if (cal_dir[0] == '/')
-+ snprintf(buffer, sizeof(buffer), "%s/%s", cal_dir, cal_file);
-+ else
-+ snprintf(buffer, sizeof(buffer), "%s/%s/%s", cal_home, cal_dir, cal_file);
-+ return (buffer);
-+}
-+
-+#define WARN0(format) \
-+ warnx(format " in %s line %d", cal_path(), cal_line)
-+#define WARN1(format, arg1) \
-+ warnx(format " in %s line %d", arg1, cal_path(), cal_line)
-+
-+static char*
-+cmptoken(char *line, const char* token)
-+{
-+ char len = strlen(token);
-+
-+ if (strncmp(line, token, len) != 0)
-+ return NULL;
-+ return (line + len);
-+}
-+
- static int
--token(char *line, FILE *out, bool *skip)
-+token(char *line, FILE *out, int *skip, int *unskip)
- {
-- char *walk, c, a;
-+ char *walk, *sep, a, c;
-+ const char *this_cal_home;
-+ const char *this_cal_dir;
-+ const char *this_cal_file;
-+ int this_cal_line;
-
-- if (strncmp(line, "endif", 5) == 0) {
-- *skip = false;
-+ while (isspace(*line))
-+ line++;
-+
-+ if (cmptoken(line, "endif")) {
-+ if (*skip + *unskip == 0) {
-+ WARN0("#endif without prior #ifdef or #ifndef");
-+ return (T_ERR);
-+ }
-+ if (*skip > 0)
-+ --*skip;
-+ else
-+ --*unskip;
-+
- return (T_OK);
- }
-
-- if (*skip)
-+ walk = cmptoken(line, "ifdef");
-+ if (walk != NULL) {
-+ sep = trimlr(&walk);
-+
-+ if (*walk == '\0') {
-+ WARN0("Expecting arguments after #ifdef");
-+ return (T_ERR);
-+ }
-+ if (*sep != '\0') {
-+ WARN1("Expecting a single word after #ifdef "
-+ "but got \"%s\"", walk);
-+ return (T_ERR);
-+ }
-+
-+ if (*skip != 0 ||
-+ definitions == NULL || sl_find(definitions, walk) == NULL)
-+ ++*skip;
-+ else
-+ ++*unskip;
-+
- return (T_OK);
-+ }
-
-- if (strncmp(line, "include", 7) == 0) {
-- walk = line + 7;
-+ walk = cmptoken(line, "ifndef");
-+ if (walk != NULL) {
-+ sep = trimlr(&walk);
-
-- trimlr(&walk);
-+ if (*walk == '\0') {
-+ WARN0("Expecting arguments after #ifndef");
-+ return (T_ERR);
-+ }
-+ if (*sep != '\0') {
-+ WARN1("Expecting a single word after #ifndef "
-+ "but got \"%s\"", walk);
-+ return (T_ERR);
-+ }
-
-+ if (*skip != 0 ||
-+ (definitions != NULL && sl_find(definitions, walk) != NULL))
-+ ++*skip;
-+ else
-+ ++*unskip;
-+
-+ return (T_OK);
-+ }
-+
-+ walk = cmptoken(line, "else");
-+ if (walk != NULL) {
-+ (void)trimlr(&walk);
-+
-+ if (*walk != '\0') {
-+ WARN0("Expecting no arguments after #else");
-+ return (T_ERR);
-+ }
-+ if (*skip + *unskip == 0) {
-+ WARN0("#else without prior #ifdef or #ifndef");
-+ return (T_ERR);
-+ }
-+
-+ if (*skip == 0) {
-+ ++*skip;
-+ --*unskip;
-+ } else if (*skip == 1) {
-+ --*skip;
-+ ++*unskip;
-+ }
-+
-+ return (T_OK);
-+ }
-+
-+ if (*skip != 0)
-+ return (T_OK);
-+
-+ walk = cmptoken(line, "include");
-+ if (walk != NULL) {
-+ (void)trimlr(&walk);
-+
- if (*walk == '\0') {
-- warnx("Expecting arguments after #include");
-+ WARN0("Expecting arguments after #include");
- return (T_ERR);
- }
-
- if (*walk != '<' && *walk != '\"') {
-- warnx("Excecting '<' or '\"' after #include");
-+ WARN0("Excecting '<' or '\"' after #include");
- return (T_ERR);
- }
-
-- a = *walk;
-+ a = *walk == '<' ? '>' : '\"';
- walk++;
- c = walk[strlen(walk) - 1];
-
-- switch(c) {
-- case '>':
-- if (a != '<') {
-- warnx("Unterminated include expecting '\"'");
-- return (T_ERR);
-- }
-- break;
-- case '\"':
-- if (a != '\"') {
-- warnx("Unterminated include expecting '>'");
-- return (T_ERR);
-- }
-- break;
-- default:
-- warnx("Unterminated include expecting '%c'",
-- a == '<' ? '>' : '\"' );
-+ if (a != c) {
-+ WARN1("Unterminated include expecting '%c'", a);
- return (T_ERR);
- }
- walk[strlen(walk) - 1] = '\0';
+- if (!warned && stat(_PATH_INCLUDE_LOCAL, &sb) != 0) {
+- warnx("calendar data files now provided by calendar-data pkg.");
+- warned = true;
+- }
-+ this_cal_home = cal_home;
-+ this_cal_dir = cal_dir;
-+ this_cal_file = cal_file;
-+ this_cal_line = cal_line;
- if (cal_parse(cal_fopen(walk), out))
- return (T_ERR);
-+ cal_home = this_cal_home;
-+ cal_dir = this_cal_dir;
-+ cal_file = this_cal_file;
-+ cal_line = this_cal_line;
-
- return (T_OK);
- }
-
-- if (strncmp(line, "define", 6) == 0) {
-+ walk = cmptoken(line, "define");
-+ if (walk != NULL) {
- if (definitions == NULL)
- definitions = sl_init();
-- walk = line + 6;
-- trimlr(&walk);
-+ sep = trimlr(&walk);
-+ *sep = '\0';
-
- if (*walk == '\0') {
-- warnx("Expecting arguments after #define");
-+ WARN0("Expecting arguments after #define");
- return (T_ERR);
- }
-
-- sl_add(definitions, strdup(walk));
-+ if (sl_find(definitions, walk) == NULL)
-+ sl_add(definitions, strdup(walk));
- return (T_OK);
- }
-
-- if (strncmp(line, "ifndef", 6) == 0) {
-- walk = line + 6;
-- trimlr(&walk);
-+ walk = cmptoken(line, "undef");
-+ if (walk != NULL) {
-+ if (definitions != NULL) {
-+ sep = trimlr(&walk);
-
-- if (*walk == '\0') {
-- warnx("Expecting arguments after #ifndef");
-- return (T_ERR);
-+ if (*walk == '\0') {
-+ WARN0("Expecting arguments after #undef");
-+ return (T_ERR);
-+ }
-+ if (*sep != '\0') {
-+ WARN1("Expecting a single word after #undef "
-+ "but got \"%s\"", walk);
-+ return (T_ERR);
-+ }
-+
-+ walk = sl_find(definitions, walk);
-+ if (walk != NULL)
-+ walk[0] = '\0';
- }
-+ return (T_OK);
-+ }
-
-- if (definitions != NULL && sl_find(definitions, walk) != NULL)
-- *skip = true;
-+ walk = cmptoken(line, "warning");
-+ if (walk != NULL) {
-+ (void)trimlr(&walk);
-+ WARN1("Warning: %s", walk);
-+ }
-
-- return (T_OK);
-+ walk = cmptoken(line, "error");
-+ if (walk != NULL) {
-+ (void)trimlr(&walk);
-+ WARN1("Error: %s", walk);
-+ return (T_ERR);
- }
-
-- return (T_PROCESS);
-+ WARN1("Undefined pre-processor command \"#%s\"", line);
-+ return (T_ERR);
-+}
-
-+static void
-+setup_locale(const char *locale)
-+{
-+ (void)setlocale(LC_ALL, locale);
-+#ifdef WITH_ICONV
-+ if (!doall)
-+ set_new_encoding();
-+#endif
-+ setnnames();
- }
-
- #define REPLACE(string, slen, struct_) \
-@@ -237,35 +391,82 @@ token(char *line, FILE *out, bool *skip)
- static int
- cal_parse(FILE *in, FILE *out)
- {
-+ char *mylocale = NULL;
- char *line = NULL;
- char *buf;
- size_t linecap = 0;
- ssize_t linelen;
- ssize_t l;
-- static int d_first = -1;
- static int count = 0;
- int i;
- int month[MAXCOUNT];
- int day[MAXCOUNT];
- int year[MAXCOUNT];
-- bool skip = false;
-- char dbuf[80];
-+ int skip = 0;
-+ int unskip = 0;
- char *pp, p;
-- struct tm tm;
- int flags;
-+ char *c, *cc;
-+ bool incomment = false;
-
-- /* Unused */
-- tm.tm_sec = 0;
-- tm.tm_min = 0;
-- tm.tm_hour = 0;
-- tm.tm_wday = 0;
--
- if (in == NULL)
- return (1);
-
-+ cal_line = 0;
- while ((linelen = getline(&line, &linecap, in)) > 0) {
-- if (*line == '#') {
-- switch (token(line+1, out, &skip)) {
-+ cal_line++;
-+ buf = line;
-+ if (buf[linelen - 1] == '\n')
-+ buf[--linelen] = '\0';
-+
-+ if (incomment) {
-+ c = strstr(buf, "*/");
-+ if (c) {
-+ c += 2;
-+ linelen -= c - buf;
-+ buf = c;
-+ incomment = false;
-+ } else {
-+ continue;
-+ }
-+ }
-+ if (!incomment) {
-+ do {
-+ c = strstr(buf, "//");
-+ cc = strstr(buf, "/*");
-+ if (c != NULL && (cc == NULL || c - cc < 0)) {
-+ /* single line comment */
-+ *c = '\0';
-+ linelen = c - buf;
-+ break;
-+ } else if (cc != NULL) {
-+ c = strstr(cc + 2, "*/");
-+ if (c != NULL) {
-+ /* multi-line comment ending on same line */
-+ c += 2;
-+ memmove(cc, c, buf + linelen + 1 - c);
-+ linelen -= c - cc;
-+ } else {
-+ /* multi-line comment */
-+ *cc = '\0';
-+ linelen = cc - buf;
-+ incomment = true;
-+ break;
-+ }
-+ }
-+ } while (c != NULL || cc != NULL);
-+ }
-+
-+ for (l = linelen;
-+ l > 0 && isspace((unsigned char)buf[l - 1]);
-+ l--)
-+ ;
-+ buf[l] = '\0';
-+ if (buf[0] == '\0')
-+ continue;
-+
-+ if (buf == line && *buf == '#') {
-+ switch (token(buf+1, out, &skip, &unskip)) {
- case T_ERR:
- free(line);
- return (1);
-@@ -278,18 +479,9 @@ cal_parse(FILE *in, FILE *out)
- }
- }
-
-- if (skip)
-+ if (skip != 0)
- continue;
-
-- buf = line;
-- for (l = linelen;
-- l > 0 && isspace((unsigned char)buf[l - 1]);
-- l--)
-- ;
-- buf[l] = '\0';
-- if (buf[0] == '\0')
-- continue;
--
- /*
- * Setting LANG in user's calendar was an old workaround
- * for 'calendar -a' being run with C locale to properly
-@@ -298,13 +490,9 @@ cal_parse(FILE *in, FILE *out)
- * and does not run iconv(), this variable has little use.
- */
- if (strncmp(buf, "LANG=", 5) == 0) {
-- (void)setlocale(LC_ALL, buf + 5);
-- d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
--#ifdef WITH_ICONV
-- if (!doall)
-- set_new_encoding();
--#endif
-- setnnames();
-+ if (mylocale == NULL)
-+ mylocale = strdup(setlocale(LC_ALL, NULL));
-+ setup_locale(buf + 5);
- continue;
- }
- /* Parse special definitions: Easter, Paskha etc */
-@@ -353,7 +541,7 @@ cal_parse(FILE *in, FILE *out)
- if (count < 0) {
- /* Show error status based on return value */
- if (debug)
-- fprintf(stderr, "Ignored: %s\n", buf);
-+ WARN1("Ignored: \"%s\"", buf);
- if (count == -1)
- continue;
- count = -count + 1;
-@@ -363,25 +551,25 @@ cal_parse(FILE *in, FILE *out)
- while (pp[1] == '\t')
- pp++;
-
-- if (d_first < 0)
-- d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
--
- for (i = 0; i < count; i++) {
-- tm.tm_mon = month[i] - 1;
-- tm.tm_mday = day[i];
-- tm.tm_year = year[i] - 1900;
-- (void)strftime(dbuf, sizeof(dbuf),
-- d_first ? "%e %b" : "%b %e", &tm);
- if (debug)
-- fprintf(stderr, "got %s\n", pp);
-- events[i] = event_add(year[i], month[i], day[i], dbuf,
-+ WARN1("got \"%s\"", pp);
-+ events[i] = event_add(year[i], month[i], day[i],
- ((flags &= F_VARIABLE) != 0) ? 1 : 0, pp,
- extradata[i]);
- }
- }
-+ while (skip-- > 0 || unskip-- > 0) {
-+ cal_line++;
-+ WARN0("Missing #endif assumed");
-+ }
-
- free(line);
- fclose(in);
-+ if (mylocale != NULL) {
-+ setup_locale(mylocale);
-+ free(mylocale);
-+ }
-
- return (0);
+ return (NULL);
}
-@@ -419,6 +607,7 @@ opencalin(void)
- FILE *fpin;
-
- /* open up calendar file */
-+ cal_file = calendarFile;
- if ((fpin = fopen(calendarFile, "r")) == NULL) {
- if (doall) {
- if (chdir(calendarHomes[0]) != 0)
diff --git a/deskutils/calendar/files/patch-parsedata.c b/deskutils/calendar/files/patch-parsedata.c
deleted file mode 100644
index 0020a72473e7..000000000000
--- a/deskutils/calendar/files/patch-parsedata.c
+++ /dev/null
@@ -1,23 +0,0 @@
---- parsedata.c.orig 2020-10-18 03:01:26 UTC
-+++ parsedata.c
-@@ -28,7 +28,7 @@
- */
-
- #include <sys/cdefs.h>
--__FBSDID("$FreeBSD$");
-+__FBSDID("$FreeBSD: head/usr.bin/calendar/parsedata.c 367203 2020-10-31 13:32:08Z se $");
-
- #include <ctype.h>
- #include <math.h>
-@@ -312,10 +312,7 @@ allfine:
-
- }
-
--void
--remember(int *rememberindex, int *y, int *m, int *d, char **ed, int yy, int mm,
-- int dd, char *extra);
--void
-+static void
- remember(int *rememberindex, int *y, int *m, int *d, char **ed, int yy, int mm,
- int dd, char *extra)
- {
diff --git a/deskutils/calendar/files/patch-pathnames.h b/deskutils/calendar/files/patch-pathnames.h
deleted file mode 100644
index ee9eb685c152..000000000000
--- a/deskutils/calendar/files/patch-pathnames.h
+++ /dev/null
@@ -1,7 +0,0 @@
---- pathnames.h.orig 2020-10-18 03:01:26 UTC
-+++ pathnames.h
-@@ -35,3 +35,4 @@
- #include <paths.h>
-
- #define _PATH_INCLUDE "/usr/share/calendar"
-+#define _PATH_INCLUDE_LOCAL _PATH_LOCALBASE "/share/calendar"
diff --git a/deskutils/calendar/files/patch-tests_Makefile b/deskutils/calendar/files/patch-tests_Makefile
deleted file mode 100644
index 02f4b1aefc14..000000000000
--- a/deskutils/calendar/files/patch-tests_Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
---- tests/Makefile.orig 2020-10-18 03:01:26 UTC
-+++ tests/Makefile
-@@ -2,9 +2,17 @@
-
- PACKAGE= tests
-
--TAP_TESTS_SH= legacy_test
-+TAP_TESTS_SH= comment_test cond_test legacy_test
-
-+TEST_METADATA.comment_test+= timeout="600"
-+TEST_METADATA.cond_test+= timeout="600"
- TEST_METADATA.legacy_test+= timeout="600"
-+
-+${PACKAGE}FILES+= calendar.comment
-+${PACKAGE}FILES+= regress.comment.out
-+
-+${PACKAGE}FILES+= calendar.cond
-+${PACKAGE}FILES+= regress.cond.out
-
- ${PACKAGE}FILES+= calendar.calibrate
- ${PACKAGE}FILES+= regress.a1.out
diff --git a/deskutils/calendar/files/patch-tests_regress.s5.out b/deskutils/calendar/files/patch-tests_regress.s5.out
deleted file mode 100644
index 1c3c07b1f86f..000000000000
--- a/deskutils/calendar/files/patch-tests_regress.s5.out
+++ /dev/null
@@ -1,7 +0,0 @@
---- tests/regress.s5.out.orig 2020-10-18 03:01:26 UTC
-+++ tests/regress.s5.out
-@@ -1,3 +1,3 @@
--Jun 21* sunthird
- Jun 21 jun 21
-+Jun 21* sunthird
- Jun 22 jun 22