From owner-svn-ports-all@freebsd.org Sat Nov 7 11:41:25 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7E6A2ED01E; Sat, 7 Nov 2020 11:41:25 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CSwM94n6dz4jRN; Sat, 7 Nov 2020 11:41:25 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C4446122; Sat, 7 Nov 2020 11:41:25 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0A7BfPVd098557; Sat, 7 Nov 2020 11:41:25 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0A7BfOVj098553; Sat, 7 Nov 2020 11:41:24 GMT (envelope-from se@FreeBSD.org) Message-Id: <202011071141.0A7BfOVj098553@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: =?UTF-8?Q?Stefan_E=c3=9fer?= Date: Sat, 7 Nov 2020 11:41:24 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r554387 - in head/deskutils/calendar: . files X-SVN-Group: ports-head X-SVN-Commit-Author: se X-SVN-Commit-Paths: in head/deskutils/calendar: . files X-SVN-Commit-Revision: 554387 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Nov 2020 11:41:25 -0000 Author: se Date: Sat Nov 7 11:41:24 2020 New Revision: 554387 URL: https://svnweb.freebsd.org/changeset/ports/554387 Log: 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. Deleted: head/deskutils/calendar/files/patch-calendar.1 head/deskutils/calendar/files/patch-calendar.c head/deskutils/calendar/files/patch-calendar.h head/deskutils/calendar/files/patch-dates.c head/deskutils/calendar/files/patch-events.c head/deskutils/calendar/files/patch-parsedata.c head/deskutils/calendar/files/patch-pathnames.h head/deskutils/calendar/files/patch-tests_Makefile head/deskutils/calendar/files/patch-tests_regress.s5.out Modified: head/deskutils/calendar/Makefile head/deskutils/calendar/distinfo head/deskutils/calendar/files/patch-Makefile head/deskutils/calendar/files/patch-io.c Modified: head/deskutils/calendar/Makefile ============================================================================== --- head/deskutils/calendar/Makefile Sat Nov 7 11:31:28 2020 (r554386) +++ head/deskutils/calendar/Makefile Sat Nov 7 11:41:24 2020 (r554387) @@ -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 Modified: head/deskutils/calendar/distinfo ============================================================================== --- head/deskutils/calendar/distinfo Sat Nov 7 11:31:28 2020 (r554386) +++ head/deskutils/calendar/distinfo Sat Nov 7 11:41:24 2020 (r554387) @@ -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 Modified: head/deskutils/calendar/files/patch-Makefile ============================================================================== --- head/deskutils/calendar/files/patch-Makefile Sat Nov 7 11:31:28 2020 (r554386) +++ head/deskutils/calendar/files/patch-Makefile Sat Nov 7 11:41:24 2020 (r554387) @@ -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 - @@ -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 +${PROG}: ${OBJS} + ${CC} ${OBJS} ${LDFLAGS} -o ${PROG} Modified: head/deskutils/calendar/files/patch-io.c ============================================================================== --- head/deskutils/calendar/files/patch-io.c Sat Nov 7 11:31:28 2020 (r554386) +++ head/deskutils/calendar/files/patch-io.c Sat Nov 7 11:41:24 2020 (r554387) @@ -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 - #include - #include --#include - #include - #include - #include -@@ -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; + if (home == NULL || *home == '\0') { + warnx("Cannot get home directory"); +@@ -145,10 +143,6 @@ cal_fopen(const char *file) } -- *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); -+ } - } - warnx("can't open calendar file \"%s\"", file); -@@ -133,96 +147,236 @@ cal_fopen(const char *file) +- if (!warned && stat(_PATH_INCLUDE_LOCAL, &sb) != 0) { +- warnx("calendar data files now provided by calendar-data pkg."); +- warned = true; +- } + 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'; - -+ 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); - } -@@ -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)