summaryrefslogtreecommitdiffstats
path: root/usr.bin/calendar
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-05-10 16:30:22 +0000
committerache <ache@FreeBSD.org>1996-05-10 16:30:22 +0000
commite18782182041e3c1e4a504c753d97480e206140b (patch)
tree2ee499be5fe987b5fb50fd8e4f1d0fba39c3a560 /usr.bin/calendar
parentee79fb34b7ffbfb608645cae031e188a0c427e27 (diff)
downloadFreeBSD-src-e18782182041e3c1e4a504c753d97480e206140b.zip
FreeBSD-src-e18782182041e3c1e4a504c753d97480e206140b.tar.gz
Localize it
Handle Orthodox Eastern -Wall cleanup
Diffstat (limited to 'usr.bin/calendar')
-rw-r--r--usr.bin/calendar/Makefile3
-rw-r--r--usr.bin/calendar/calendar.111
-rw-r--r--usr.bin/calendar/calendar.c13
-rw-r--r--usr.bin/calendar/calendar.h4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.feiertag4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.geschichte4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.kirche4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.literatur4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.musik4
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.wissenschaft4
-rw-r--r--usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici4
-rw-r--r--usr.bin/calendar/calendars/hr_HR.ISO_8859-2/calendar.praznici4
-rw-r--r--usr.bin/calendar/day.c88
-rw-r--r--usr.bin/calendar/io.c47
-rw-r--r--usr.bin/calendar/ostern.c3
-rw-r--r--usr.bin/calendar/paskha.c91
22 files changed, 275 insertions, 41 deletions
diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile
index 2b97e8e..5707971 100644
--- a/usr.bin/calendar/Makefile
+++ b/usr.bin/calendar/Makefile
@@ -1,7 +1,8 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= calendar
-SRCS= calendar.c io.c day.c ostern.c
+SRCS= calendar.c io.c day.c ostern.c paskha.c
+CFLAGS+= -Wall
INTER= de_DE.ISO_8859-1 hr_HR.ISO_8859-2
TEXTMODE?= 444
diff --git a/usr.bin/calendar/calendar.1 b/usr.bin/calendar/calendar.1
index 8efe79b..f3017bd 100644
--- a/usr.bin/calendar/calendar.1
+++ b/usr.bin/calendar/calendar.1
@@ -73,6 +73,10 @@ as default calendar file.
.El
.Pp
+To handle calendars in your national code table you can specify
+.Dq LANG=<locale_name>
+in the calendar file as early as possible.
+.Pp
Lines should begin with a month and day.
They may be entered in almost any format, either numeric or as character
strings.
@@ -83,7 +87,10 @@ Two numbers default to the month followed by the day.
Lines with leading tabs default to the last entered date, allowing
multiple line specifications for a single date.
``Easter'', may be followed by an positive or negative integer, is
-Easter for this year. Weekdays may be followed by ``-4'' ... ``+5'' (aliases
+Easter for this year.
+``Paskha'', may be followed by an positive or negative integer, is
+Orthodox Easter for this year.
+Weekdays may be followed by ``-4'' ... ``+5'' (aliases
last, first, second, third, fourth) for moving events like
``the last Monday in April''
@@ -105,6 +112,7 @@ are ignored.
.Pp
Some possible calendar entries:
.Bd -unfilled -offset indent
+LANG=C
#include <calendar.usholiday>
#include <calendar.birthday>
@@ -119,6 +127,7 @@ May Sun+2 ... second Sunday in May (Muttertag)
04/SunLast ... last Sunday in April, summer time in Europe
Easter ... Easter
Easter-2 ... Good Friday (2 days before Easter)
+Paskha ... Orthodox Easter
.Ed
.Sh FILES
diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c
index c338423..95ecebd 100644
--- a/usr.bin/calendar/calendar.c
+++ b/usr.bin/calendar/calendar.c
@@ -32,22 +32,23 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
+static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#endif /* not lint */
+#include <err.h>
+#include <errno.h>
+#include <locale.h>
#include <pwd.h>
#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <err.h>
#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
#include "pathnames.h"
#include "calendar.h"
@@ -67,6 +68,8 @@ main(argc, argv)
extern int optind;
int ch;
+ (void) setlocale(LC_ALL, "");
+
while ((ch = getopt(argc, argv, "?-af:t:A:B:")) != EOF)
switch (ch) {
case '-': /* backward contemptible */
diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h
index 4324c41..2fc4923 100644
--- a/usr.bin/calendar/calendar.h
+++ b/usr.bin/calendar/calendar.h
@@ -46,14 +46,16 @@ int getdayvar __P((char *));
int getfield __P((char *, char **, int *));
int getmonth __P((char *));
int geteaster __P((char *, int));
+int getpaskha __P((char *, int));
int easter __P((int));
int isnow __P((char *, int *, int *, int *));
FILE *opencal __P((void));
void settime __P((time_t));
time_t Mktime __P((char *));
void usage __P((void));
+void setnnames __P((void));
-#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
+#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
/* some flags */
#define F_ISMONTH 0x01 /* month (Januar ...) */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag
index ae3e5e0..e47d36a 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag
@@ -1,12 +1,14 @@
/*
* Feiertage
*
- * $Id: calendar.feiertag,v 1.1 1996/01/29 00:34:12 wosch Exp $
+ * $Id: calendar.feiertag,v 1.2 1996/02/02 06:05:13 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_feiertag_
#define _de_DE_ISO_8859_1_feiertag_
+LANG=de_DE.ISO_8859-1
+
/* arbeitsfreie staatliche Feiertage */
01/01 Neujahr
05/01 Maifeiertag
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte
index 3b984f9..5dc3096 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte
@@ -13,12 +13,14 @@
*
* ISBN 3-924521-59-X
*
- * $Id: calendar.geschichte,v 1.1 1996/01/29 00:34:13 wosch Exp $
+ * $Id: calendar.geschichte,v 1.2 1996/02/02 06:05:15 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_geschichte_
#define _de_DE_ISO_8859_1_geschichte_
+LANG=de_DE.ISO_8859-1
+
/* 1800-1933 */
07/11 Gründung der Rheinbundes, 1806
10/14 Doppelschlacht bei Jena und Auerstedt, 1806
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche
index c55b263..0fdd135 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche
@@ -1,12 +1,14 @@
/*
* Kirche in Deutschland
*
- * $Id: calendar.kirche,v 1.1 1996/01/29 00:34:15 wosch Exp $
+ * $Id: calendar.kirche,v 1.2 1996/02/02 06:05:16 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_kirche_
#define _de_DE_ISO_8859_1_kirche_
+LANG=de_DE.ISO_8859-1
+
Easter-46 Aschermittwoch
Easter-48 Rosenmontag
Easter-7 Palmsonntag
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur
index ea1c6ed..d35599c 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur
@@ -1,12 +1,14 @@
/*
* Literatur
*
- * $Id: calendar.literatur,v 1.1 1996/01/29 00:34:16 wosch Exp $
+ * $Id: calendar.literatur,v 1.2 1996/02/02 06:05:17 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_literatur_
#define _de_DE_ISO_8859_1_literatur_
+LANG=de_DE.ISO_8859-1
+
/* Schriftsteller
Fontane
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik
index 5aba169..bf0a7f3 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik
@@ -1,12 +1,14 @@
/*
* Musik
*
- * $Id: calendar.musik,v 1.1 1996/01/29 00:34:17 wosch Exp $
+ * $Id: calendar.musik,v 1.2 1996/02/02 06:05:18 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_musik_
#define _de_DE_ISO_8859_1_musik_
+LANG=de_DE.ISO_8859-1
+
/* Klassik */
02/23 Händel geboren, 1685
03/21 J.S. Bach geboren, 1685
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft
index 915149a..d859571 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft
+++ b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft
@@ -1,12 +1,14 @@
/*
* Wissenschaft
*
- * $Id: calendar.wissenschaft,v 1.1 1996/01/29 00:34:18 wosch Exp $
+ * $Id: calendar.wissenschaft,v 1.2 1996/02/02 06:05:20 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_wissenschaft_
#define _de_DE_ISO_8859_1_wissenschaft_
+LANG=de_DE.ISO_8859-1
+
04/12 erster Mann im All, Juri Gagarin, 1961
04/18 Einstein gestorben, 1955
06/22 Konrad Zuse geboren, 1919, Berlin
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.feiertag b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.feiertag
index ae3e5e0..e47d36a 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.feiertag
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.feiertag
@@ -1,12 +1,14 @@
/*
* Feiertage
*
- * $Id: calendar.feiertag,v 1.1 1996/01/29 00:34:12 wosch Exp $
+ * $Id: calendar.feiertag,v 1.2 1996/02/02 06:05:13 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_feiertag_
#define _de_DE_ISO_8859_1_feiertag_
+LANG=de_DE.ISO_8859-1
+
/* arbeitsfreie staatliche Feiertage */
01/01 Neujahr
05/01 Maifeiertag
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.geschichte b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.geschichte
index 3b984f9..5dc3096 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.geschichte
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.geschichte
@@ -13,12 +13,14 @@
*
* ISBN 3-924521-59-X
*
- * $Id: calendar.geschichte,v 1.1 1996/01/29 00:34:13 wosch Exp $
+ * $Id: calendar.geschichte,v 1.2 1996/02/02 06:05:15 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_geschichte_
#define _de_DE_ISO_8859_1_geschichte_
+LANG=de_DE.ISO_8859-1
+
/* 1800-1933 */
07/11 Gründung der Rheinbundes, 1806
10/14 Doppelschlacht bei Jena und Auerstedt, 1806
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.kirche b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.kirche
index c55b263..0fdd135 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.kirche
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.kirche
@@ -1,12 +1,14 @@
/*
* Kirche in Deutschland
*
- * $Id: calendar.kirche,v 1.1 1996/01/29 00:34:15 wosch Exp $
+ * $Id: calendar.kirche,v 1.2 1996/02/02 06:05:16 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_kirche_
#define _de_DE_ISO_8859_1_kirche_
+LANG=de_DE.ISO_8859-1
+
Easter-46 Aschermittwoch
Easter-48 Rosenmontag
Easter-7 Palmsonntag
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.literatur b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.literatur
index ea1c6ed..d35599c 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.literatur
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.literatur
@@ -1,12 +1,14 @@
/*
* Literatur
*
- * $Id: calendar.literatur,v 1.1 1996/01/29 00:34:16 wosch Exp $
+ * $Id: calendar.literatur,v 1.2 1996/02/02 06:05:17 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_literatur_
#define _de_DE_ISO_8859_1_literatur_
+LANG=de_DE.ISO_8859-1
+
/* Schriftsteller
Fontane
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.musik b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.musik
index 5aba169..bf0a7f3 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.musik
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.musik
@@ -1,12 +1,14 @@
/*
* Musik
*
- * $Id: calendar.musik,v 1.1 1996/01/29 00:34:17 wosch Exp $
+ * $Id: calendar.musik,v 1.2 1996/02/02 06:05:18 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_musik_
#define _de_DE_ISO_8859_1_musik_
+LANG=de_DE.ISO_8859-1
+
/* Klassik */
02/23 Händel geboren, 1685
03/21 J.S. Bach geboren, 1685
diff --git a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.wissenschaft b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.wissenschaft
index 915149a..d859571 100644
--- a/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.wissenschaft
+++ b/usr.bin/calendar/calendars/de_DE.ISO_8859-1/calendar.wissenschaft
@@ -1,12 +1,14 @@
/*
* Wissenschaft
*
- * $Id: calendar.wissenschaft,v 1.1 1996/01/29 00:34:18 wosch Exp $
+ * $Id: calendar.wissenschaft,v 1.2 1996/02/02 06:05:20 wosch Exp $
*/
#ifndef _de_DE_ISO_8859_1_wissenschaft_
#define _de_DE_ISO_8859_1_wissenschaft_
+LANG=de_DE.ISO_8859-1
+
04/12 erster Mann im All, Juri Gagarin, 1961
04/18 Einstein gestorben, 1955
06/22 Konrad Zuse geboren, 1919, Berlin
diff --git a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici b/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
index fa1ae4f..ae4547c 100644
--- a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
+++ b/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
@@ -1,12 +1,14 @@
/*
* hrvatski praznici
*
- * $Id: calendar.croatian,v 1.2 1996/01/30 23:35:08 wosch Exp $
+ * $Id: calendar.praznici,v 1.1 1996/02/09 14:35:02 wosch Exp $
*/
#ifndef _hr_HR_ISO_8859_2_praznici
#define _hr_HR_ISO_8859_2_praznici
+LANG=hr_HR.ISO_8859-2
+
/* slobodni dr¾avni praznici */
01/01 Nova godina
05/01 Prvi maj
diff --git a/usr.bin/calendar/calendars/hr_HR.ISO_8859-2/calendar.praznici b/usr.bin/calendar/calendars/hr_HR.ISO_8859-2/calendar.praznici
index fa1ae4f..ae4547c 100644
--- a/usr.bin/calendar/calendars/hr_HR.ISO_8859-2/calendar.praznici
+++ b/usr.bin/calendar/calendars/hr_HR.ISO_8859-2/calendar.praznici
@@ -1,12 +1,14 @@
/*
* hrvatski praznici
*
- * $Id: calendar.croatian,v 1.2 1996/01/30 23:35:08 wosch Exp $
+ * $Id: calendar.praznici,v 1.1 1996/02/09 14:35:02 wosch Exp $
*/
#ifndef _hr_HR_ISO_8859_2_praznici
#define _hr_HR_ISO_8859_2_praznici
+LANG=hr_HR.ISO_8859-2
+
/* slobodni dr¾avni praznici */
01/01 Nova godina
05/01 Prvi maj
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c
index 1414c59..5559ba0 100644
--- a/usr.bin/calendar/day.c
+++ b/usr.bin/calendar/day.c
@@ -32,7 +32,10 @@
*/
+#include <ctype.h>
+#include <locale.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <sys/uio.h>
@@ -57,19 +60,83 @@ static char *days[] = {
"sun", "mon", "tue", "wed", "thu", "fri", "sat", NULL,
};
+static char *fndays[8]; /* full national days names */
+static char *ndays[8]; /* short national days names */
+
static char *months[] = {
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec", NULL,
};
+static char *fnmonths[13]; /* full national months names */
+static char *nmonths[13]; /* short national month names */
+
+void setnnames(void)
+{
+ char buf[80];
+ int i, l;
+ struct tm tm;
+
+ for (i = 0; i < 7; i++) {
+ tm.tm_wday = i;
+ strftime(buf, sizeof(buf), "%a", &tm);
+ for (l = strlen(buf);
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
+ if (ndays[i] != NULL)
+ free(ndays[i]);
+ ndays[i] = strdup(buf);
+
+ strftime(buf, sizeof(buf), "%A", &tm);
+ for (l = strlen(buf);
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
+ if (fndays[i] != NULL)
+ free(fndays[i]);
+ fndays[i] = strdup(buf);
+#ifdef DEBUG
+ printf("ndays[%d] = %s, fndays[%d] = %s\n",
+ i, ndays[i], i, fndays[i]);
+#endif
+ }
+ for (i = 0; i < 12; i++) {
+ tm.tm_mon = i;
+ strftime(buf, sizeof(buf), "%b", &tm);
+ for (l = strlen(buf);
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
+ if (nmonths[i] != NULL)
+ free(nmonths[i]);
+ nmonths[i] = strdup(buf);
+
+ strftime(buf, sizeof(buf), "%B", &tm);
+ for (l = strlen(buf);
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
+ if (fnmonths[i] != NULL)
+ free(fnmonths[i]);
+ fnmonths[i] = strdup(buf);
+#ifdef DEBUG
+ printf("nmonths[%d] = %s, fnmonths[%d] = %s\n",
+ i, nmonths[i], i, fnmonths[i]);
+#endif
+ }
+}
void
settime(now)
time_t now;
{
-
tp = localtime(&now);
if ( isleap(tp->tm_year + 1900) ) {
yrdays = 366;
@@ -81,7 +148,12 @@ settime(now)
/* Friday displays Monday's events */
offset = tp->tm_wday == 5 ? 3 : 1;
header[5].iov_base = dayname;
+
+ (void) setlocale(LC_TIME, "C");
header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp);
+ (void) setlocale(LC_TIME, "");
+
+ setnnames();
}
/* convert Day[/Month][/Year] into unix time (since 1970)
@@ -149,7 +221,7 @@ isnow(endp, monthp, dayp, varp)
int *dayp;
int *varp;
{
- int day, flags, month, v1, v2;
+ int day, flags, month = 0, v1, v2;
/*
* CONVENTION
@@ -317,6 +389,12 @@ getmonth(s)
{
register char **p;
+ for (p = fnmonths; *p; ++p)
+ if (!strncasecmp(s, *p, strlen(*p)))
+ return ((p - fnmonths) + 1);
+ for (p = nmonths; *p; ++p)
+ if (!strncasecmp(s, *p, strlen(*p)))
+ return ((p - nmonths) + 1);
for (p = months; *p; ++p)
if (!strncasecmp(s, *p, 3))
return ((p - months) + 1);
@@ -330,6 +408,12 @@ getday(s)
{
register char **p;
+ for (p = fndays; *p; ++p)
+ if (!strncasecmp(s, *p, strlen(*p)))
+ return ((p - fndays) + 1);
+ for (p = ndays; *p; ++p)
+ if (!strncasecmp(s, *p, strlen(*p)))
+ return ((p - ndays) + 1);
for (p = days; *p; ++p)
if (!strncasecmp(s, *p, 3))
return ((p - days) + 1);
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 82c1cd1..3f69a00 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -32,13 +32,13 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
+static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#endif /* not lint */
#include <sys/param.h>
@@ -49,6 +49,7 @@ static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#include <unistd.h>
#include <err.h>
#include <errno.h>
+#include <locale.h>
#include <string.h>
#include <sys/uio.h>
#include <sys/time.h>
@@ -65,13 +66,13 @@ char *calendarHome = ".calendar"; /* HOME */
char *calendarNoMail = "nomail"; /* don't sent mail if this file exist */
struct iovec header[] = {
- "From: ", 6,
- NULL, 0,
- " (Reminder Service)\nTo: ", 24,
- NULL, 0,
- "\nSubject: ", 10,
- NULL, 0,
- "'s Calendar\nPrecedence: bulk\n\n", 30,
+ {"From: ", 6},
+ {NULL, 0},
+ {" (Reminder Service)\nTo: ", 24},
+ {NULL, 0},
+ {"\nSubject: ", 10},
+ {NULL, 0},
+ {"'s Calendar\nPrecedence: bulk\n\n", 30},
};
@@ -81,7 +82,7 @@ cal()
register int printing;
register char *p;
FILE *fp;
- int ch;
+ int ch, l;
int month;
int day;
int var;
@@ -94,8 +95,18 @@ cal()
*p = '\0';
else
while ((ch = getchar()) != '\n' && ch != EOF);
+ for (l = strlen(buf);
+ l > 0 && isspace((unsigned char)buf[l - 1]);
+ l--)
+ ;
+ buf[l] = '\0';
if (buf[0] == '\0')
continue;
+ if (strncmp(buf, "LANG=", 5) == 0) {
+ (void) setlocale(LC_ALL, buf + 5);
+ setnnames();
+ continue;
+ }
if (buf[0] != '\t') {
printing = isnow(buf, &month, &day, &var) ? 1 : 0;
if ((p = strchr(buf, '\t')) == NULL)
@@ -120,23 +131,23 @@ getfield(p, endp, flags)
int val, var;
char *start, savech;
- for (; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
+ for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p);
if (*p == '*') { /* `*' is current month */
*flags |= F_ISMONTH;
*endp = p+1;
return (tp->tm_mon + 1);
}
- if (isdigit(*p)) {
+ if (isdigit((unsigned char)*p)) {
val = strtol(p, &p, 10); /* if 0, it's failure */
- for (; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
+ for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
- for (start = p; isalpha(*++p););
+ for (start = p; isalpha((unsigned char)*++p););
/* Sunday-1 */
if (*p == '+' || *p == '-')
- for(; isdigit(*++p););
+ for(; isdigit((unsigned char)*++p););
savech = *p;
*p = '\0';
@@ -163,12 +174,16 @@ getfield(p, endp, flags)
else if ((val = geteaster(start, tp->tm_year + 1900)) != 0)
*flags |= F_EASTER;
+ /* Paskha */
+ else if ((val = getpaskha(start, tp->tm_year + 1900)) != 0)
+ *flags |= F_EASTER;
+
/* undefined rest */
else {
*p = savech;
return (0);
}
- for (*p = savech; !isdigit(*p) && !isalpha(*p) && *p != '*'; ++p);
+ for (*p = savech; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) && *p != '*'; ++p);
*endp = p;
return (val);
}
diff --git a/usr.bin/calendar/ostern.c b/usr.bin/calendar/ostern.c
index 06e843b..e0ae0f5 100644
--- a/usr.bin/calendar/ostern.c
+++ b/usr.bin/calendar/ostern.c
@@ -1,10 +1,11 @@
/*
* Copyright (c) 1995 Wolfram Schneider. Public domain.
*
- * $Id: ostern.c,v 1.2 1996/02/01 13:05:12 wosch Exp $
+ * $Id: ostern.c,v 1.1 1996/02/02 06:02:40 wosch Exp $
*/
#include <string.h>
+#include <stdlib.h>
/* return year day for Easter */
diff --git a/usr.bin/calendar/paskha.c b/usr.bin/calendar/paskha.c
new file mode 100644
index 0000000..3fa8a31
--- /dev/null
+++ b/usr.bin/calendar/paskha.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define PASKHA "paskha"
+#define PASKHALEN (sizeof(PASKHA) - 1)
+
+/* KOI8-R encoding, needed to fully handle Russian case */
+#define PASKHA1 "ŠĮÓČĮ"
+#define PASKHALEN1 (sizeof(PASKHA1) - 1)
+
+extern int *cumdays;
+
+/* return year day for Orthodox Easter using Gauss formula */
+/* (old style result) */
+
+static int
+paskha (R)
+int R; /*year*/
+{
+ int a, b, c, d, e;
+ static int x = 15;
+ static int y = 6;
+
+ a = R % 19;
+ b = R % 4;
+ c = R % 7;
+ d = (19*a + x) % 30;
+ e = (2*b + 4*c + 6*d + y) % 7;
+ return ((cumdays[2/*feb*/] + 22/*mar*/) + (d + e));
+}
+
+/* return year day for Orthodox Easter depending days */
+
+int
+getpaskha(s, year)
+ char *s;
+ int year;
+{
+ int offset;
+
+ if (strncasecmp(s, PASKHA, PASKHALEN) == 0)
+ s += PASKHALEN;
+ else if (strncasecmp(s, PASKHA1, PASKHALEN1) == 0)
+ s += PASKHALEN1;
+ else
+ return 0;
+
+
+ /* Paskha+1 or Paskha-2
+ * ^ ^ */
+
+ switch(*s) {
+
+ case '-':
+ case '+':
+ offset = atoi(s);
+ break;
+
+ default:
+ offset = 0;
+ break;
+ }
+
+ return (paskha(year) + offset + 13/* new style */);
+}
OpenPOWER on IntegriCloud