diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2007-12-29 22:26:52 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2007-12-29 22:26:52 +0000 |
commit | 4963e73b02772bda064113bfa6b351806c4a19e7 (patch) | |
tree | e8f21ce8fa9d0d7652027aa1cebe942f2b6f4a9f | |
parent | 47b4fc964c4486761a3c8de6302562e41e3e121a (diff) |
update to tzcode2007j from elsie.nci.nih.gov; mostly ANSIfication
-rw-r--r-- | lib/libc/time/localtime.c | 152 | ||||
-rw-r--r-- | lib/libc/time/private.h | 93 | ||||
-rw-r--r-- | lib/libc/time/strftime.c | 16 | ||||
-rw-r--r-- | lib/libc/time/tz-link.htm | 33 | ||||
-rw-r--r-- | lib/libc/time/zdump.c | 37 | ||||
-rw-r--r-- | lib/libc/time/zic.c | 134 |
6 files changed, 207 insertions, 258 deletions
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index a22fc0bcf7b..bbb3f4cc224 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localtime.c,v 1.32 2007/02/06 19:35:16 millert Exp $ */ +/* $OpenBSD: localtime.c,v 1.33 2007/12/29 22:26:51 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** 1996-06-05 by Arthur David Olson. @@ -132,51 +132,52 @@ struct rule { ** Prototypes for static functions. */ -static long detzcode P((const char * codep)); -static time_t detzcode64 P((const char * codep)); -static int differ_by_repeat P((time_t t1, time_t t0)); -static const char * getzname P((const char * strp)); -static const char * getqzname P((const char * strp, const int delim)); -static const char * getnum P((const char * strp, int * nump, int min, - int max)); -static const char * getsecs P((const char * strp, long * secsp)); -static const char * getoffset P((const char * strp, long * offsetp)); -static const char * getrule P((const char * strp, struct rule * rulep)); -static void gmtload P((struct state * sp)); -static struct tm * gmtsub P((const time_t * timep, long offset, - struct tm * tmp)); -static struct tm * localsub P((const time_t * timep, long offset, - struct tm * tmp)); -static int increment_overflow P((int * number, int delta)); -static int leaps_thru_end_of P((int y)); -static int long_increment_overflow P((long * number, int delta)); -static int long_normalize_overflow P((long * tensptr, - int * unitsptr, int base)); -static int normalize_overflow P((int * tensptr, int * unitsptr, - int base)); -static void settzname P((void)); -static time_t time1 P((struct tm * tmp, - struct tm * (*funcp) P((const time_t *, - long, struct tm *)), - long offset)); -static time_t time2 P((struct tm *tmp, - struct tm * (*funcp) P((const time_t *, - long, struct tm*)), - long offset, int * okayp)); -static time_t time2sub P((struct tm *tmp, - struct tm * (*funcp) P((const time_t *, - long, struct tm*)), - long offset, int * okayp, int do_norm_secs)); -static struct tm * timesub P((const time_t * timep, long offset, - const struct state * sp, struct tm * tmp)); -static int tmcomp P((const struct tm * atmp, - const struct tm * btmp)); -static time_t transtime P((time_t janfirst, int year, - const struct rule * rulep, long offset)); -static int tzload P((const char * name, struct state * sp, - int doextend)); -static int tzparse P((const char * name, struct state * sp, - int lastditch)); +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 * getnum(const char * strp, int * nump, int min, + int max); +static const char * getsecs(const char * strp, long * secsp); +static const char * getoffset(const char * strp, long * offsetp); +static const char * getrule(const char * strp, struct rule * rulep); +static void gmtload(struct state * sp); +static struct tm * gmtsub(const time_t * timep, long offset, + struct tm * tmp); +static struct tm * localsub(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 long_increment_overflow(long * number, int delta); +static int long_normalize_overflow(long * tensptr, + int * unitsptr, int base); +static int normalize_overflow(int * tensptr, int * unitsptr, + int base); +static void settzname(void); +static time_t time1(struct tm * tmp, + struct tm * (*funcp)(const time_t *, + long, struct tm *), + long offset); +static time_t time2(struct tm *tmp, + struct tm * (*funcp)(const time_t *, + long, struct tm*), + long offset, int * okayp); +static time_t time2sub(struct tm *tmp, + struct tm * (*funcp)(const time_t *, + long, struct tm*), + long offset, int * okayp, int do_norm_secs); +static struct tm * timesub(const time_t * timep, long offset, + const struct state * sp, struct tm * tmp); +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); +static int typesequiv(const struct state * sp, int a, int b); +static int tzload(const char * name, struct state * sp, + int doextend); +static int tzparse(const char * name, struct state * sp, + int lastditch); #ifdef ALL_STATE static struct state * lclptr; @@ -251,7 +252,7 @@ const char * const codep; } static void -settzname P((void)) +settzname(void) { register struct state * const sp = lclptr; register int i; @@ -558,15 +559,42 @@ register const int doextend; } i = 2 * YEARSPERREPEAT; sp->goback = sp->goahead = sp->timecnt > i; - sp->goback = sp->goback && sp->types[i] == sp->types[0] && + sp->goback = sp->goback && + typesequiv(sp, sp->types[i], sp->types[0]) && differ_by_repeat(sp->ats[i], sp->ats[0]); sp->goahead = sp->goahead && - sp->types[sp->timecnt - 1] == sp->types[sp->timecnt - 1 - i] && + typesequiv(sp, sp->types[sp->timecnt - 1], + sp->types[sp->timecnt - 1 - i]) && differ_by_repeat(sp->ats[sp->timecnt - 1], sp->ats[sp->timecnt - 1 - i]); return 0; } +static int +typesequiv(sp, a, b) +const struct state * const sp; +const int a; +const int b; +{ + register int result; + + if (sp == NULL || + a < 0 || a >= sp->typecnt || + b < 0 || b >= sp->typecnt) + result = FALSE; + else { + register const struct ttinfo * ap = &sp->ttis[a]; + register const struct ttinfo * bp = &sp->ttis[b]; + result = ap->tt_gmtoff == bp->tt_gmtoff && + ap->tt_isdst == bp->tt_isdst && + ap->tt_ttisstd == bp->tt_ttisstd && + ap->tt_ttisgmt == bp->tt_ttisgmt && + strcmp(&sp->chars[ap->tt_abbrind], + &sp->chars[bp->tt_abbrind]) == 0; + } + return result; +} + static const int mon_lengths[2][MONSPERYEAR] = { { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } @@ -1113,7 +1141,7 @@ struct state * const sp; } static void -tzsetwall_basic P((void)) +tzsetwall_basic(void) { if (lcl_is_set < 0) return; @@ -1141,7 +1169,7 @@ tzsetwall_basic P((void)) static #endif /* !defined STD_INSPIRED */ void -tzsetwall P((void)) +tzsetwall(void) { _THREAD_PRIVATE_MUTEX_LOCK(lcl); tzsetwall_basic(); @@ -1150,7 +1178,7 @@ tzsetwall P((void)) static void -tzset_basic P((void)) +tzset_basic(void) { register const char * name; @@ -1193,7 +1221,7 @@ tzset_basic P((void)) } void -tzset P((void)) +tzset(void) { _THREAD_PRIVATE_MUTEX_LOCK(lcl); tzset_basic(); @@ -1673,7 +1701,7 @@ register const struct tm * const btmp; static time_t time2sub(tmp, funcp, offset, okayp, do_norm_secs) struct tm * const tmp; -struct tm * (* const funcp) P((const time_t*, long, struct tm*)); +struct tm * (* const funcp)(const time_t*, long, struct tm*); const long offset; int * const okayp; const int do_norm_secs; @@ -1815,12 +1843,8 @@ const int do_norm_secs; ** It's okay to guess wrong since the guess ** gets checked. */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ sp = (const struct state *) - (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); + ((funcp == localsub) ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; @@ -1861,7 +1885,7 @@ label: static time_t time2(tmp, funcp, offset, okayp) struct tm * const tmp; -struct tm * (* const funcp) P((const time_t*, long, struct tm*)); +struct tm * (* const funcp)(const time_t*, long, struct tm*); const long offset; int * const okayp; { @@ -1879,7 +1903,7 @@ int * const okayp; static time_t time1(tmp, funcp, offset) struct tm * const tmp; -struct tm * (* const funcp) P((const time_t *, long, struct tm *)); +struct tm * (* const funcp)(const time_t *, long, struct tm *); const long offset; { register time_t t; @@ -1914,11 +1938,7 @@ const long offset; ** We try to divine the type they started from and adjust to the ** type they need. */ - /* - ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's. - */ - sp = (const struct state *) (((void *) funcp == (void *) localsub) ? - lclptr : gmtptr); + sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; diff --git a/lib/libc/time/private.h b/lib/libc/time/private.h index 869fe8603ca..7dcb8a6d406 100644 --- a/lib/libc/time/private.h +++ b/lib/libc/time/private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: private.h,v 1.20 2007/06/30 13:20:42 millert Exp $ */ +/* $OpenBSD: private.h,v 1.21 2007/12/29 22:26:51 millert Exp $ */ #ifndef PRIVATE_H #define PRIVATE_H @@ -33,7 +33,7 @@ #if 0 #ifndef lint #ifndef NOID -static char privatehid[] = "@(#)private.h 8.3"; +static char privatehid[] = "@(#)private.h 8.5"; #endif /* !defined NOID */ #endif /* !defined lint */ #endif @@ -124,17 +124,15 @@ static char privatehid[] = "@(#)private.h 8.3"; #endif /* !defined WEXITSTATUS */ #if HAVE_UNISTD_H -#include "unistd.h" /* for F_OK and R_OK */ +#include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */ #endif /* HAVE_UNISTD_H */ -#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 */ /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ #define is_digit(c) ((unsigned)(c) - '0' <= 9) @@ -167,78 +165,15 @@ typedef long int_fast64_t; ** Workarounds for compilers/systems. */ -/* -** If your compiler lacks prototypes, "#define P(x) ()". -*/ - -#ifndef P -#define P(x) x -#endif /* !defined P */ - -/* -** SunOS 4.1.1 headers lack EXIT_SUCCESS. -*/ - -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif /* !defined EXIT_SUCCESS */ - -/* -** SunOS 4.1.1 headers lack EXIT_FAILURE. -*/ - -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif /* !defined EXIT_FAILURE */ - -/* -** SunOS 4.1.1 headers lack FILENAME_MAX. -*/ - -#ifndef FILENAME_MAX - -#ifndef MAXPATHLEN -#ifdef unix -#include "sys/param.h" -#endif /* defined unix */ -#endif /* !defined MAXPATHLEN */ - -#ifdef MAXPATHLEN -#define FILENAME_MAX MAXPATHLEN -#endif /* defined MAXPATHLEN */ -#ifndef MAXPATHLEN -#define FILENAME_MAX 1024 /* Pure guesswork */ -#endif /* !defined MAXPATHLEN */ - -#endif /* !defined FILENAME_MAX */ - #if 0 /* -** SunOS 4.1.1 libraries lack remove. -*/ - -#ifndef remove -extern int unlink P((const char * filename)); -#define remove unlink -#endif /* !defined remove */ - -/* -** Some ancient errno.h implementations don't declare errno. -** But some newer errno.h implementations define it as a macro. -** Fix the former without affecting the latter. -*/ -#ifndef errno -extern int errno; -#endif /* !defined errno */ - -/* ** Some time.h implementations don't declare asctime_r. ** Others might define it as a macro. ** Fix the former without affecting the latter. */ #ifndef asctime_r -extern char * asctime_r(); +extern char * asctime_r(struct tm const *, char *); #endif #endif @@ -246,14 +181,14 @@ extern char * asctime_r(); ** Private function declarations. */ -char * icalloc P((int nelem, int elsize)); -char * icatalloc P((char * old, const char * new)); -char * icpyalloc P((const char * string)); -char * imalloc P((int n)); -void * irealloc P((void * pointer, int size)); -void icfree P((char * pointer)); -void ifree P((char * pointer)); -const char * scheck P((const char * string, const char * format)); +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); /* ** Finally, some convenience items. @@ -341,8 +276,8 @@ const char * scheck P((const char * string, const char * format)); #if HAVE_INCOMPATIBLE_CTIME_R #undef asctime_r #undef ctime_r -char *asctime_r P((struct tm const *, char *)); -char *ctime_r P((time_t const *, char *)); +char *asctime_r(struct tm const *, char *); +char *ctime_r(time_t const *, char *); #endif /* HAVE_INCOMPATIBLE_CTIME_R */ #ifndef YEARSPERREPEAT diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 578e8f7cc0c..961773e0c59 100644 --- a/lib/libc/time/strftime.c +++ b/lib/libc/time/strftime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strftime.c,v 1.17 2007/09/17 07:07:23 moritz Exp $ */ +/* $OpenBSD: strftime.c,v 1.18 2007/12/29 22:26:51 millert Exp $ */ #include "private.h" /* @@ -61,7 +61,7 @@ struct lc_time_T { #ifdef LOCALE_HOME #include "sys/stat.h" static struct lc_time_T localebuf; -static struct lc_time_T * _loc P((void)); +static struct lc_time_T * _loc(void); #define Locale _loc() #endif /* defined LOCALE_HOME */ #ifndef LOCALE_HOME @@ -114,11 +114,11 @@ static const struct lc_time_T C_time_locale = { "%a %b %e %H:%M:%S %Z %Y" }; -static char * _add P((const char *, char *, const char *)); -static char * _conv P((int, const char *, char *, const char *)); -static char * _fmt P((const char *, const struct tm *, char *, const char *, - int *)); -static char * _yconv P((int, int, int, int, char *, const char *)); +static char * _add(const char *, char *, const char *); +static char * _conv(int, const char *, char *, const char *); +static char * _fmt(const char *, const struct tm *, char *, const char *, + int *); +static char * _yconv(int, int, int, int, char *, const char *); extern char * tzname[]; @@ -652,7 +652,7 @@ const char * const ptlim; #ifdef LOCALE_HOME static struct lc_time_T * -_loc P((void)) +_loc(void) { static const char locale_home[] = LOCALE_HOME; static const char lc_time[] = "LC_TIME"; diff --git a/lib/libc/time/tz-link.htm b/lib/libc/time/tz-link.htm index f7ee4c9dbe0..b54a5805a99 100644 --- a/lib/libc/time/tz-link.htm +++ b/lib/libc/time/tz-link.htm @@ -8,7 +8,7 @@ <meta http-equiv="Content-type" content='text/html; charset="US-ASCII"'> <meta name="DC.Creator" content="Eggert, Paul"> <meta name="DC.Contributor" content="Olson, Arthur David"> -<meta name="DC.Date" content="2007-08-17"> +<meta name="DC.Date" content="2007-11-29"> <meta name="DC.Description" content="Sources of information about time zones and daylight saving time"> <meta name="DC.Identifier" content="http://www.twinsun.com/tz/tz-link.htm"> @@ -18,7 +18,7 @@ <body> <h1>Sources for Time Zone and Daylight Saving Time Data</h1> <address> -@(#)tz-link.htm 8.13 +@(#)tz-link.htm 8.14 </address> <p> Please send corrections to this web page to the @@ -152,7 +152,7 @@ Consortium</a> is promoting further work in this area. <a href="http://www.calconnect.org/publications/icalendartimezoneproblemsandrecommendationsv1.0.pdf">iCalendar TIMEZONE Problems and Recommendations</a> offers guidelines and recommendations for the use of VTIMEZONE and <code>tz</code>.</li> -<li><a href="http://www.calconnect.org/dstlinks.html">Extended Daylight +<li><a href="http://www.calconnect.org/dstlinks.shtml">Extended Daylight Saving Time Links, Advisories and Changes</a> lists vendor material on recent daylight saving time changes.</li> <li><a @@ -198,9 +198,10 @@ available under both the <abbr>GPL</abbr> and the Perl Artistic License. DateTime::TimeZone also contains a script <code>tests_from_zdump</code> that generates test cases for each clock transition in the <code>tz</code> database.</li> -<li><a href="http://icu-project.org/"><abbr -title="International Components for Unicode">ICU</abbr></a> -contains a C/C++ library for internationalization that +<li><a href="http://icu-project.org/">International Components for +Unicode (<abbr>ICU</abbr>)</a> contains C/C++ and <a +href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> +libraries for internationalization that has a compiler from <code>tz</code> source into an <abbr>ICU</abbr>-specific format. <abbr>ICU</abbr> is freely available under a @@ -211,11 +212,6 @@ contains a class <code>org.joda.time.tz.ZoneInfoCompiler</code> that compiles <code>tz</code> source into a Joda-specific binary format. Joda Time is freely available under a <abbr>BSD</abbr>-style license.</li> -<li><a href="http://mozware.free.fr/devtools/xmlDate/">xmlDate</a> -contains <a -href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> code that -parses <samp>tz</samp> source into an internal object that represents -a time zone. It is freely available under the GPL.</li> <li><a href="http://sourceforge.net/projects/pytz/">PyTZ - Python Time Zone Library</a> compiles <code>tz</code> source into <a href="http://www.python.org/">Python</a>. @@ -251,8 +247,7 @@ This library is freely available under the (<abbr title="Lesser General Public License">LGPL</abbr>)</a>, and is widely used in <abbr>GNU</abbr>/Linux systems.</li> <li><a href="http://www.bmsi.com/java/#TZ">ZoneInfo.java</a> -is a <code>tz</code> binary file reader written in <a -href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a>. +is a <code>tz</code> binary file reader written in Java. It is freely available under the <abbr>LGPL</abbr>.</li> <li>Tcl, mentioned above, also contains a <code>tz</code> binary file reader.</li> @@ -420,10 +415,6 @@ href="http://www.aph.gov.au/LIBRARY/Pubs/rn/2006-07/07rn13.pdf">research note on daylight saving time in Australia</a>. The Bureau of Meteorology publishes a list of <a href="http://www.bom.gov.au/climate/averages/tables/dst_times.shtml">Implementation Dates of Daylight Savings Time within Australia</a>.</dd> -<dt>Austria</dt> -<dd>The National Metrology Institute publishes a -table of <a href="http://www.metrologie.at/pdf/sommerzeit.pdf" -hreflang="de">daylight saving time in Austria (in German)</a>.</dd> <dt>Belgium</dt> <dd>The Royal Observatory of Belgium maintains a table of <a href="http://www.astro.oma.be/GENERAL/INFO/nli001a.html" @@ -500,9 +491,9 @@ Time Protocol</a> discusses how to synchronize clocks of Internet hosts.</li> <li><a -href="ftp://ftp.rfc-editor.org/internet-drafts/draft-ietf-dhc-timezone-option-04.txt">A +href="ftp://ftp.rfc-editor.org/in-notes/rfc4833.txt">A Timezone Option for <abbr title="Dynamic Host Configuration Protocol">DHCP</abbr></a> -proposes a <a +specifies a <a href="http://www.dhcp.org/">DHCP</a> option for a server to configure a client's time zone and daylight saving settings automatically.</li> <li><a href="http://gauss.gge.unb.ca/GMT.UT.and.the.RGO.html">A Few @@ -608,8 +599,8 @@ abbreviations, identifiers, and formats. For example, it contains French translations for "Eastern European Summer Time", "<abbr title="Eastern European Summer Time">EEST</abbr>", and "Bucharest". <a -href="http://unicode.org/cldr/data/charts/by_type/names.zone.html">By-Type -Chart: names.zone</a> shows these values for many locales. +href="http://www.unicode.org/cldr/data/charts/by_type/names.metazone.html">By-Type +Chart: names.metazone</a> shows these values for many locales. <abbr>ICU</abbr> contains a mechanism for using this data.</li> <li>Alphabetic time zone abbreviations should not be used as unique identifiers for <abbr>UTC</abbr> offsets as they are ambiguous in diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c index e1241209e24..a7c72bbb8fb 100644 --- a/lib/libc/time/zdump.c +++ b/lib/libc/time/zdump.c @@ -1,8 +1,8 @@ -/* $OpenBSD: zdump.c,v 1.20 2007/06/30 13:20:42 millert Exp $ */ +/* $OpenBSD: zdump.c,v 1.21 2007/12/29 22:26:51 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** Feb 14, 2003 by Arthur David Olson. -static char elsieid[] = "@(#)zdump.c 8.4"; +static char elsieid[] = "@(#)zdump.c 8.6"; /* ** This code has been made independent of the rest of the time @@ -93,6 +93,9 @@ static char elsieid[] = "@(#)zdump.c 8.4"; #define SECSPERNYEAR (SECSPERDAY * DAYSPERNYEAR) #define SECSPERLYEAR (SECSPERNYEAR + SECSPERDAY) +#ifndef HAVE_GETTEXT +#define HAVE_GETTEXT 0 +#endif #if HAVE_GETTEXT #include "locale.h" /* for setlocale */ #include "libintl.h" @@ -134,13 +137,9 @@ static char elsieid[] = "@(#)zdump.c 8.4"; #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ -#ifndef P -#define P(x) x -#endif /* !defined P */ - extern char ** environ; -extern int getopt P((int argc, char * const argv[], - const char * options)); +extern int getopt(int argc, char * const argv[], + const char * options); extern char * optarg; extern int optind; extern char * tzname[2]; @@ -151,15 +150,15 @@ static size_t longest; static char * progname; static int warned; -static char * abbr P((struct tm * tmp)); -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)); -static void setabsolutes P((void)); -static void show P((char * zone, time_t t, int v)); -static const char * tformat P((void)); -static time_t yeartot P((long y)); +static char * abbr(struct tm * tmp); +static void abbrok(const char * abbrp, const char * zone); +static long delta(struct tm * newp, struct tm * oldp); +static void dumptime(const struct tm * tmp); +static time_t hunt(char * name, time_t lot, time_t hit); +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); #ifndef TYPECHECK #define my_localtime localtime @@ -393,7 +392,7 @@ _("usage: %s [-v] [-c [loyear,]hiyear] zonename ...\n"), } static void -setabsolutes() +setabsolutes(void) { if (0.5 == (time_t) 0.5) { /* @@ -591,7 +590,7 @@ struct tm * tmp; */ static const char * -tformat() +tformat(void) { if (0.5 == (time_t) 0.5) { /* floating */ if (sizeof (time_t) > sizeof (double)) diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index 2ea9df1e8b4..8ba884209bf 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zic.c,v 1.29 2007/06/30 13:20:42 millert Exp $ */ +/* $OpenBSD: zic.c,v 1.30 2007/12/29 22:26:51 millert Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -102,69 +102,69 @@ struct zone { zic_t z_untiltime; }; -extern int getopt P((int argc, char * const argv[], - const char * options)); -extern int link P((const char * fromname, const char * toname)); +extern int getopt(int argc, char * const argv[], + const char * options); +extern int link(const char * fromname, const char * toname); extern char * optarg; extern int optind; -static void addtt P((zic_t starttime, int type)); -static int addtype P((long gmtoff, const char * abbr, int isdst, - int ttisstd, int ttisgmt)); -static void leapadd P((zic_t t, int positive, int rolling, int count)); -static void adjleap P((void)); -static void associate P((void)); -static int ciequal P((const char * ap, const char * bp)); -static void convert P((long val, char * buf)); -static void convert64 P((zic_t val, char * buf)); -static void dolink P((const char * fromfield, const char * tofield)); -static void doabbr P((char * abbr, size_t size, const char * format, - const char * letters, int isdst, int doquotes)); -static void eat P((const char * name, int num)); -static void eats P((const char * name, int num, - const char * rname, int rnum)); -static long eitol P((int i)); -static void error P((const char * message)); -static char ** getfields P((char * buf)); -static long gethms P((const char * string, const char * errstrng, - int signable)); -static void infile P((const char * filename)); -static void inleap P((char ** fields, int nfields)); -static void inlink P((char ** fields, int nfields)); -static void inrule P((char ** fields, int nfields)); -static int inzcont P((char ** fields, int nfields)); -static int inzone P((char ** fields, int nfields)); -static int inzsub P((char ** fields, int nfields, int iscont)); -static int is32 P((zic_t x)); -static int itsabbr P((const char * abbr, const char * word)); -static int itsdir P((const char * name)); -static int lowerit P((int c)); -static char * memcheck P((char * tocheck)); -static int mkdirs P((char * filename)); -static void newabbr P((const char * abbr)); -static long oadd P((long t1, long t2)); -static void outzone P((const struct zone * zp, int ntzones)); -static void puttzcode P((long code, FILE * fp)); -static void puttzcode64 P((zic_t code, FILE * fp)); -static int rcomp P((const void * leftp, const void * rightp)); -static zic_t rpytime P((const struct rule * rp, int wantedy)); -static void rulesub P((struct rule * rp, +static void addtt(zic_t starttime, int type); +static int addtype(long gmtoff, const char * abbr, int isdst, + int ttisstd, int ttisgmt); +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, size_t size, 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); +static void infile(const char * filename); +static void inleap(char ** fields, int nfields); +static void inlink(char ** fields, int nfields); +static void inrule(char ** fields, int nfields); +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); +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 P((char * result, size_t size, long offset)); -static int stringrule P((char * result, size_t size, const struct rule * rp, - long dstoff, long gmtoff)); -static void stringzone P((char * result, size_t size, - const struct zone * zp, int ntzones)); -static void setboundaries P((void)); -static zic_t tadd P((zic_t t1, long t2)); -static void usage P((void)); -static void writezone P((const char * name, const char * string)); -static int yearistype P((int year, const char * type)); + const char * dayp, const char * timep); +static int stringoffset(char * result, size_t size, long offset); +static int stringrule(char * result, size_t size, const struct rule * rp, + long dstoff, long gmtoff); +static void stringzone(char * result, size_t size, + const struct zone * zp, int ntzones); +static void setboundaries(void); +static zic_t tadd(zic_t t1, long t2); +static void usage(void); +static void writezone(const char * name, const char * string); +static int yearistype(int year, const char * type); #if !HAVE_STRERROR -static char * strerror P((int)); +static char * strerror(int); #endif /* !HAVE_STRERROR */ static int charcnt; @@ -290,8 +290,8 @@ struct lookup { const int l_value; }; -static struct lookup const * byword P((const char * string, - const struct lookup * lp)); +static struct lookup const * byword(const char * string, + const struct lookup * lp); static struct lookup const line_codes[] = { { "Rule", LC_RULE }, @@ -474,7 +474,7 @@ const char * const string; } static void -usage P((void)) +usage(void) { (void) fprintf(stderr, _("usage: %s [-v] [-d directory] [-L leapsecondfilename] [-l timezone]\n\t[-p timezone] [-y command] [filename ...]\n"), progname); @@ -675,7 +675,7 @@ const char * const tofield; #define TIME_T_BITS_IN_FILE 64 static void -setboundaries P((void)) +setboundaries(void) { register int i; @@ -717,7 +717,7 @@ const void * cp2; } static void -associate P((void)) +associate(void) { register struct zone * zp; register struct rule * rp; @@ -2015,7 +2015,8 @@ const int zonecount; } for (i = 0; i < zonecount; ++i) { zp = &zpfirst[i]; - updateminmax(zp->z_untilrule.r_loyear); + if (i < zonecount - 1) + updateminmax(zp->z_untilrule.r_loyear); for (j = 0; j < zp->z_nrules; ++j) { rp = &zp->z_rules[j]; if (rp->r_lowasnum) @@ -2046,8 +2047,11 @@ wp = ecpyalloc(_("no POSIX environment variable for zone")); else max_year = INT_MAX; } /* - ** For the benefit of older systems, generate data through 2037. + ** For the benefit of older systems, + ** generate data from 1900 through 2037. */ + if (min_year > 1900) + min_year = 1900; if (max_year < 2037) max_year = 2037; for (i = 0; i < zonecount; ++i) { @@ -2343,7 +2347,7 @@ int count; } static void -adjleap P((void)) +adjleap(void) { register int i; register long last = 0; |