diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-09-27 18:19:21 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-09-27 18:19:21 +0000 |
commit | 716bf09b2a5be6f063a72b1233131b4aefdb1359 (patch) | |
tree | f9dcc20b91d5af0cd7d07713bb1206163b5a0e14 /usr.bin | |
parent | 92900900fdc0e9acbb5a7bcc5c706154526cbcc9 (diff) |
some fixes and cleanups some from dfa@solo.ee, some pointed
out by pjanzen@ .
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/calendar/calendar.1 | 9 | ||||
-rw-r--r-- | usr.bin/calendar/calendar.h | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.history | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk | 4 | ||||
-rw-r--r-- | usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan | 4 | ||||
-rw-r--r-- | usr.bin/calendar/day.c | 25 | ||||
-rw-r--r-- | usr.bin/calendar/io.c | 28 |
8 files changed, 49 insertions, 33 deletions
diff --git a/usr.bin/calendar/calendar.1 b/usr.bin/calendar/calendar.1 index e03a69a08d6..cc0f979d83a 100644 --- a/usr.bin/calendar/calendar.1 +++ b/usr.bin/calendar/calendar.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: calendar.1,v 1.15 2001/09/26 20:38:55 mickey Exp $ +.\" $OpenBSD: calendar.1,v 1.16 2001/09/27 18:19:20 mickey Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -95,6 +95,13 @@ To handle national Easter names in the calendars, .Dq Paskha=<national_name> (for Orthodox Easter) can be used. .Pp +To enforce special date calculation mode for Cyrillic calendars +you should specify +.Dq LANG=<local_name> +and +.Dq BODUN=Yes +where <local_name> can be ru_RU.KOI8-R, uk_UA.KOI8-U or by_BY.KOI8-B +.Pp Other lines should begin with a month and day. They may be entered in almost any format, either numeric or as character strings. diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h index 0b5f5a83990..71d8fd0a075 100644 --- a/usr.bin/calendar/calendar.h +++ b/usr.bin/calendar/calendar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: calendar.h,v 1.6 2001/09/26 20:38:55 mickey Exp $ */ +/* $OpenBSD: calendar.h,v 1.7 2001/09/27 18:19:20 mickey Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -60,7 +60,7 @@ struct event { struct match { time_t when; char print_date[30]; - char prefix[30]; + int bodun; int var; struct match *next; }; diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common index 3897f8fca9e..496bde68b33 100644 --- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common +++ b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common @@ -1,14 +1,14 @@ /* * Русские праздники и памятные даты * - * $OpenBSD: calendar.common,v 1.3 2001/09/26 20:40:15 mickey Exp $ + * $OpenBSD: calendar.common,v 1.4 2001/09/27 18:19:20 mickey Exp $ */ #ifndef _ru_RU_KOI8_R_common_ #define _ru_RU_KOI8_R_common_ LANG=ru_RU.KOI8-R -BODUN=Конечно +BODUN=Бодун на утро от: /* Январь */ 01/01 Новый год diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.history b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.history index 0d0b5db4698..0cc122d927e 100644 --- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.history +++ b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.history @@ -1,14 +1,14 @@ /* * Моменты истории * - * $OpenBSD: calendar.history,v 1.2 2001/09/26 20:40:15 mickey Exp $ + * $OpenBSD: calendar.history,v 1.3 2001/09/27 18:19:20 mickey Exp $ */ #ifndef _ru_RU_KOI8_R_history_ #define _ru_RU_KOI8_R_history_ LANG=ru_RU.KOI8-R -BODUN=Конечно +BODUN=Бодун на утро от: 01/01 Введение в России нового летосчисления, 1700г 01/02 Первая фотография Луны, 1839г diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk index f01b56d8507..61368d5bc53 100644 --- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk +++ b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk @@ -1,14 +1,14 @@ /* * Перевод часов для московской временной зоны * - * $OpenBSD: calendar.msk,v 1.2 2001/09/26 20:40:15 mickey Exp $ + * $OpenBSD: calendar.msk,v 1.3 2001/09/27 18:19:20 mickey Exp $ */ #ifndef _ru_RU_KOI8_R_msk_ #define _ru_RU_KOI8_R_msk_ LANG=ru_RU.KOI8-R -BODUN=Конечно +BODUN=Бодун на утро от: 03/SunLast Начало московского летнего времени; часы переводятся вперед 10/SunLast Конец московского летнего времени; часы переводятся назад diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan index 2988df2f89c..6a934cd1eb7 100644 --- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan +++ b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan @@ -1,14 +1,14 @@ /* * Языческие праздники * - * $OpenBSD: calendar.pagan,v 1.2 2001/09/26 20:40:15 mickey Exp $ + * $OpenBSD: calendar.pagan,v 1.3 2001/09/27 18:19:20 mickey Exp $ */ #ifndef _ru_RU_KOI8_R_pagan_ #define _ru_RU_KOI8_R_pagan_ LANG=ru_RU.KOI8-R -BODUN=Конечно +BODUN=Бодун на утро от: 12/21* Зимнее солнцестояние 12/25 Коляда (сдвинутое зимнее солнцестояние) diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 74a5379148e..3ac361ea53e 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.12 2001/09/26 20:38:55 mickey Exp $ */ +/* $OpenBSD: day.c,v 1.13 2001/09/27 18:19:20 mickey Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else -static char rcsid[] = "$OpenBSD: day.c,v 1.12 2001/09/26 20:38:55 mickey Exp $"; +static char rcsid[] = "$OpenBSD: day.c,v 1.13 2001/09/27 18:19:20 mickey Exp $"; #endif #endif /* not lint */ @@ -433,17 +433,22 @@ isnow(endp, bodun) } if ((tmp = malloc(sizeof(struct match))) == NULL) err(1, NULL); - tmp->when = f_time + v2 * SECSPERDAY; + + if (bodun && (day - tp->tm_yday) == -1) { + tmp->when = f_time - 1 * SECSPERDAY; + tmtmp.tm_mday++; + tmp->bodun = 1; + } else { + tmp->when = f_time + v2 * SECSPERDAY; + tmp->bodun = 0; + } + (void)mktime(&tmtmp); if (strftime(tmp->print_date, sizeof(tmp->print_date), /* "%a %b %d", &tm); Skip weekdays */ "%b %d", &tmtmp) == 0) tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; - if (bodun && (day - tp->tm_yday) == -1) - strcpy(tmp->prefix, "Бодун на утро от: "); - else - tmp->prefix[0] = '\0'; tmp->var = varp; tmp->next = NULL; @@ -539,11 +544,7 @@ isnow(endp, bodun) /* "%a %b %d", &tm); Skip weekdays */ "%b %d", &tmtmp) == 0) tmp->print_date[sizeof(tmp->print_date) - 1] = '\0'; - if (bodun && tdiff == -1) - strcpy(tmp->prefix, - "Bodun na ytpo ot: "); - else - tmp->prefix[0] = '\0'; + tmp->bodun = bodun && tdiff == -1; tmp->var = varp; tmp->next = NULL; if (tmp2) diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 3f209dad6f3..a37461cec52 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.16 2001/09/27 02:55:01 mickey Exp $ */ +/* $OpenBSD: io.c,v 1.17 2001/09/27 18:19:20 mickey Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -43,7 +43,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #else -static char rcsid[] = "$OpenBSD: io.c,v 1.16 2001/09/27 02:55:01 mickey Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.17 2001/09/27 18:19:20 mickey Exp $"; #endif #endif /* not lint */ @@ -89,7 +89,7 @@ cal() FILE *fp; int ch, l, i, bodun = 0, bodun_maybe = 0; int var; - char buf[2048 + 1]; + char buf[2048 + 1], *prefix = NULL; struct event *events, *cur_evt, *ev1, *tmp; struct match *m; @@ -114,13 +114,21 @@ cal() !strcmp(buf + 5, "uk_UA.KOI8-U") || !strcmp(buf + 5, "by_BY.KOI8-B")) { bodun_maybe++; - bodun = bodun_always; + bodun = 0; + if (prefix) + free(prefix); + prefix = NULL; } else bodun_maybe = 0; continue; } - if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) + if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) { bodun++; + if (prefix) + free(prefix); + if ((prefix = strdup(buf + 6)) == NULL) + err(1, NULL); + } /* User defined names for special events */ if ((p = strchr(buf, '='))) { for (i = 0; i < NUMEV; i++) { @@ -167,14 +175,14 @@ cal() cur_evt->desc = ev1->desc; cur_evt->ldesc = NULL; } else { - if (m->prefix[0]) { - int l1 = strlen(m->prefix); + if (m->bodun && prefix) { + int l1 = strlen(prefix); int l2 = strlen(p); if ((cur_evt->ldesc = malloc(l1 + l2)) == NULL) - err(1, "realloc"); - sprintf(cur_evt->ldesc, "\t%s%s", - m->prefix, p + 1); + err(1, "malloc"); + sprintf(cur_evt->ldesc, + "\t%s %s", prefix, p + 1); } else if ((cur_evt->ldesc = strdup(p)) == NULL) err(1, NULL); |