aboutsummaryrefslogtreecommitdiff
path: root/timezone
diff options
context:
space:
mode:
Diffstat (limited to 'timezone')
-rw-r--r--timezone/checktab.awk4
-rw-r--r--timezone/private.h31
-rw-r--r--timezone/scheck.c2
-rw-r--r--timezone/tzselect.ksh4
-rw-r--r--timezone/zdump.c47
-rw-r--r--timezone/zic.c44
6 files changed, 108 insertions, 24 deletions
diff --git a/timezone/checktab.awk b/timezone/checktab.awk
index 6a2d19ae00..6d532141e6 100644
--- a/timezone/checktab.awk
+++ b/timezone/checktab.awk
@@ -1,8 +1,8 @@
# Check tz tables for consistency.
-# @(#)checktab.awk 1.6
+# @(#)checktab.awk 1.7
-# Contributed by Paul Eggert <eggert@twinsun.com>.
+# Contributed by Paul Eggert.
BEGIN {
FS = "\t"
diff --git a/timezone/private.h b/timezone/private.h
index 5de2f7dfe4..9a1ef22abb 100644
--- a/timezone/private.h
+++ b/timezone/private.h
@@ -25,6 +25,8 @@ static char privatehid[] = "@(#)private.h 7.55";
#endif /* !defined NOID */
#endif /* !defined lint */
+#define GRANDPARENTED "Local time zone must be set--see zic manual page"
+
/*
** Defaults for preprocessor symbols.
** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
@@ -91,13 +93,13 @@ static char privatehid[] = "@(#)private.h 7.55";
#include "time.h"
#include "stdlib.h"
-#if HAVE_GETTEXT - 0
+#if HAVE_GETTEXT
#include "libintl.h"
-#endif /* HAVE_GETTEXT - 0 */
+#endif /* HAVE_GETTEXT */
-#if HAVE_SYS_WAIT_H - 0
+#if HAVE_SYS_WAIT_H
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
-#endif /* HAVE_SYS_WAIT_H - 0 */
+#endif /* HAVE_SYS_WAIT_H */
#ifndef WIFEXITED
#define WIFEXITED(status) (((status) & 0xff) == 0)
@@ -106,20 +108,20 @@ static char privatehid[] = "@(#)private.h 7.55";
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#endif /* !defined WEXITSTATUS */
-#if HAVE_UNISTD_H - 0
+#if HAVE_UNISTD_H
#include "unistd.h" /* for F_OK and R_OK */
-#endif /* HAVE_UNISTD_H - 0 */
+#endif /* HAVE_UNISTD_H */
-#if !(HAVE_UNISTD_H - 0)
+#if !HAVE_UNISTD_H
#ifndef F_OK
#define F_OK 0
#endif /* !defined F_OK */
#ifndef R_OK
#define R_OK 4
#endif /* !defined R_OK */
-#endif /* !(HAVE_UNISTD_H - 0) */
+#endif /* !HAVE_UNISTD_H */
-/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
+/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
/*
@@ -216,7 +218,7 @@ char * imalloc P((int n));
void * irealloc P((void * pointer, int size));
void icfree P((char * pointer));
void ifree P((char * pointer));
-char * scheck P((const char *string, const char *format));
+char * scheck P((const char *string, char *format));
/*
** Finally, some convenience items.
@@ -255,7 +257,8 @@ char * scheck P((const char *string, const char *format));
** add one more for a minus sign if the type is signed.
*/
#define INT_STRLEN_MAXIMUM(type) \
- ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
+ ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
+ 1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */
/*
@@ -289,11 +292,11 @@ char * scheck P((const char *string, const char *format));
*/
#ifndef _
-#if HAVE_GETTEXT - 0
+#if HAVE_GETTEXT
#define _(msgid) gettext(msgid)
-#else /* !(HAVE_GETTEXT - 0) */
+#else /* !HAVE_GETTEXT */
#define _(msgid) msgid
-#endif /* !(HAVE_GETTEXT - 0) */
+#endif /* !HAVE_GETTEXT */
#endif /* !defined _ */
#ifndef TZ_DOMAIN
diff --git a/timezone/scheck.c b/timezone/scheck.c
index fd115f9c48..2dd9b35285 100644
--- a/timezone/scheck.c
+++ b/timezone/scheck.c
@@ -11,7 +11,7 @@ static char elsieid[] = "@(#)scheck.c 8.16";
char *
scheck(string, format)
const char * const string;
-const char * const format;
+char * const format;
{
register char * fbuf;
register const char * fp;
diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
index be589240d1..f6e28bfdab 100644
--- a/timezone/tzselect.ksh
+++ b/timezone/tzselect.ksh
@@ -1,11 +1,11 @@
#! @KSH@
-# '@(#)tzselect.ksh 1.7'
+# '@(#)tzselect.ksh 1.8'
# Ask the user about the time zone, and output the resulting TZ value to stdout.
# Interact with the user via stderr and stdin.
-# Contributed by Paul Eggert <eggert@twinsun.com>.
+# Contributed by Paul Eggert.
# Porting notes:
#
diff --git a/timezone/zdump.c b/timezone/zdump.c
index 2fcce38c06..78cc28ef65 100644
--- a/timezone/zdump.c
+++ b/timezone/zdump.c
@@ -1,4 +1,4 @@
-static char elsieid[] = "@(#)zdump.c 7.64";
+static char elsieid[] = "@(#)zdump.c 7.65";
/*
** This code has been made independent of the rest of the time
@@ -144,8 +144,10 @@ static time_t absolute_min_time;
static time_t absolute_max_time;
static size_t longest;
static char * progname;
+static int warned;
static char * abbr P((struct tm * tmp));
+static void abbrok P((const char * abbr, const char * zone));
static long delta P((struct tm * newp, struct tm * oldp));
static void dumptime P((const struct tm * tmp));
static time_t hunt P((char * name, time_t lot, time_t hit));
@@ -191,6 +193,44 @@ time_t * tp;
}
#endif /* !defined TYPECHECK */
+static void
+abbrok(abbr, zone)
+const char * const abbr;
+const char * const zone;
+{
+ register int i;
+ register const char * cp;
+ register char * wp;
+
+ if (warned)
+ return;
+ cp = abbr;
+ wp = NULL;
+ while (isascii(*cp) && isalpha(*cp))
+ ++cp;
+ if (cp - abbr == 0)
+ wp = _("lacks alphabetic at start");
+ if (cp - abbr < 3)
+ wp = _("has fewer than 3 alphabetics");
+ if (cp - abbr > 6)
+ wp = _("has more than 6 alphabetics");
+ if (wp == NULL && (*cp == '+' || *cp == '-')) {
+ ++cp;
+ if (isascii(*cp) && isdigit(*cp))
+ if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
+ ++cp;
+ }
+ if (*cp != '\0')
+ wp = _("differs from POSIX standard");
+ if (wp == NULL)
+ return;
+ (void) fflush(stdout);
+ (void) fprintf(stderr,
+ "%s: warning: zone \"%s\" abbreviation \"%s\" %s\n",
+ progname, zone, abbr, wp);
+ warned = TRUE;
+}
+
int
main(argc, argv)
int argc;
@@ -216,7 +256,7 @@ char * argv[];
INITIALIZE(cutlotime);
INITIALIZE(cuthitime);
#if HAVE_GETTEXT
- (void) setlocale(LC_MESSAGES, "");
+ (void) setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
@@ -297,6 +337,7 @@ _("%s: usage is %s [ --version ] [ -v ] [ -c [loyear,]hiyear ] zonename ...\n"),
show(argv[i], now, FALSE);
continue;
}
+ warned = FALSE;
t = absolute_min_time;
show(argv[i], t, TRUE);
t += SECSPERHOUR * HOURSPERDAY;
@@ -527,6 +568,8 @@ int v;
}
}
(void) printf("\n");
+ if (tmp != NULL && *abbr(tmp) != '\0')
+ abbrok(abbr(tmp), zone);
}
static char *
diff --git a/timezone/zic.c b/timezone/zic.c
index fb86fc69d2..57dc5311d5 100644
--- a/timezone/zic.c
+++ b/timezone/zic.c
@@ -1,4 +1,4 @@
-static char elsieid[] = "@(#)zic.c 7.122";
+static char elsieid[] = "@(#)zic.c 7.124";
/*
** Regardless of the type of time_t, we do our work using this type.
@@ -10,6 +10,10 @@ typedef int zic_t;
#include "locale.h"
#include "tzfile.h"
+#ifndef ZIC_MAX_ABBR_LEN_WO_WARN
+#define ZIC_MAX_ABBR_LEN_WO_WARN 6
+#endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */
+
#if HAVE_SYS_STAT_H
#include "sys/stat.h"
#endif
@@ -475,8 +479,7 @@ char * argv[];
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif /* defined unix */
#if HAVE_GETTEXT
- (void) setlocale(LC_CTYPE, "");
- (void) setlocale(LC_MESSAGES, "");
+ (void) setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
@@ -2197,6 +2200,41 @@ const char * const string;
{
register int i;
+ if (strcmp(string, GRANDPARENTED) != 0) {
+ register const char * cp;
+ register char * wp;
+
+ /*
+ ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics
+ ** optionally followed by a + or - and a number from 1 to 14.
+ */
+ cp = string;
+ wp = NULL;
+ while (isascii(*cp) && isalpha(*cp))
+ ++cp;
+ if (cp - string == 0)
+wp = _("time zone abbreviation lacks alphabetic at start");
+ if (noise && cp - string > 3)
+wp = _("time zone abbreviation has more than 3 alphabetics");
+ if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
+wp = _("time zone abbreviation has too many alphabetics");
+ if (wp == NULL && (*cp == '+' || *cp == '-')) {
+ ++cp;
+ if (isascii(*cp) && isdigit(*cp))
+ if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
+ ++cp;
+ }
+ if (*cp != '\0')
+wp = _("time zone abbreviation differs from POSIX standard");
+ if (wp != NULL) {
+ wp = ecpyalloc(wp);
+ wp = ecatalloc(wp, " (");
+ wp = ecatalloc(wp, string);
+ wp = ecatalloc(wp, ")");
+ warning(wp);
+ ifree(wp);
+ }
+ }
i = strlen(string) + 1;
if (charcnt + i > TZ_MAX_CHARS) {
error(_("too many, or too long, time zone abbreviations"));