summaryrefslogtreecommitdiff
path: root/lib/libc/time/zdump.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2006-02-18 21:54:18 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2006-02-18 21:54:18 +0000
commit5f50945fa963bcbb2a85a9a31a6cd5434c8fa835 (patch)
treea95882f2e211521425ae2b1f4be950ed7c92c498 /lib/libc/time/zdump.c
parent0c56dc52204d19c05046dcc3e47ba5387d3924e9 (diff)
Update to tzcode2006a; primarily just cast and const fixes.
Diffstat (limited to 'lib/libc/time/zdump.c')
-rw-r--r--lib/libc/time/zdump.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c
index 99e1ce5a40d..614398641d7 100644
--- a/lib/libc/time/zdump.c
+++ b/lib/libc/time/zdump.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: zdump.c,v 1.17 2005/08/08 08:05:38 espie Exp $ */
+/* $OpenBSD: zdump.c,v 1.18 2006/02/18 21:54:17 millert Exp $ */
/*
** This file is in the public domain, so clarified as of
-** Feb 14, 2003 by Arthur David Olson (arthur_david_olson@nih.gov).
+** Feb 14, 2003 by Arthur David Olson.
*/
/*
@@ -17,6 +17,10 @@
#include "time.h" /* for struct tm */
#include "stdlib.h" /* for exit, malloc, atoi */
#include "float.h" /* for FLT_MAX and DBL_MAX */
+#include "ctype.h" /* for isalpha et al. */
+#ifndef isascii
+#define isascii(x) 1
+#endif
#ifndef ZDUMP_LO_YEAR
#define ZDUMP_LO_YEAR (-500)
@@ -152,7 +156,7 @@ static char * progname;
static int warned;
static char * abbr P((struct tm * tmp));
-static void abbrok P((const char * abbr, const char * zone));
+static void abbrok P((const char * abbrp, 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));
@@ -199,8 +203,8 @@ time_t * tp;
#endif /* !defined TYPECHECK */
static void
-abbrok(abbr, zone)
-const char * const abbr;
+abbrok(abbrp, zone)
+const char * const abbrp;
const char * const zone;
{
register const char * cp;
@@ -208,30 +212,31 @@ const char * const zone;
if (warned)
return;
- cp = abbr;
+ cp = abbrp;
wp = NULL;
- while (isascii(*cp) && isalpha(*cp))
+ while (isascii((unsigned char) *cp) && isalpha((unsigned char) *cp))
++cp;
- if (cp - abbr == 0)
+ if (cp - abbrp == 0)
wp = _("lacks alphabetic at start");
- if (cp - abbr < 3)
+ else if (cp - abbrp < 3)
wp = _("has fewer than 3 alphabetics");
- if (cp - abbr > 6)
+ else if (cp - abbrp > 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 (isascii((unsigned char) *cp) &&
+ isdigit((unsigned char) *cp))
+ if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
+ ++cp;
+ if (*cp != '\0')
+ wp = _("differs from POSIX standard");
}
- 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);
+ _("%s: warning: zone \"%s\" abbreviation \"%s\" %s\n"),
+ progname, zone, abbrp, wp);
warned = TRUE;
}
@@ -276,9 +281,9 @@ char * argv[];
if ((c != EOF && c != -1) ||
(optind == argc - 1 && strcmp(argv[optind], "=") == 0)) {
(void) fprintf(stderr,
-_("usage %s [-v] [-c [loyear,]hiyear] zonename ...\n"),
+_("usage: %s [-v] [-c [loyear,]hiyear] zonename ...\n"),
progname);
- (void) exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
if (vflag) {
if (cutarg != NULL) {
@@ -295,7 +300,7 @@ _("usage %s [-v] [-c [loyear,]hiyear] zonename ...\n"),
} else {
(void) fprintf(stderr, _("%s: wild -c argument %s\n"),
progname, cutarg);
- (void) exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
}
setabsolutes();
@@ -318,7 +323,7 @@ _("usage %s [-v] [-c [loyear,]hiyear] zonename ...\n"),
if (fakeenv == NULL ||
(fakeenv[0] = (char *) malloc(longest + 4)) == NULL) {
(void) perror(progname);
- (void) exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
to = 0;
strlcpy(fakeenv[to++], "TZ=", longest + 4);
@@ -384,7 +389,7 @@ _("usage %s [-v] [-c [loyear,]hiyear] zonename ...\n"),
if (fflush(stdout) || ferror(stdout)) {
(void) fprintf(stderr, "%s: ", progname);
(void) perror(_("Error writing standard output"));
- (void) exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
/* If exit fails to exit... */
@@ -408,7 +413,7 @@ setabsolutes()
(void) fprintf(stderr,
_("%s: use of -v on system with floating time_t other than float or double\n"),
progname);
- (void) exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
} else if (0 > (time_t) -1) {
/*
@@ -508,7 +513,7 @@ time_t hit;
}
/*
-** Thanks to Paul Eggert (eggert@twinsun.com) for logic used in delta.
+** Thanks to Paul Eggert for logic used in delta.
*/
static long