Module Name: src
Committed By: christos
Date: Wed Oct 24 00:10:03 UTC 2012
Modified Files:
src/lib/libc/time: Makefile asctime.c ialloc.c localtime.c private.h
scheck.c strftime.c zdump.c zic.c
Log Message:
apply 2012g via patch
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/time/Makefile
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/time/asctime.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/time/ialloc.c
cvs rdiff -u -r1.67 -r1.68 src/lib/libc/time/localtime.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/time/private.h
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/time/scheck.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/time/strftime.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/time/zdump.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/time/zic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/Makefile
diff -u src/lib/libc/time/Makefile:1.6 src/lib/libc/time/Makefile:1.7
--- src/lib/libc/time/Makefile:1.6 Thu Aug 9 08:38:25 2012
+++ src/lib/libc/time/Makefile Tue Oct 23 20:10:03 2012
@@ -3,7 +3,7 @@
# 2009-05-17 by Arthur David Olson.
# Version numbers of the code and data distributions.
-VERSION = 2012e
+VERSION = 2012g
# Change the line below for your time zone (after finding the zone you want in
# the time zone files, or adding it to a time zone file).
@@ -120,10 +120,18 @@ LDLIBS=
# -DZIC_MAX_ABBR_LEN_WO_WARN=3
# (or some other number) to set the maximum time zone abbreviation length
# that zic will accept without a warning (the default is 6)
-GCC_DEBUG_FLAGS = -Dlint -g -O3 -fno-common \
- -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
- -Wnested-externs -Wpointer-arith -Wshadow \
- -Wtraditional # -Wstrict-prototypes -Wwrite-strings
+GCC_DEBUG_FLAGS = -Dlint -g3 -O3 -fno-common -fstrict-aliasing \
+ -Wall -Wextra \
+ -Wbad-function-cast -Wcast-align -Wcast-qual \
+ -Wformat=2 -Winit-self \
+ -Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes \
+ -Wnested-externs \
+ -Wno-format-nonliteral -Wno-sign-compare -Wno-sign-conversion \
+ -Wno-type-limits \
+ -Wno-unused-parameter -Woverlength-strings -Wpointer-arith \
+ -Wshadow -Wstrict-prototypes -Wsuggest-attribute=const \
+ -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \
+ -Wwrite-strings
#
# If you want to use System V compatibility code, add
# -DUSG_COMPAT
@@ -276,7 +284,8 @@ NEWUCBSRCS= date.c strftime.c
SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
tzfile.5 tzselect.8 zic.8 zdump.8
-DOCS= README Theory $(MANS) date.1 Makefile
+COMMON= Makefile
+DOCS= README Theory $(MANS) date.1
PRIMARY_YDATA= africa antarctica asia australasia \
europe northamerica southamerica
YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward
@@ -289,7 +298,7 @@ WEB_PAGES= tz-art.htm tz-link.htm
MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
$(WEB_PAGES) checktab.awk workman.sh \
zoneinfo2tdf.pl
-ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
+ENCHILADA= $(COMMON) $(DOCS) $(SOURCES) $(DATA) $(MISC)
# And for the benefit of csh users on systems that assume the user
# shell should be used to handle commands in Makefiles. . .
@@ -437,10 +446,11 @@ public: $(ENCHILADA) set-timestamps
done
$(AWK) -f checktab.awk $(PRIMARY_YDATA)
LC_ALL=C && export LC_ALL && \
- tar $(TARFLAGS) -cf - $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | \
+ tar $(TARFLAGS) -cf - \
+ $(COMMON) $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | \
gzip $(GZIPFLAGS) > tzcode$(VERSION).tar.gz
LC_ALL=C && export LC_ALL && \
- tar $(TARFLAGS) -cf - $(DATA) | \
+ tar $(TARFLAGS) -cf - $(COMMON) $(DATA) | \
gzip $(GZIPFLAGS) > tzdata$(VERSION).tar.gz
typecheck:
Index: src/lib/libc/time/asctime.c
diff -u src/lib/libc/time/asctime.c:1.15 src/lib/libc/time/asctime.c:1.16
--- src/lib/libc/time/asctime.c:1.15 Mon Jun 25 18:32:46 2012
+++ src/lib/libc/time/asctime.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: asctime.c,v 1.15 2012/06/25 22:32:46 abs Exp $ */
+/* $NetBSD: asctime.c,v 1.16 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -16,7 +16,7 @@
#if 0
static char elsieid[] = "@(#)asctime.c 8.5";
#else
-__RCSID("$NetBSD: asctime.c,v 1.15 2012/06/25 22:32:46 abs Exp $");
+__RCSID("$NetBSD: asctime.c,v 1.16 2012/10/24 00:10:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -94,7 +94,7 @@ static char buf_asctime[MAX_ASCTIME_BUF_
#define ASCTIME_BUFLEN (3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)
char *
-asctime_r(const struct tm * timeptr, char * buf)
+asctime_r(const struct tm *timeptr, char *buf)
{
static const char *wday_name[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
Index: src/lib/libc/time/ialloc.c
diff -u src/lib/libc/time/ialloc.c:1.7 src/lib/libc/time/ialloc.c:1.8
--- src/lib/libc/time/ialloc.c:1.7 Sat Jan 2 05:42:49 2010
+++ src/lib/libc/time/ialloc.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ialloc.c,v 1.7 2010/01/02 10:42:49 tsutsui Exp $ */
+/* $NetBSD: ialloc.c,v 1.8 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -13,44 +13,13 @@
#if 0
static char elsieid[] = "@(#)ialloc.c 8.30";
#else
-__RCSID("$NetBSD: ialloc.c,v 1.7 2010/01/02 10:42:49 tsutsui Exp $");
+__RCSID("$NetBSD: ialloc.c,v 1.8 2012/10/24 00:10:03 christos Exp $");
#endif
#include "private.h"
-#define nonzero(n) (((n) == 0) ? 1 : (n))
-
-char *
-imalloc(n)
-const int n;
-{
- return malloc((size_t) nonzero(n));
-}
-
-char *
-icalloc(nelem, elsize)
-int nelem;
-int elsize;
-{
- if (nelem == 0 || elsize == 0)
- nelem = elsize = 1;
- return calloc((size_t) nelem, (size_t) elsize);
-}
-
-void *
-irealloc(pointer, size)
-void * const pointer;
-const int size;
-{
- if (pointer == NULL)
- return imalloc(size);
- return realloc((void *) pointer, (size_t) nonzero(size));
-}
-
char *
-icatalloc(old, new)
-char * const old;
-const char * const new;
+icatalloc(char *const old, const char *const new)
{
register char * result;
register int oldsize, newsize;
@@ -62,31 +31,14 @@ const char * const new;
return old;
else
oldsize = strlen(old);
- if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
+ if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
if (new != NULL)
(void) strcpy(result + oldsize, new); /* XXX strcpy is safe */
return result;
}
char *
-icpyalloc(string)
-const char * const string;
-{
- return icatalloc((char *) NULL, string);
-}
-
-void
-ifree(p)
-char * const p;
-{
- if (p != NULL)
- (void) free(p);
-}
-
-void
-icfree(p)
-char * const p;
+icpyalloc(const char *const string)
{
- if (p != NULL)
- (void) free(p);
+ return icatalloc(NULL, string);
}
Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.67 src/lib/libc/time/localtime.c:1.68
--- src/lib/libc/time/localtime.c:1.67 Tue Mar 20 12:39:08 2012
+++ src/lib/libc/time/localtime.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.67 2012/03/20 16:39:08 matt Exp $ */
+/* $NetBSD: localtime.c,v 1.68 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.67 2012/03/20 16:39:08 matt Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.68 2012/10/24 00:10:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -155,8 +155,8 @@ typedef struct tm *(*subfun_t)(const tim
static long detzcode(const char * codep);
static time_t detzcode64(const char * codep);
static int differ_by_repeat(time_t t1, time_t t0);
-static const char * getzname(const char * strp);
-static const char * getqzname(const char * strp, const int delim);
+static const char * getzname(const char * strp) __pure;
+static const char * getqzname(const char * strp, const int delim) __pure;
static const char * getnum(const char * strp, int * nump, int min,
int max);
static const char * getsecs(const char * strp, long * secsp);
@@ -168,7 +168,7 @@ static struct tm * gmtsub(const timezone
static struct tm * localsub(const timezone_t sp, const time_t *timep,
long offset, struct tm *tmp);
static int increment_overflow(int * number, int delta);
-static int leaps_thru_end_of(int y);
+static int leaps_thru_end_of(int y) __pure;
static int long_increment_overflow(long * number, int delta);
static int long_normalize_overflow(long * tensptr,
int * unitsptr, int base);
@@ -176,7 +176,7 @@ static int normalize_overflow(int * ten
int base);
static void settzname(void);
static time_t time1(const timezone_t sp, struct tm * const tmp,
- subfun_t funcp, long offset);
+ subfun_t funcp, const long offset);
static time_t time2(const timezone_t sp, struct tm * const tmp,
subfun_t funcp,
const long offset, int *const okayp);
@@ -188,7 +188,7 @@ static struct tm * timesub(const timezon
static int tmcomp(const struct tm * atmp,
const struct tm * btmp);
static time_t transtime(time_t janfirst, int year,
- const struct rule * rulep, long offset);
+ const struct rule * rulep, long offset) __pure;
static int typesequiv(const timezone_t sp, int a, int b);
static int tzload(timezone_t sp, const char * name,
int doextend);
@@ -696,7 +696,7 @@ getqzname(const char *strp, const int de
*/
static const char *
-getnum(const char *strp, int * const nump, const int min, const int max)
+getnum(const char *strp, int *const nump, const int min, const int max)
{
char c;
int num;
@@ -1430,7 +1430,7 @@ localtime_rz(const timezone_t sp, const
*/
static struct tm *
-gmtsub(const timezone_t sp, const time_t * const timep, const long offset,
+gmtsub(const timezone_t sp, const time_t *const timep, const long offset,
struct tm *const tmp)
{
struct tm * result;
@@ -1712,7 +1712,7 @@ ctime_rz(const timezone_t sp, const time
*/
static int
-increment_overflow(int *ip, int j)
+increment_overflow(int *const ip, int j)
{
int i = *ip;
@@ -1729,7 +1729,7 @@ increment_overflow(int *ip, int j)
}
static int
-long_increment_overflow(long *lp, int m)
+long_increment_overflow(long *const lp, int m)
{
long l = *lp;
@@ -2009,7 +2009,7 @@ time2(const timezone_t sp, struct tm *co
static time_t
time1(const timezone_t sp, struct tm *const tmp, subfun_t funcp,
- long offset)
+ const long offset)
{
time_t t;
int samei, otheri;
@@ -2082,7 +2082,7 @@ time1(const timezone_t sp, struct tm *co
}
time_t
-mktime_z(const timezone_t sp, struct tm *tmp)
+mktime_z(const timezone_t sp, struct tm *const tmp)
{
time_t t;
if (sp == NULL)
@@ -2093,7 +2093,7 @@ mktime_z(const timezone_t sp, struct tm
}
time_t
-mktime(struct tm * const tmp)
+mktime(struct tm *const tmp)
{
time_t result;
@@ -2107,7 +2107,7 @@ mktime(struct tm * const tmp)
#ifdef STD_INSPIRED
time_t
-timelocal_z(const timezone_t sp, struct tm *tmp)
+timelocal_z(const timezone_t sp, struct tm *const tmp)
{
if (tmp != NULL)
tmp->tm_isdst = -1; /* in case it wasn't initialized */
Index: src/lib/libc/time/private.h
diff -u src/lib/libc/time/private.h:1.26 src/lib/libc/time/private.h:1.27
--- src/lib/libc/time/private.h:1.26 Thu Aug 9 08:38:25 2012
+++ src/lib/libc/time/private.h Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: private.h,v 1.26 2012/08/09 12:38:25 christos Exp $ */
+/* $NetBSD: private.h,v 1.27 2012/10/24 00:10:03 christos Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@@ -156,6 +156,14 @@ typedef long int_fast64_t;
#define INT32_MIN (-1 - INT32_MAX)
#endif /* !defined INT32_MIN */
+#ifndef __pure
+#if 2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)
+# define __pure __attribute__ ((__pure__))
+#else
+# define __pure /* empty */
+#endif
+#endif
+
/*
** Workarounds for compilers/systems.
*/
@@ -174,13 +182,8 @@ extern char * asctime_r(struct tm const
** Private function declarations.
*/
-char * icalloc(int nelem, int elsize);
char * icatalloc(char * old, const char * new);
char * icpyalloc(const char * string);
-char * imalloc(int n);
-void * irealloc(void * pointer, int size);
-void icfree(char * pointer);
-void ifree(char * pointer);
const char * scheck(const char * string, const char * format);
/*
Index: src/lib/libc/time/scheck.c
diff -u src/lib/libc/time/scheck.c:1.8 src/lib/libc/time/scheck.c:1.9
--- src/lib/libc/time/scheck.c:1.8 Sat Jan 2 05:42:49 2010
+++ src/lib/libc/time/scheck.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: scheck.c,v 1.8 2010/01/02 10:42:49 tsutsui Exp $ */
+/* $NetBSD: scheck.c,v 1.9 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -15,7 +15,7 @@
#if 0
static char elsieid[] = "@(#)scheck.c 8.19";
#else
-__RCSID("$NetBSD: scheck.c,v 1.8 2010/01/02 10:42:49 tsutsui Exp $");
+__RCSID("$NetBSD: scheck.c,v 1.9 2012/10/24 00:10:03 christos Exp $");
#endif
#endif /* !defined lint */
@@ -24,9 +24,7 @@ __RCSID("$NetBSD: scheck.c,v 1.8 2010/01
#include "private.h"
const char *
-scheck(string, format)
-const char * const string;
-const char * const format;
+scheck(const char *const string, const char *const format)
{
register char * fbuf;
register const char * fp;
@@ -38,7 +36,7 @@ const char * const format;
result = "";
if (string == NULL || format == NULL)
return result;
- fbuf = imalloc((int) (2 * strlen(format) + 4));
+ fbuf = malloc(2 * strlen(format) + 4);
if (fbuf == NULL)
return result;
fp = format;
@@ -67,7 +65,7 @@ const char * const format;
*tp++ = 'c';
*tp = '\0';
if (sscanf(string, fbuf, &dummy) != 1)
- result = (char *) format;
- ifree(fbuf);
+ result = format;
+ free(fbuf);
return result;
}
Index: src/lib/libc/time/strftime.c
diff -u src/lib/libc/time/strftime.c:1.22 src/lib/libc/time/strftime.c:1.23
--- src/lib/libc/time/strftime.c:1.22 Tue Mar 20 12:39:08 2012
+++ src/lib/libc/time/strftime.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: strftime.c,v 1.22 2012/03/20 16:39:08 matt Exp $ */
+/* $NetBSD: strftime.c,v 1.23 2012/10/24 00:10:03 christos Exp $ */
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
@@ -6,7 +6,7 @@
static char elsieid[] = "@(#)strftime.c 7.64";
static char elsieid[] = "@(#)strftime.c 8.3";
#else
-__RCSID("$NetBSD: strftime.c,v 1.22 2012/03/20 16:39:08 matt Exp $");
+__RCSID("$NetBSD: strftime.c,v 1.23 2012/10/24 00:10:03 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -99,8 +99,8 @@ extern char * tzname[];
#define IN_ALL 3
size_t
-strftime_z(const timezone_t sp, char * const s, const size_t maxsize,
- const char * const format, const struct tm * const t)
+strftime_z(const timezone_t sp, char *const s, const size_t maxsize,
+ const char *const format, const struct tm *const t)
{
char * p;
int warn;
@@ -131,7 +131,7 @@ strftime_z(const timezone_t sp, char * c
}
static char *
-_fmt(const timezone_t sp, const char *format, const struct tm * const t,
+_fmt(const timezone_t sp, const char *format, const struct tm *const t,
char *pt, const char *const ptlim, int *warnp)
{
for ( ; *format; ++format) {
@@ -585,8 +585,8 @@ strftime(char * const s, const size_t ma
}
static char *
-_conv(const int n, const char * const format, char * const pt,
- const char * const ptlim)
+_conv(const int n, const char *const format, char *const pt,
+ const char *const ptlim)
{
char buf[INT_STRLEN_MAXIMUM(int) + 1];
@@ -595,7 +595,7 @@ _conv(const int n, const char * const fo
}
static char *
-_add(const char *str, char *pt, const char * const ptlim)
+_add(const char *str, char *pt, const char *const ptlim)
{
while (pt < ptlim && (*pt = *str++) != '\0')
++pt;
@@ -612,7 +612,7 @@ _add(const char *str, char *pt, const ch
static char *
_yconv(const int a, const int b, const int convert_top, const int convert_yy,
- char *pt, const char * const ptlim)
+ char *pt, const char *const ptlim)
{
register int lead;
register int trail;
@@ -663,7 +663,7 @@ _loc(void)
*/
if (localebuf.mon[0])
return &localebuf;
- name = setlocale(LC_TIME, (char *) NULL);
+ name = setlocale(LC_TIME, NULL);
if (name == NULL || *name == '\0')
goto no_locale;
/*
Index: src/lib/libc/time/zdump.c
diff -u src/lib/libc/time/zdump.c:1.25 src/lib/libc/time/zdump.c:1.26
--- src/lib/libc/time/zdump.c:1.25 Thu Aug 9 08:38:26 2012
+++ src/lib/libc/time/zdump.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zdump.c,v 1.25 2012/08/09 12:38:26 christos Exp $ */
+/* $NetBSD: zdump.c,v 1.26 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2009-05-17 by Arthur David Olson.
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: zdump.c,v 1.25 2012/08/09 12:38:26 christos Exp $");
+__RCSID("$NetBSD: zdump.c,v 1.26 2012/10/24 00:10:03 christos Exp $");
#endif /* !defined lint */
#include "version.h"
@@ -117,6 +117,14 @@ __RCSID("$NetBSD: zdump.c,v 1.25 2012/08
#endif /* !defined lint */
#endif /* !defined GNUC_or_lint */
+#ifndef __pure
+#if 2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)
+# define __pure __attribute__ ((__pure__))
+#else
+# define __pure /* empty */
+#endif
+#endif
+
#ifndef INITIALIZE
#ifdef GNUC_or_lint
#define INITIALIZE(x) ((x) = 0)
@@ -157,28 +165,27 @@ static int warned;
static const char * abbr(struct tm * tmp);
static void abbrok(const char * abbrp, const char * zone);
-static long delta(struct tm * newp, struct tm * oldp);
+static long delta(struct tm * newp, struct tm * oldp) __pure;
static void dumptime(const struct tm * tmp);
static time_t hunt(char * name, time_t lot, time_t hit);
int main(int, char **);
static void setabsolutes(void);
static void show(char * zone, time_t t, int v);
static const char * tformat(void);
-static time_t yeartot(long y);
+static time_t yeartot(long y) __pure;
#ifndef TYPECHECK
#define my_localtime localtime
#else /* !defined TYPECHECK */
static struct tm *
-my_localtime(tp)
-time_t * tp;
+my_localtime(time_t *tp)
{
- register struct tm * tmp;
+ struct tm *tmp;
tmp = localtime(tp);
if (tp != NULL && tmp != NULL) {
struct tm tm;
- register time_t t;
+ time_t t;
tm = *tmp;
t = mktime(&tm);
@@ -204,12 +211,10 @@ 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;
- register const char * wp;
+ const char *cp;
+ const char *wp;
if (warned)
return;
@@ -242,7 +247,7 @@ const char * const zone;
}
__dead static void
-usage(FILE *stream, int status)
+usage(FILE *const stream, const int status)
{
(void) fprintf(stream,
_("%s: usage is %s [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] zonename ...\n\
@@ -253,26 +258,24 @@ Report bugs to [email protected].\n")
}
int
-main(argc, argv)
-int argc;
-char * argv[];
-{
- register int i;
- register int c;
- register int vflag;
- register char * cutarg;
- register long cutloyear = ZDUMP_LO_YEAR;
- register long cuthiyear = ZDUMP_HI_YEAR;
- register time_t cutlotime;
- register time_t cuthitime;
- register char ** fakeenv;
- time_t now;
- time_t t;
- time_t newt;
- struct tm tm;
- struct tm newtm;
- register struct tm * tmp;
- register struct tm * newtmp;
+main(int argc, char *argv[])
+{
+ int i;
+ int c;
+ int vflag;
+ char * cutarg;
+ long cutloyear = ZDUMP_LO_YEAR;
+ long cuthiyear = ZDUMP_HI_YEAR;
+ time_t cutlotime;
+ time_t cuthitime;
+ char ** fakeenv;
+ time_t now;
+ time_t t;
+ time_t newt;
+ struct tm tm;
+ struct tm newtm;
+ struct tm * tmp;
+ struct tm * newtmp;
INITIALIZE(cutlotime);
INITIALIZE(cuthitime);
@@ -329,15 +332,14 @@ char * argv[];
if (strlen(argv[i]) > longest)
longest = strlen(argv[i]);
{
- register int from;
- register int to;
+ int from;
+ int to;
for (i = 0; environ[i] != NULL; ++i)
continue;
- fakeenv = (char **) malloc((size_t) ((i + 2) *
- sizeof *fakeenv));
+ fakeenv = malloc((i + 2) * sizeof *fakeenv);
if (fakeenv == NULL ||
- (fakeenv[0] = (char *) malloc(longest + 4)) == NULL) {
+ (fakeenv[0] = malloc(longest + 4)) == NULL) {
err(EXIT_FAILURE, "Can't allocated %zu bytes",
longest + 4);
}
@@ -460,12 +462,11 @@ _("%s: use of -v on system with floating
}
static time_t
-yeartot(y)
-const long y;
+yeartot(const long y)
{
- register long myy;
- register long seconds;
- register time_t t;
+ long myy;
+ long seconds;
+ time_t t;
myy = EPOCH_YEAR;
t = 0;
@@ -497,9 +498,9 @@ hunt(char *name, time_t lot, time_t hit)
time_t t;
long diff;
struct tm lotm;
- register struct tm * lotmp;
+ struct tm * lotmp;
struct tm tm;
- register struct tm * tmp;
+ struct tm * tmp;
char loab[MAX_STRING_LENGTH];
lotmp = my_localtime(&lot);
@@ -539,12 +540,10 @@ hunt(char *name, time_t lot, time_t hit)
*/
static long
-delta(newp, oldp)
-struct tm * newp;
-struct tm * oldp;
+delta(struct tm *newp, struct tm *oldp)
{
- register long result;
- register int tmy;
+ long result;
+ int tmy;
if (newp->tm_year < oldp->tm_year)
return -delta(oldp, newp);
@@ -564,7 +563,7 @@ struct tm * oldp;
static void
show(char *zone, time_t t, int v)
{
- register struct tm * tmp;
+ struct tm * tmp;
(void) printf("%-*s ", (int) longest, zone);
if (v) {
@@ -595,10 +594,9 @@ show(char *zone, time_t t, int v)
}
static const char *
-abbr(tmp)
-struct tm * tmp;
+abbr(struct tm *tmp)
{
- register const char * result;
+ const char * result;
static const char nada;
if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1)
@@ -635,8 +633,7 @@ tformat(void)
}
static void
-dumptime(timeptr)
-register const struct tm * timeptr;
+dumptime(const struct tm *timeptr)
{
static const char wday_name[][3] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
@@ -645,10 +642,10 @@ register const struct tm * timeptr;
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
- register const char * wn;
- register const char * mn;
- register int lead;
- register int trail;
+ const char * wn;
+ const char * mn;
+ int lead;
+ int trail;
if (timeptr == NULL) {
(void) printf("NULL");
Index: src/lib/libc/time/zic.c
diff -u src/lib/libc/time/zic.c:1.30 src/lib/libc/time/zic.c:1.31
--- src/lib/libc/time/zic.c:1.30 Thu Aug 9 08:38:26 2012
+++ src/lib/libc/time/zic.c Tue Oct 23 20:10:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: zic.c,v 1.30 2012/08/09 12:38:26 christos Exp $ */
+/* $NetBSD: zic.c,v 1.31 2012/10/24 00:10:03 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.30 2012/08/09 12:38:26 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.31 2012/10/24 00:10:03 christos Exp $");
#endif /* !defined lint */
#include "version.h"
@@ -122,17 +122,8 @@ static int addtype(long gmtoff, const ch
static void leapadd(zic_t t, int positive, int rolling, int count);
static void adjleap(void);
static void associate(void);
-static int ciequal(const char * ap, const char * bp);
-static void convert(long val, char * buf);
-static void convert64(zic_t val, char * buf);
static void dolink(const char * fromfield, const char * tofield);
-static void doabbr(char * abbr, const int, const char * format,
- const char * letters, int isdst, int doquotes);
-static void eat(const char * name, int num);
-static void eats(const char * name, int num,
- const char * rname, int rnum);
static long eitol(int i);
-static void error(const char * message);
static char ** getfields(char * buf);
static long gethms(const char * string, const char * errstrng,
int signable);
@@ -143,34 +134,20 @@ static void inrule(char ** fields, int n
static int inzcont(char ** fields, int nfields);
static int inzone(char ** fields, int nfields);
static int inzsub(char ** fields, int nfields, int iscont);
-static int is32(zic_t x);
-static int itsabbr(const char * abbr, const char * word);
static int itsdir(const char * name);
static int lowerit(int c);
int main(int, char **);
-static char * memcheck(char * tocheck);
static int mkdirs(char * filename);
static void newabbr(const char * abbr);
static long oadd(long t1, long t2);
static void outzone(const struct zone * zp, int ntzones);
-static void puttzcode(long code, FILE * fp);
-static void puttzcode64(zic_t code, FILE * fp);
static int rcomp(const void * leftp, const void * rightp);
static zic_t rpytime(const struct rule * rp, int wantedy);
static void rulesub(struct rule * rp,
const char * loyearp, const char * hiyearp,
const char * typep, const char * monthp,
const char * dayp, const char * timep);
-static int stringoffset(char * result, long offset);
-static int stringrule(char * result, const struct rule * rp,
- long dstoff, long gmtoff);
-static void stringzone(char * result, const int,
- const struct zone * zp, int ntzones);
-static void setboundaries(void);
static zic_t tadd(zic_t t1, long t2);
-static void usage(FILE *stream, int status);
-static void warning(const char * const);
-static void writezone(const char * name, const char * string);
static int yearistype(int year, const char * type);
static int atcomp(const void *avp, const void *bvp);
static void updateminmax(int x);
@@ -185,9 +162,7 @@ static int leapmaxyear;
static int linenum;
static int max_abbrvar_len;
static int max_format_len;
-static zic_t max_time;
static int max_year;
-static zic_t min_time;
static int min_year;
static int noise;
static const char * rfilename;
@@ -393,9 +368,8 @@ static char roll[TZ_MAX_LEAPS];
** Memory allocation.
*/
-static char *
-memcheck(ptr)
-char * const ptr;
+static __pure void *
+memcheck(void *const ptr)
{
if (ptr == NULL) {
const char *e = strerror(errno);
@@ -407,8 +381,8 @@ char * const ptr;
return ptr;
}
-#define emalloc(size) memcheck(imalloc(size))
-#define erealloc(ptr, size) memcheck(irealloc((ptr), (size)))
+#define emalloc(size) memcheck(malloc(size))
+#define erealloc(ptr, size) memcheck(realloc((ptr), (size)))
#define ecpyalloc(ptr) memcheck(icpyalloc(ptr))
#define ecatalloc(oldp, newp) memcheck(icatalloc((oldp), (newp)))
@@ -417,11 +391,8 @@ char * const ptr;
*/
static void
-eats(name, num, rname, rnum)
-const char * const name;
-const int num;
-const char * const rname;
-const int rnum;
+eats(const char *const name, const int num, const char *const rname,
+ const int rnum)
{
filename = name;
linenum = num;
@@ -430,16 +401,13 @@ const int rnum;
}
static void
-eat(name, num)
-const char * const name;
-const int num;
+eat(const char *const name, const int num)
{
- eats(name, num, (char *) NULL, -1);
+ eats(name, num, NULL, -1);
}
static void
-error(string)
-const char * const string;
+error(const char *const string)
{
/*
** Match the format of "cc" to allow sh users to
@@ -456,15 +424,14 @@ const char * const string;
}
static void
-warning(string)
-const char * const string;
+warning(const char *const string)
{
char * cp;
cp = ecpyalloc(_("warning: "));
cp = ecatalloc(cp, string);
error(cp);
- ifree(cp);
+ free(cp);
--errors;
}
@@ -487,13 +454,11 @@ static const char * leapsec;
static const char * yitcommand;
int
-main(argc, argv)
-int argc;
-char * argv[];
-{
- register int i;
- register int j;
- register int c;
+main(int argc, char *argv[])
+{
+ int i;
+ int j;
+ int c;
#ifdef _POSIX_VERSION
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
@@ -586,8 +551,6 @@ _("%s: More than one -L option specified
if (yitcommand == NULL)
yitcommand = "yearistype";
- setboundaries();
-
if (optind < argc && leapsec != NULL) {
infile(leapsec);
adjleap();
@@ -630,12 +593,10 @@ _("%s: More than one -L option specified
}
static void
-dolink(fromfield, tofield)
-const char * const fromfield;
-const char * const tofield;
+dolink(const char *const fromfield, const char *const tofield)
{
- register char * fromname;
- register char * toname;
+ char * fromname;
+ char * toname;
if (fromfield[0] == '/')
fromname = ecpyalloc(fromfield);
@@ -669,7 +630,7 @@ const char * const tofield;
access(fromname, F_OK) == 0 &&
!itsdir(fromname)) {
const char *s = tofield;
- register char * symlinkcontents = NULL;
+ char * symlinkcontents = NULL;
while ((s = strchr(s+1, '/')) != NULL)
symlinkcontents =
@@ -682,7 +643,7 @@ const char * const tofield;
toname);
if (result == 0)
warning(_("hard link failed, symbolic link used"));
- ifree(symlinkcontents);
+ free(symlinkcontents);
}
#endif /* HAVE_SYMLINK */
if (result != 0) {
@@ -694,34 +655,24 @@ warning(_("hard link failed, symbolic li
exit(EXIT_FAILURE);
}
}
- ifree(fromname);
- ifree(toname);
+ free(fromname);
+ free(toname);
}
#define TIME_T_BITS_IN_FILE 64
-
-static void
-setboundaries(void)
-{
- register int i;
-
- min_time = -1;
- for (i = 0; i < TIME_T_BITS_IN_FILE - 1; ++i)
- min_time *= 2;
- max_time = -(min_time + 1);
-}
+static const zic_t min_time = (zic_t) -1 << (TIME_T_BITS_IN_FILE - 1);
+static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1));
static int
-itsdir(name)
-const char * const name;
+itsdir(const char *const name)
{
- register char * myname;
- register int accres;
+ char * myname;
+ int accres;
myname = ecpyalloc(name);
myname = ecatalloc(myname, "/.");
accres = access(myname, F_OK);
- ifree(myname);
+ free(myname);
return accres == 0;
}
@@ -734,9 +685,7 @@ const char * const name;
*/
static int
-rcomp(cp1, cp2)
-const void * cp1;
-const void * cp2;
+rcomp(const void *cp1, const void *cp2)
{
return strcmp(((const struct rule *) cp1)->r_name,
((const struct rule *) cp2)->r_name);
@@ -745,14 +694,13 @@ const void * cp2;
static void
associate(void)
{
- register struct zone * zp;
- register struct rule * rp;
- register int base, out;
- register int i, j;
+ struct zone * zp;
+ struct rule * rp;
+ int base, out;
+ int i, j;
if (nrules != 0) {
- (void) qsort((void *) rules, (size_t) nrules,
- (size_t) sizeof *rules, rcomp);
+ (void) qsort(rules, (size_t)nrules, sizeof *rules, rcomp);
for (i = 0; i < nrules - 1; ++i) {
if (strcmp(rules[i].r_name,
rules[i + 1].r_name) != 0)
@@ -819,16 +767,15 @@ associate(void)
}
static void
-infile(name)
-const char * name;
+infile(const char *name)
{
- register FILE * fp;
- register char ** fields;
- register char * cp;
- register const struct lookup * lp;
- register int nfields;
- register int wantcont;
- register int num;
+ FILE * fp;
+ char ** fields;
+ char * cp;
+ const struct lookup * lp;
+ int nfields;
+ int wantcont;
+ int num;
char buf[BUFSIZ];
if (strcmp(name, "-") == 0) {
@@ -896,7 +843,7 @@ _("%s: panic: Invalid l_value %d\n"),
exit(EXIT_FAILURE);
}
}
- ifree((char *) fields);
+ free(fields);
}
if (ferror(fp)) {
(void) fprintf(stderr, _("%s: Error reading %s\n"),
@@ -923,10 +870,7 @@ _("%s: panic: Invalid l_value %d\n"),
*/
static long
-gethms(string, errstring, signable)
-const char * string;
-const char * const errstring;
-const int signable;
+gethms(const char *string, const char *const errstring, const int signable)
{
long hh;
int mm, ss, sign;
@@ -968,9 +912,7 @@ warning(_("values over 24 hours not hand
}
static void
-inrule(fields, nfields)
-register char ** const fields;
-const int nfields;
+inrule(char **const fields, const int nfields)
{
static struct rule r;
@@ -991,17 +933,14 @@ const int nfields;
r.r_abbrvar = ecpyalloc(fields[RF_ABBRVAR]);
if (max_abbrvar_len < strlen(r.r_abbrvar))
max_abbrvar_len = strlen(r.r_abbrvar);
- rules = (struct rule *) (void *) erealloc((char *) rules,
- (int) ((nrules + 1) * sizeof *rules));
+ rules = erealloc(rules, (nrules + 1) * sizeof *rules);
rules[nrules++] = r;
}
static int
-inzone(fields, nfields)
-register char ** const fields;
-const int nfields;
+inzone(char **const fields, const int nfields)
{
- register int i;
+ int i;
static char * buf;
if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) {
@@ -1009,7 +948,7 @@ const int nfields;
return FALSE;
}
if (strcmp(fields[ZF_NAME], TZDEFAULT) == 0 && lcltime != NULL) {
- buf = erealloc(buf, (int) (132 + strlen(TZDEFAULT)));
+ buf = erealloc(buf, 132 + strlen(TZDEFAULT));
(void)sprintf(buf, /* XXX: sprintf is safe */
_("\"Zone %s\" line and -l option are mutually exclusive"),
TZDEFAULT);
@@ -1017,7 +956,7 @@ _("\"Zone %s\" line and -l option are mu
return FALSE;
}
if (strcmp(fields[ZF_NAME], TZDEFRULES) == 0 && psxrules != NULL) {
- buf = erealloc(buf, (int) (132 + strlen(TZDEFRULES)));
+ buf = erealloc(buf, 132 + strlen(TZDEFRULES));
(void)sprintf(buf, /* XXX: sprintf is safe */
_("\"Zone %s\" line and -p option are mutually exclusive"),
TZDEFRULES);
@@ -1027,9 +966,9 @@ _("\"Zone %s\" line and -p option are mu
for (i = 0; i < nzones; ++i)
if (zones[i].z_name != NULL &&
strcmp(zones[i].z_name, fields[ZF_NAME]) == 0) {
- buf = erealloc(buf, (int) (132 +
+ buf = erealloc(buf, 132 +
strlen(fields[ZF_NAME]) +
- strlen(zones[i].z_filename)));
+ strlen(zones[i].z_filename));
(void)sprintf(buf, /* XXX: sprintf is safe */
_("duplicate zone name %s (file \"%s\", line %d)"),
fields[ZF_NAME],
@@ -1042,9 +981,7 @@ _("duplicate zone name %s (file \"%s\",
}
static int
-inzcont(fields, nfields)
-register char ** const fields;
-const int nfields;
+inzcont(char **const fields, const int nfields)
{
if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) {
error(_("wrong number of fields on Zone continuation line"));
@@ -1054,17 +991,14 @@ const int nfields;
}
static int
-inzsub(fields, nfields, iscont)
-register char ** const fields;
-const int nfields;
-const int iscont;
+inzsub(char **const fields, const int nfields, const int iscont)
{
- register char * cp;
+ char * cp;
static struct zone z;
- register int i_gmtoff, i_rule, i_format;
- register int i_untilyear, i_untilmonth;
- register int i_untilday, i_untiltime;
- register int hasuntil;
+ int i_gmtoff, i_rule, i_format;
+ int i_untilyear, i_untilmonth;
+ int i_untilday, i_untiltime;
+ int hasuntil;
if (iscont) {
i_gmtoff = ZFC_GMTOFF;
@@ -1124,8 +1058,7 @@ const int iscont;
return FALSE;
}
}
- zones = (struct zone *) (void *) erealloc((char *) zones,
- (int) ((nzones + 1) * sizeof *zones));
+ zones = erealloc(zones, (nzones + 1) * sizeof *zones);
zones[nzones++] = z;
/*
** If there was an UNTIL field on this line,
@@ -1135,13 +1068,11 @@ const int iscont;
}
static void
-inleap(fields, nfields)
-register char ** const fields;
-const int nfields;
-{
- register const char * cp;
- register const struct lookup * lp;
- register int i, j;
+inleap(char **const fields, const int nfields)
+{
+ const char * cp;
+ const struct lookup * lp;
+ int i, j;
int year, month, day;
long dayoff, tod;
zic_t t;
@@ -1209,7 +1140,7 @@ const int nfields;
tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
cp = fields[LP_CORR];
{
- register int positive;
+ int positive;
int count;
if (strcmp(cp, "") == 0) { /* infile() turns "-" into "" */
@@ -1239,9 +1170,7 @@ const int nfields;
}
static void
-inlink(fields, nfields)
-register char ** const fields;
-const int nfields;
+inlink(char **const fields, const int nfields)
{
struct link l;
@@ -1261,25 +1190,19 @@ const int nfields;
l.l_linenum = linenum;
l.l_from = ecpyalloc(fields[LF_FROM]);
l.l_to = ecpyalloc(fields[LF_TO]);
- links = (struct link *) (void *) erealloc((char *) links,
- (int) ((nlinks + 1) * sizeof *links));
+ links = erealloc(links, (nlinks + 1) * sizeof *links);
links[nlinks++] = l;
}
static void
-rulesub(rp, loyearp, hiyearp, typep, monthp, dayp, timep)
-register struct rule * const rp;
-const char * const loyearp;
-const char * const hiyearp;
-const char * const typep;
-const char * const monthp;
-const char * const dayp;
-const char * const timep;
-{
- register const struct lookup * lp;
- register const char * cp;
- register char * dp;
- register char * ep;
+rulesub(struct rule *const rp, const char *const loyearp,
+ const char *const hiyearp, const char *const typep,
+ const char *const monthp, const char *const dayp, const char *const timep)
+{
+ const struct lookup * lp;
+ const char * cp;
+ char * dp;
+ char * ep;
if ((lp = byword(monthp, mon_names)) == NULL) {
error(_("invalid month name"));
@@ -1312,7 +1235,7 @@ const char * const timep;
}
}
rp->r_tod = gethms(dp, _("invalid time of day"), FALSE);
- ifree(dp);
+ free(dp);
/*
** Year work.
*/
@@ -1396,12 +1319,12 @@ const char * const timep;
*ep++ = 0;
if (*ep++ != '=') {
error(_("invalid day of month"));
- ifree(dp);
+ free(dp);
return;
}
if ((lp = byword(dp, wday_names)) == NULL) {
error(_("invalid weekday name"));
- ifree(dp);
+ free(dp);
return;
}
rp->r_wday = lp->l_value;
@@ -1410,63 +1333,55 @@ const char * const timep;
rp->r_dayofmonth <= 0 ||
(rp->r_dayofmonth > len_months[1][rp->r_month])) {
error(_("invalid day of month"));
- ifree(dp);
+ free(dp);
return;
}
}
- ifree(dp);
+ free(dp);
}
static void
-convert(val, buf)
-const long val;
-char * const buf;
+convert(const long val, char *const buf)
{
- register int i;
- register int shift;
+ int i;
+ int shift;
+ unsigned char *const b = (unsigned char *) buf;
for (i = 0, shift = 24; i < 4; ++i, shift -= 8)
- buf[i] = val >> shift;
+ b[i] = val >> shift;
}
static void
-convert64(val, buf)
-const zic_t val;
-char * const buf;
+convert64(const zic_t val, char *const buf)
{
- register int i;
- register int shift;
+ int i;
+ int shift;
+ unsigned char *const b = (unsigned char *) buf;
for (i = 0, shift = 56; i < 8; ++i, shift -= 8)
- buf[i] = val >> shift;
+ b[i] = val >> shift;
}
static void
-puttzcode(val, fp)
-const long val;
-FILE * const fp;
+puttzcode(const long val, FILE *const fp)
{
char buf[4];
convert(val, buf);
- (void) fwrite((void *) buf, (size_t) sizeof buf, (size_t) 1, fp);
+ (void) fwrite(buf, sizeof buf, (size_t) 1, fp);
}
static void
-puttzcode64(val, fp)
-const zic_t val;
-FILE * const fp;
+puttzcode64(const zic_t val, FILE *const fp)
{
char buf[8];
convert64(val, buf);
- (void) fwrite((void *) buf, (size_t) sizeof buf, (size_t) 1, fp);
+ (void) fwrite(buf, sizeof buf, (size_t) 1, fp);
}
static int
-atcomp(avp, bvp)
-const void * avp;
-const void * bvp;
+atcomp(const void *avp, const void *bvp)
{
const zic_t a = ((const struct attype *) avp)->at;
const zic_t b = ((const struct attype *) bvp)->at;
@@ -1475,22 +1390,19 @@ const void * bvp;
}
static int
-is32(x)
-const zic_t x;
+is32(const zic_t x)
{
return INT32_MIN <= x && x <= INT32_MAX;
}
static void
-writezone(name, string)
-const char * const name;
-const char * const string;
-{
- register FILE * fp;
- register int i, j;
- register int leapcnt32, leapi32;
- register int timecnt32, timei32;
- register int pass;
+writezone(const char *const name, const char *const string)
+{
+ FILE * fp;
+ int i, j;
+ int leapcnt32, leapi32;
+ int timecnt32, timei32;
+ int pass;
static char * fullname;
static const struct tzhead tzh0;
static struct tzhead tzh;
@@ -1501,8 +1413,8 @@ const char * const string;
** Sort.
*/
if (timecnt > 1)
- (void) qsort((void *) attypes, (size_t) timecnt,
- (size_t) sizeof *attypes, atcomp);
+ (void) qsort(attypes, (size_t) timecnt, sizeof *attypes,
+ atcomp);
/*
** Optimize.
*/
@@ -1570,7 +1482,7 @@ const char * const string;
++leapi32;
}
fullname = erealloc(fullname,
- (int) (strlen(directory) + 1 + strlen(name) + 1));
+ strlen(directory) + 1 + strlen(name) + 1);
(void) sprintf(fullname, "%s/%s", directory, name); /* XXX: sprintf is safe */
/*
** Remove old file, if any, to snap links.
@@ -1594,12 +1506,12 @@ const char * const string;
}
}
for (pass = 1; pass <= 2; ++pass) {
- register int thistimei, thistimecnt;
- register int thisleapi, thisleapcnt;
- register int thistimelim, thisleaplim;
+ int thistimei, thistimecnt;
+ int thisleapi, thisleapcnt;
+ int thistimelim, thisleaplim;
int writetype[TZ_MAX_TIMES];
int typemap[TZ_MAX_TYPES];
- register int thistypecnt;
+ int thistypecnt;
char thischars[TZ_MAX_CHARS];
char thischarcnt;
int indmap[TZ_MAX_CHARS];
@@ -1646,7 +1558,7 @@ const char * const string;
** set correctly).
*/
{
- register int mrudst, mrustd, hidst, histd, type;
+ int mrudst, mrustd, hidst, histd, type;
hidst = histd = mrudst = mrustd = -1;
for (i = thistimei; i < thistimelim; ++i)
@@ -1690,7 +1602,7 @@ const char * const string;
indmap[i] = -1;
thischarcnt = 0;
for (i = 0; i < typecnt; ++i) {
- register char * thisabbr;
+ char * thisabbr;
if (!writetype[i])
continue;
@@ -1707,8 +1619,8 @@ const char * const string;
}
indmap[abbrinds[i]] = j;
}
-#define DO(field) (void) fwrite((void *) tzh.field, \
- (size_t) sizeof tzh.field, (size_t) 1, fp)
+#define DO(field) (void) fwrite(tzh.field, \
+ sizeof tzh.field, (size_t) 1, fp)
tzh = tzh0;
(void) strncpy(tzh.tzh_magic, TZ_MAGIC, sizeof tzh.tzh_magic);
tzh.tzh_version[0] = ZIC_VERSION;
@@ -1730,16 +1642,13 @@ const char * const string;
#undef DO
for (i = thistimei; i < thistimelim; ++i)
if (pass == 1)
- puttzcode((long) ats[i], fp);
+ puttzcode(ats[i], fp);
else puttzcode64(ats[i], fp);
for (i = thistimei; i < thistimelim; ++i) {
unsigned char uc;
uc = typemap[types[i]];
- (void) fwrite((void *) &uc,
- (size_t) sizeof uc,
- (size_t) 1,
- fp);
+ (void) fwrite(&uc, sizeof uc, (size_t) 1, fp);
}
for (i = 0; i < typecnt; ++i)
if (writetype[i]) {
@@ -1748,11 +1657,10 @@ const char * const string;
(void) putc((unsigned char) indmap[abbrinds[i]], fp);
}
if (thischarcnt != 0)
- (void) fwrite((void *) thischars,
- (size_t) sizeof thischars[0],
+ (void) fwrite(thischars, sizeof thischars[0],
(size_t) thischarcnt, fp);
for (i = thisleapi; i < thisleaplim; ++i) {
- register zic_t todo;
+ zic_t todo;
if (roll[i]) {
if (timecnt == 0 || trans[i] < ats[0]) {
@@ -1792,17 +1700,12 @@ const char * const string;
}
static void
-doabbr(abbr, abbrlen, format, letters, isdst, doquotes)
-char * const abbr;
-const int abbrlen;
-const char * const format;
-const char * const letters;
-const int isdst;
-const int doquotes;
-{
- register char * cp;
- register char * slashp;
- register int len;
+doabbr(char *const abbr, const int abbrlen, const char *const format,
+ const char *const letters, const int isdst, const int doquotes)
+{
+ char * cp;
+ char * slashp;
+ int len;
slashp = strchr(format, '/');
if (slashp == NULL) {
@@ -1813,8 +1716,7 @@ const int doquotes;
(void) strlcpy(abbr, slashp + 1, abbrlen);
} else {
if (slashp > format)
- (void) strncpy(abbr, format,
- (unsigned) (slashp - format));
+ (void) strncpy(abbr, format, (size_t)(slashp - format));
abbr[slashp - format] = '\0';
}
if (!doquotes)
@@ -1834,8 +1736,7 @@ const int doquotes;
}
static void
-updateminmax(x)
-const int x;
+updateminmax(const int x)
{
if (min_year > x)
min_year = x;
@@ -1844,13 +1745,11 @@ const int x;
}
static int
-stringoffset(result, offset)
-char * result;
-long offset;
-{
- register int hours;
- register int minutes;
- register int seconds;
+stringoffset(char *result, long offset)
+{
+ int hours;
+ int minutes;
+ int seconds;
result[0] = '\0';
if (offset < 0) {
@@ -1876,17 +1775,14 @@ long offset;
}
static int
-stringrule(result, rp, dstoff, gmtoff)
-char * result;
-const struct rule * const rp;
-const long dstoff;
-const long gmtoff;
+stringrule(char *result, const struct rule *const rp, const long dstoff,
+ const long gmtoff)
{
- register long tod;
+ long tod;
result = end(result);
if (rp->r_dycode == DC_DOM) {
- register int month, total;
+ int month, total;
if (rp->r_dayofmonth == 29 && rp->r_month == TM_FEBRUARY)
return -1;
@@ -1895,7 +1791,7 @@ const long gmtoff;
total += len_months[0][month];
(void) sprintf(result, "J%d", total + rp->r_dayofmonth);
} else {
- register int week;
+ int week;
if (rp->r_dycode == DC_DOWGEQ) {
if ((rp->r_dayofmonth % DAYSPERWEEK) != 1)
@@ -1931,18 +1827,15 @@ const long gmtoff;
}
static void
-stringzone(result, resultlen, zpfirst, zonecount)
-char * result;
-const int resultlen;
-const struct zone * const zpfirst;
-const int zonecount;
-{
- register const struct zone * zp;
- register struct rule * rp;
- register struct rule * stdrp;
- register struct rule * dstrp;
- register int i;
- register const char * abbrvar;
+stringzone(char *result, const int resultlen, const struct zone *const zpfirst,
+ const int zonecount)
+{
+ const struct zone * zp;
+ struct rule * rp;
+ struct rule * stdrp;
+ struct rule * dstrp;
+ int i;
+ const char * abbrvar;
result[0] = '\0';
zp = zpfirst + zonecount - 1;
@@ -2016,28 +1909,26 @@ const int zonecount;
}
static void
-outzone(zpfirst, zonecount)
-const struct zone * const zpfirst;
-const int zonecount;
-{
- register const struct zone * zp;
- register struct rule * rp;
- register int i, j;
- register int usestart, useuntil;
- register zic_t starttime, untiltime;
- register long gmtoff;
- register long stdoff;
- register int year;
- register long startoff;
- register int startttisstd;
- register int startttisgmt;
- register int type;
- register char * startbuf;
- register char * ab;
- register char * envvar;
- register int max_abbr_len;
- register int max_envvar_len;
- register int prodstic; /* all rules are min to max */
+outzone(const struct zone *const zpfirst, const int zonecount)
+{
+ const struct zone * zp;
+ struct rule * rp;
+ int i, j;
+ int usestart, useuntil;
+ zic_t starttime, untiltime;
+ long gmtoff;
+ long stdoff;
+ int year;
+ long startoff;
+ int startttisstd;
+ int startttisgmt;
+ int type;
+ char * startbuf;
+ char * ab;
+ char * envvar;
+ int max_abbr_len;
+ int max_envvar_len;
+ int prodstic; /* all rules are min to max */
max_abbr_len = 2 + max_format_len + max_abbrvar_len;
max_envvar_len = 2 * max_abbr_len + 5 * 9;
@@ -2081,13 +1972,13 @@ const int zonecount;
*/
stringzone(envvar, max_envvar_len+1, zpfirst, zonecount);
if (noise && envvar[0] == '\0') {
- register char * wp;
+ char * wp;
-wp = ecpyalloc(_("no POSIX environment variable for zone"));
+ wp = ecpyalloc(_("no POSIX environment variable for zone"));
wp = ecatalloc(wp, " ");
wp = ecatalloc(wp, zpfirst->z_name);
warning(wp);
- ifree(wp);
+ free(wp);
}
if (envvar[0] == '\0') {
if (min_year >= INT_MIN + YEARSPERREPEAT)
@@ -2132,7 +2023,10 @@ wp = ecpyalloc(_("no POSIX environment v
if (zp->z_nrules == 0) {
stdoff = zp->z_stdoff;
doabbr(startbuf, max_abbr_len + 1, zp->z_format,
- (char *) NULL, stdoff != 0, FALSE);
+/*###2025 [cc] error: passing argument 4 of 'doabbr' makes integer from pointer without a cast%%%*/
+/*###2025 [cc] error: passing argument 2 of 'doabbr' makes pointer from integer without a cast%%%*/
+/*###2025 [cc] error: too many arguments to function 'doabbr'%%%*/
+ NULL, stdoff != 0, FALSE);
type = addtype(oadd(zp->z_gmtoff, stdoff),
startbuf, stdoff != 0, startttisstd,
startttisgmt);
@@ -2159,9 +2053,9 @@ wp = ecpyalloc(_("no POSIX environment v
rp->r_temp = rpytime(rp, year);
}
for ( ; ; ) {
- register int k;
- register zic_t jtime, ktime;
- register long offset;
+ int k;
+ zic_t jtime, ktime;
+ long offset;
INITIALIZE(ktime);
if (useuntil) {
@@ -2220,6 +2114,9 @@ wp = ecpyalloc(_("no POSIX environment v
zp->z_format,
rp->r_abbrvar,
rp->r_stdoff != 0,
+/*###2113 [cc] error: too many arguments to function 'doabbr'%%%*/
+/*###2113 [cc] error: passing argument 4 of 'doabbr' makes integer from pointer without a cast%%%*/
+/*###2113 [cc] error: passing argument 2 of 'doabbr' makes pointer from integer without a cast%%%*/
FALSE);
continue;
}
@@ -2232,12 +2129,18 @@ wp = ecpyalloc(_("no POSIX environment v
rp->r_abbrvar,
rp->r_stdoff !=
0,
+/*###2125 [cc] error: passing argument 4 of 'doabbr' makes integer from pointer without a cast%%%*/
+/*###2125 [cc] error: too many arguments to function 'doabbr'%%%*/
+/*###2125 [cc] error: passing argument 2 of 'doabbr' makes pointer from integer without a cast%%%*/
FALSE);
}
}
eats(zp->z_filename, zp->z_linenum,
rp->r_filename, rp->r_linenum);
doabbr(ab, max_abbr_len+1, zp->z_format, rp->r_abbrvar,
+/*###2131 [cc] error: too many arguments to function 'doabbr'%%%*/
+/*###2131 [cc] error: passing argument 2 of 'doabbr' makes pointer from integer without a cast%%%*/
+/*###2131 [cc] error: passing argument 4 of 'doabbr' makes integer from pointer without a cast%%%*/
rp->r_stdoff != 0, FALSE);
offset = oadd(zp->z_gmtoff, rp->r_stdoff);
type = addtype(offset, ab, rp->r_stdoff != 0,
@@ -2275,15 +2178,13 @@ error(_("can't determine time zone abbre
}
}
writezone(zpfirst->z_name, envvar);
- ifree(startbuf);
- ifree(ab);
- ifree(envvar);
+ free(startbuf);
+ free(ab);
+ free(envvar);
}
static void
-addtt(starttime, type)
-const zic_t starttime;
-int type;
+addtt(const zic_t starttime, int type)
{
if (starttime <= min_time ||
(timecnt == 1 && attypes[0].at < min_time)) {
@@ -2309,14 +2210,10 @@ int type;
}
static int
-addtype(gmtoff, abbr, isdst, ttisstd, ttisgmt)
-const long gmtoff;
-const char * const abbr;
-const int isdst;
-const int ttisstd;
-const int ttisgmt;
+addtype(const long gmtoff, const char *const abbr, const int isdst,
+ const int ttisstd, const int ttisgmt)
{
- register int i, j;
+ int i, j;
if (isdst != TRUE && isdst != FALSE) {
error(_("internal error - addtype called with bad isdst"));
@@ -2369,13 +2266,9 @@ const int ttisgmt;
}
static void
-leapadd(t, positive, rolling, count)
-const zic_t t;
-const int positive;
-const int rolling;
-int count;
+leapadd(const zic_t t, const int positive, const int rolling, int count)
{
- register int i, j;
+ int i, j;
if (leapcnt + (positive ? count : 1) > TZ_MAX_LEAPS) {
error(_("too many leap seconds"));
@@ -2405,8 +2298,8 @@ int count;
static void
adjleap(void)
{
- register int i;
- register long last = 0;
+ int i;
+ long last = 0;
/*
** propagate leap seconds forward
@@ -2418,16 +2311,14 @@ adjleap(void)
}
static int
-yearistype(year, type)
-const int year;
-const char * const type;
+yearistype(const int year, const char *const type)
{
static char * buf;
int result;
if (type == NULL || *type == '\0')
return TRUE;
- buf = erealloc(buf, (int) (132 + strlen(yitcommand) + strlen(type)));
+ buf = erealloc(buf, 132 + strlen(yitcommand) + strlen(type));
(void)sprintf(buf, "%s %d %s", yitcommand, year, type); /* XXX: sprintf is safe */
result = system(buf);
if (WIFEXITED(result)) switch (WEXITSTATUS(result)) {
@@ -2444,17 +2335,15 @@ const char * const type;
}
static int
-lowerit(a)
-int a;
+lowerit(int a)
{
a = (unsigned char) a;
return (isascii(a) && isupper(a)) ? tolower(a) : a;
}
-static int
-ciequal(ap, bp) /* case-insensitive equality */
-register const char * ap;
-register const char * bp;
+/* case-insensitive equality */
+static __pure int
+ciequal(const char *ap, const char *bp)
{
while (lowerit(*ap) == lowerit(*bp++))
if (*ap++ == '\0')
@@ -2462,10 +2351,8 @@ register const char * bp;
return FALSE;
}
-static int
-itsabbr(abbr, word)
-register const char * abbr;
-register const char * word;
+static __pure int
+itsabbr(const char *abbr, const char *word)
{
if (lowerit(*abbr) != lowerit(*word))
return FALSE;
@@ -2478,13 +2365,11 @@ register const char * word;
return TRUE;
}
-static const struct lookup *
-byword(word, table)
-register const char * const word;
-register const struct lookup * const table;
+static __pure const struct lookup *
+byword(const char *const word, const struct lookup *const table)
{
- register const struct lookup * foundlp;
- register const struct lookup * lp;
+ const struct lookup * foundlp;
+ const struct lookup * lp;
if (word == NULL || table == NULL)
return NULL;
@@ -2508,17 +2393,15 @@ register const struct lookup * const tab
}
static char **
-getfields(cp)
-register char * cp;
+getfields(char *cp)
{
- register char * dp;
- register char ** array;
- register int nsubs;
+ char * dp;
+ char ** array;
+ int nsubs;
if (cp == NULL)
return NULL;
- array = (char **) (void *)
- emalloc((int) ((strlen(cp) + 1) * sizeof *array));
+ array = emalloc((strlen(cp) + 1) * sizeof *array);
nsubs = 0;
for ( ; ; ) {
while (isascii((unsigned char) *cp) &&
@@ -2549,38 +2432,28 @@ register char * cp;
return array;
}
-static long
-oadd(t1, t2)
-const long t1;
-const long t2;
+static __pure long
+oadd(const long t1, const long t2)
{
- register long t;
-
- t = t1 + t2;
- if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) {
+ if (t1 < 0 ? t2 < LONG_MIN - t1 : LONG_MAX - t1 < t2) {
error(_("time overflow"));
exit(EXIT_FAILURE);
}
- return t;
+ return t1 + t2;
}
static zic_t
-tadd(t1, t2)
-const zic_t t1;
-const long t2;
+tadd(const zic_t t1, const long t2)
{
- register zic_t t;
-
if (t1 == max_time && t2 > 0)
return max_time;
if (t1 == min_time && t2 < 0)
return min_time;
- t = t1 + t2;
- if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) {
+ if (t1 < 0 ? t2 < min_time - t1 : max_time - t1 < t2) {
error(_("time overflow"));
exit(EXIT_FAILURE);
}
- return t;
+ return t1 + t2;
}
/*
@@ -2589,13 +2462,11 @@ const long t2;
*/
static zic_t
-rpytime(rp, wantedy)
-register const struct rule * const rp;
-register const int wantedy;
-{
- register int y, m, i;
- register long dayoff; /* with a nod to Margaret O. */
- register zic_t t;
+rpytime(const struct rule *const rp, const int wantedy)
+{
+ int y, m, i;
+ long dayoff; /* with a nod to Margaret O. */
+ zic_t t;
if (wantedy == INT_MIN)
return min_time;
@@ -2631,7 +2502,7 @@ register const int wantedy;
--i;
dayoff = oadd(dayoff, eitol(i));
if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) {
- register long wday;
+ long wday;
#define LDAYSPERWEEK ((long) DAYSPERWEEK)
wday = eitol(EPOCH_WDAY);
@@ -2672,31 +2543,30 @@ will not work with pre-2004 versions of
}
static void
-newabbr(string)
-const char * const string;
+newabbr(const char *const string)
{
- register int i;
+ int i;
if (strcmp(string, GRANDPARENTED) != 0) {
- register const char * cp;
- register char * wp;
+ const char * cp;
+ const char * mp;
/*
** 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;
+ mp = NULL;
while (isascii((unsigned char) *cp) &&
isalpha((unsigned char) *cp))
++cp;
if (cp - string == 0)
-wp = _("time zone abbreviation lacks alphabetic at start");
+mp = _("time zone abbreviation lacks alphabetic at start");
if (noise && cp - string > 3)
-wp = _("time zone abbreviation has more than 3 alphabetics");
+mp = _("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 == '-')) {
+mp = _("time zone abbreviation has too many alphabetics");
+ if (mp == NULL && (*cp == '+' || *cp == '-')) {
++cp;
if (isascii((unsigned char) *cp) &&
isdigit((unsigned char) *cp))
@@ -2705,14 +2575,14 @@ wp = _("time zone abbreviation has too m
++cp;
}
if (*cp != '\0')
-wp = _("time zone abbreviation differs from POSIX standard");
- if (wp != NULL) {
- wp = ecpyalloc(wp);
+mp = _("time zone abbreviation differs from POSIX standard");
+ if (mp != NULL) {
+ char *wp = ecpyalloc(mp);
wp = ecatalloc(wp, " (");
wp = ecatalloc(wp, string);
wp = ecatalloc(wp, ")");
warning(wp);
- ifree(wp);
+ free(wp);
}
}
i = strlen(string) + 1;
@@ -2725,11 +2595,10 @@ wp = _("time zone abbreviation differs f
}
static int
-mkdirs(argname)
-char * argname;
+mkdirs(char *argname)
{
- register char * name;
- register char * cp;
+ char * name;
+ char * cp;
if (argname == NULL || *argname == '\0')
return 0;
@@ -2760,20 +2629,19 @@ char * argname;
(void) fprintf(stderr,
_("%s: Can't create directory %s: %s\n"),
progname, name, e);
- ifree(name);
+ free(name);
return -1;
}
}
}
*cp = '/';
}
- ifree(name);
+ free(name);
return 0;
}
static long
-eitol(i)
-const int i;
+eitol(const int i)
{
long l;