summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorDan McDonald <danmcd@omniti.com>2016-04-08 11:27:24 -0400
committerDan McDonald <danmcd@omniti.com>2016-04-11 16:23:15 -0400
commit67e157eca677c3d1b1c5d1049d9fc53c2e05033c (patch)
tree8b80931d6df47447829f2f788271f42eea4b142e /usr/src/cmd
parent237b1f3178a3c47b25420fdd5ba0a1694c18c11a (diff)
downloadillumos-joyent-67e157eca677c3d1b1c5d1049d9fc53c2e05033c.tar.gz
6869 Update zdump to better-handle POSIX timezones
Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/zdump/zdump.c41
-rw-r--r--usr/src/cmd/zic/zic.c27
2 files changed, 19 insertions, 49 deletions
diff --git a/usr/src/cmd/zdump/zdump.c b/usr/src/cmd/zdump/zdump.c
index 45be5589db..eae12f775f 100644
--- a/usr/src/cmd/zdump/zdump.c
+++ b/usr/src/cmd/zdump/zdump.c
@@ -3,8 +3,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* zdump 7.24
* Taken from elsie.nci.nih.gov to replace the existing Solaris zdump,
@@ -142,9 +140,7 @@ time_t *tp;
#endif /* !defined TYPECHECK */
static void
-abbrok(abbrp, zone)
-const char * const abbrp;
-const char * const zone;
+abbrok(const char * const abbrp, const char * const zone)
{
register const char *cp;
int error = 0;
@@ -152,43 +148,24 @@ const char * const zone;
if (warned)
return;
cp = abbrp;
- while (isascii(*cp) && isalpha((unsigned char)*cp))
+ while (isalpha(*cp) || isdigit(*cp) || *cp == '-' || *cp == '+')
++cp;
(void) fflush(stdout);
- if (cp - abbrp == 0) {
- /*
- * TRANSLATION_NOTE
- * The first %s prints for the program name (zdump),
- * the second %s prints the timezone name, the third
- * %s prints the timezone abbreviation (tzname[0] or
- * tzname[1]).
- */
- (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
- "abbreviation \"%s\" lacks alphabetic at start\n"),
- progname, zone, abbrp);
- error = 1;
- } else if (cp - abbrp < 3) {
+ if (cp - abbrp < 3) {
(void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
"abbreviation \"%s\" has fewer than 3 alphabetics\n"),
progname, zone, abbrp);
error = 1;
} else if (cp - abbrp > 6) {
(void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
- "abbreviation \"%s\" has more than 6 alphabetics\n"),
+ "abbreviation \"%s\" has more than 6 characters\n"),
progname, zone, abbrp);
error = 1;
- }
- if (error == 0 && (*cp == '+' || *cp == '-')) {
- ++cp;
- if (isascii(*cp) && isdigit((unsigned char)*cp))
- if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
- ++cp;
- if (*cp != '\0') {
- (void) fprintf(stderr, gettext("%s: warning: "
- "zone \"%s\" abbreviation \"%s\" differs from "
- "POSIX standard\n"), progname, zone, abbrp);
- error = 1;
- }
+ } else if (*cp != '\0') {
+ (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
+ "abbreviation \"%s\" has characters other than "
+ "alphanumerics\n"), progname, zone, abbrp);
+ error = 1;
}
if (error)
warned = TRUE;
diff --git a/usr/src/cmd/zic/zic.c b/usr/src/cmd/zic/zic.c
index 63f4722787..382be7d222 100644
--- a/usr/src/cmd/zic/zic.c
+++ b/usr/src/cmd/zic/zic.c
@@ -2,9 +2,8 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-static char elsieid[] = "@(#)zic.c 7.128.1";
+static char elsieid[] = "@(#)zic.c 7.128.1";
/*
* #define LEAPSECOND_SUPPORT
@@ -2230,8 +2229,7 @@ register const int wantedy;
}
static void
-newabbr(string)
-const char * const string;
+newabbr(const char * const string)
{
register int i;
@@ -2239,30 +2237,25 @@ const char * const string;
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))
+ while (isalpha(*cp) || ('0' <= *cp && *cp <= '9') ||
+ *cp == '-' || *cp == '+') {
++cp;
- if (cp - string == 0)
- wp = gettext(("time zone abbreviation lacks "
- "alphabetic at start"));
- if (noise && cp - string > 3)
- wp = gettext(("time zone abbreviation has more than 3 "
+ }
+ if (noise && cp - string < 3)
+ wp = gettext(("time zone abbreviation has less than 3 "
"alphabetics"));
- if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
+ if (wp == NULL && cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
wp = gettext(("time zone abbreviation has too many "
- "alphabetics"));
+ "characters"));
if (wp == NULL && (*cp == '+' || *cp == '-')) {
++cp;
if (isascii(*cp) && isdigit(*cp))
if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
++cp;
}
- if (*cp != '\0')
+ if (wp == NULL && *cp != '\0')
wp = gettext("time zone abbreviation differs from "
"POSIX standard");
if (wp != NULL) {