diff options
| author | Joseph Myers <joseph@codesourcery.com> | 2012-11-09 21:20:57 +0000 |
|---|---|---|
| committer | Joseph Myers <joseph@codesourcery.com> | 2012-11-09 21:20:57 +0000 |
| commit | 92e4b6a92716f8b2457376291171a6330d072b0d (patch) | |
| tree | 376786acd464b7ec8e556b2336fd66d73c28f956 /timezone | |
| parent | 9bde902c768916daeec9983dcc0c8c420cd3895d (diff) | |
| download | glibc-92e4b6a92716f8b2457376291171a6330d072b0d.tar.xz glibc-92e4b6a92716f8b2457376291171a6330d072b0d.zip | |
Update tzcode to 2012i.
Diffstat (limited to 'timezone')
| -rw-r--r-- | timezone/README | 7 | ||||
| -rw-r--r-- | timezone/checktab.awk | 2 | ||||
| -rw-r--r-- | timezone/ialloc.c | 62 | ||||
| -rw-r--r-- | timezone/private.h | 21 | ||||
| -rw-r--r-- | timezone/scheck.c | 16 | ||||
| -rw-r--r-- | timezone/tzfile.h | 10 | ||||
| -rw-r--r-- | timezone/tzselect.ksh | 33 | ||||
| -rw-r--r-- | timezone/version.h | 1 | ||||
| -rw-r--r-- | timezone/zdump.c | 131 | ||||
| -rw-r--r-- | timezone/zic.c | 404 |
10 files changed, 224 insertions, 463 deletions
diff --git a/timezone/README b/timezone/README index 05bfe91a28..cb3d2cdb69 100644 --- a/timezone/README +++ b/timezone/README @@ -1,7 +1,10 @@ The files zic.c zdump.c ialloc.c scheck.c tzfile.h private.h tzselect.ksh checktab.awk -come from the tzcode package by Arthur David Olson et.al. +come from the tzcode package by Arthur David Olson et.al.; the file + version.h +has the contents that would be generated by that package's Makefile, +and tzselect.ksh has been modified for use in glibc. The files africa antarctica asia australasia europe @@ -13,5 +16,5 @@ come from the tzdata package by Arthur David Olson et.al. Please check the ChangeLog files in the top level directory for the version of the tzcode and tzdata packages. -These packages may be found at ftp://munnari.oz.au/pub/. Commentary +These packages may be found at ftp://ftp.iana.org/tz/releases/. Commentary should be addressed to tz@iana.org. diff --git a/timezone/checktab.awk b/timezone/checktab.awk index 80ad7d5701..c88b12f1ba 100644 --- a/timezone/checktab.awk +++ b/timezone/checktab.awk @@ -1,7 +1,5 @@ # Check tz tables for consistency. -# @(#)checktab.awk 8.1 - # Contributed by Paul Eggert. BEGIN { diff --git a/timezone/ialloc.c b/timezone/ialloc.c index 1fc2035f45..b6f018897b 100644 --- a/timezone/ialloc.c +++ b/timezone/ialloc.c @@ -3,49 +3,12 @@ ** 2006-07-17 by Arthur David Olson. */ -#ifndef lint -#ifndef NOID -static char elsieid[] = "@(#)ialloc.c 8.30"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - /*LINTLIBRARY*/ #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; @@ -56,31 +19,14 @@ const char * const new; else if (newsize == 0) 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); 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); } diff --git a/timezone/private.h b/timezone/private.h index 008d468ac7..1d1d391f56 100644 --- a/timezone/private.h +++ b/timezone/private.h @@ -15,16 +15,6 @@ ** Thank you! */ -/* -** ID -*/ - -#ifndef lint -#ifndef NOID -static char privatehid[] = "@(#)private.h 8.6"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - #define GRANDPARENTED "Local time zone must be set--see zic manual page" /* @@ -154,6 +144,12 @@ typedef long int_fast64_t; #define INT32_MIN (-1 - INT32_MAX) #endif /* !defined INT32_MIN */ +#if 2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__) +# define ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define ATTRIBUTE_PURE /* empty */ +#endif + /* ** Workarounds for compilers/systems. */ @@ -172,13 +168,8 @@ extern char * asctime_r(struct tm const *, char *); ** 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); /* diff --git a/timezone/scheck.c b/timezone/scheck.c index 74d9b07c14..ed60980d83 100644 --- a/timezone/scheck.c +++ b/timezone/scheck.c @@ -3,20 +3,12 @@ ** 2006-07-17 by Arthur David Olson. */ -#ifndef lint -#ifndef NOID -static char elsieid[] = "@(#)scheck.c 8.19"; -#endif /* !defined lint */ -#endif /* !defined NOID */ - /*LINTLIBRARY*/ #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; @@ -28,7 +20,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; @@ -57,7 +49,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; } diff --git a/timezone/tzfile.h b/timezone/tzfile.h index 3a9eee305a..0f6c687f16 100644 --- a/timezone/tzfile.h +++ b/timezone/tzfile.h @@ -16,16 +16,6 @@ */ /* -** ID -*/ - -#ifndef lint -#ifndef NOID -static char tzfilehid[] = "@(#)tzfile.h 8.1"; -#endif /* !defined NOID */ -#endif /* !defined lint */ - -/* ** Information about time zone files. */ diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh index 57bf707e45..0e93d7982b 100644 --- a/timezone/tzselect.ksh +++ b/timezone/tzselect.ksh @@ -1,6 +1,6 @@ #! @KSH@ -VERSION='@(#)tzselect.ksh 8.2' +TZVERSION=tz2012i # Ask the user about the time zone, and output the resulting TZ value to stdout. # Interact with the user via stderr and stdin. @@ -9,29 +9,22 @@ VERSION='@(#)tzselect.ksh 8.2' # Porting notes: # -# This script requires several features of the Korn shell. -# If your host lacks the Korn shell, -# you can use either of the following free programs instead: -# -# <a href=ftp://ftp.gnu.org/pub/gnu/> -# Bourne-Again shell (bash) -# </a> +# This script requires a Posix-like shell with the extension of a +# 'select' statement. The 'select' statement was introduced in the +# Korn shell and is available in Bash and other shell implementations. +# If your host lacks both Bash and the Korn shell, you can get their +# source from one of these locations: # -# <a href=ftp://ftp.cs.mun.ca/pub/pdksh/pdksh.tar.gz> -# Public domain ksh -# </a> +# Bash <http://www.gnu.org/software/bash/bash.html> +# Korn Shell <http://www.kornshell.com/> +# Public Domain Korn Shell <http://www.cs.mun.ca/~michael/pdksh/> # # This script also uses several features of modern awk programs. -# If your host lacks awk, or has an old awk that does not conform to Posix.2, +# If your host lacks awk, or has an old awk that does not conform to Posix, # you can use either of the following free programs instead: # -# <a href=ftp://ftp.gnu.org/pub/gnu/> -# GNU awk (gawk) -# </a> -# -# <a href=ftp://ftp.whidbey.net/pub/brennan/> -# mawk -# </a> +# Gawk (GNU awk) <http://www.gnu.org/software/gawk/> +# mawk <http://invisible-island.net/mawk/> # Specify default values for environment variables if they are unset. @@ -55,7 +48,7 @@ EOF exit 0 elif [ "$1" = "--version" ]; then cat <<EOF -tzselect $VERSION +tzselect $TZVERSION EOF exit 0 fi diff --git a/timezone/version.h b/timezone/version.h new file mode 100644 index 0000000000..0873ea1347 --- /dev/null +++ b/timezone/version.h @@ -0,0 +1 @@ +static char const TZVERSION[]="tz2012i"; diff --git a/timezone/zdump.c b/timezone/zdump.c index 67bed06bc3..805267d14c 100644 --- a/timezone/zdump.c +++ b/timezone/zdump.c @@ -3,7 +3,7 @@ ** 2009-05-17 by Arthur David Olson. */ -static char elsieid[] = "@(#)zdump.c 8.10"; +#include "version.h" /* ** This code has been made independent of the rest of the time @@ -17,6 +17,7 @@ static char elsieid[] = "@(#)zdump.c 8.10"; #include "time.h" /* for struct tm */ #include "stdlib.h" /* for exit, malloc, atoi */ #include "float.h" /* for FLT_MAX and DBL_MAX */ +#include "limits.h" /* for CHAR_BIT, LLONG_MAX */ #include "ctype.h" /* for isalpha et al. */ #ifndef isascii #define isascii(x) 1 @@ -119,6 +120,12 @@ static char elsieid[] = "@(#)zdump.c 8.10"; #endif /* !defined GNUC_or_lint */ #endif /* !defined INITIALIZE */ +#if 2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__) +# define ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define ATTRIBUTE_PURE /* empty */ +#endif + /* ** For the benefit of GNU folk... ** `_(MSGID)' uses the current locale's message library string for MSGID. @@ -144,28 +151,54 @@ extern char * optarg; extern int optind; extern char * tzname[2]; -static time_t absolute_min_time; -static time_t absolute_max_time; +/* The minimum and maximum finite time values. Shift 'long long' or + 'long' instead of 'time_t'; this avoids compile-time errors when + time_t is floating-point. In practice, 'long long' is wide enough. */ +static time_t const absolute_min_time = + ((time_t) 0.5 == 0.5 + ? (sizeof (time_t) == sizeof (float) ? (time_t) -FLT_MAX + : sizeof (time_t) == sizeof (double) ? (time_t) -DBL_MAX + : sizeof (time_t) == sizeof (long double) ? (time_t) -LDBL_MAX + : 0) + : (time_t) -1 < 0 +#ifdef LLONG_MAX + ? (time_t) ((long long) -1 << (CHAR_BIT * sizeof (time_t) - 1)) +#else + ? (time_t) ((long) -1 << (CHAR_BIT * sizeof (time_t) - 1)) +#endif + : 0); +static time_t const absolute_max_time = + ((time_t) 0.5 == 0.5 + ? (sizeof (time_t) == sizeof (float) ? (time_t) FLT_MAX + : sizeof (time_t) == sizeof (double) ? (time_t) DBL_MAX + : sizeof (time_t) == sizeof (long double) ? (time_t) LDBL_MAX + : -1) + : (time_t) -1 < 0 +#ifdef LLONG_MAX + ? (time_t) (- (~ 0 < 0) - ((long long) -1 << (CHAR_BIT * sizeof (time_t) - 1))) +#else + ? (time_t) (- (~ 0 < 0) - ((long) -1 << (CHAR_BIT * sizeof (time_t) - 1))) +#endif + : (time_t) -1); static size_t longest; static char * progname; static int warned; 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 long delta(struct tm * newp, struct tm * oldp) ATTRIBUTE_PURE; 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 checkabsolutes(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) ATTRIBUTE_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; @@ -198,12 +231,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 char * wp; + register const char * wp; if (warned) return; @@ -236,9 +267,7 @@ const char * const zone; } static void -usage(stream, status) -FILE * const stream; -const int status; +usage(FILE * const stream, const int status) { (void) fprintf(stream, _("%s: usage is %s [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] zonename ...\n\ @@ -249,9 +278,7 @@ Report bugs to tz@elsie.nci.nih.gov.\n"), } int -main(argc, argv) -int argc; -char * argv[]; +main(int argc, char *argv[]) { register int i; register int c; @@ -282,7 +309,7 @@ char * argv[]; progname = argv[0]; for (i = 1; i < argc; ++i) if (strcmp(argv[i], "--version") == 0) { - (void) printf("%s\n", elsieid); + (void) printf("%s\n", TZVERSION); exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "--help") == 0) { usage(stdout, EXIT_SUCCESS); @@ -315,7 +342,7 @@ char * argv[]; exit(EXIT_FAILURE); } } - setabsolutes(); + checkabsolutes(); cutlotime = yeartot(cutloyear); cuthitime = yeartot(cuthiyear); } @@ -330,10 +357,9 @@ char * argv[]; for (i = 0; environ[i] != NULL; ++i) continue; - fakeenv = (char **) malloc((size_t) ((i + 2) * - sizeof *fakeenv)); - if (fakeenv == NULL || - (fakeenv[0] = (char *) malloc(longest + 4)) == NULL) { + fakeenv = malloc((i + 2) * sizeof *fakeenv); + if (fakeenv == NULL + || (fakeenv[0] = malloc(longest + 4)) == NULL) { (void) perror(progname); exit(EXIT_FAILURE); } @@ -406,53 +432,18 @@ char * argv[]; } static void -setabsolutes(void) +checkabsolutes(void) { - if (0.5 == (time_t) 0.5) { - /* - ** time_t is floating. - */ - if (sizeof (time_t) == sizeof (float)) { - absolute_min_time = (time_t) -FLT_MAX; - absolute_max_time = (time_t) FLT_MAX; - } else if (sizeof (time_t) == sizeof (double)) { - absolute_min_time = (time_t) -DBL_MAX; - absolute_max_time = (time_t) DBL_MAX; - } else { - (void) fprintf(stderr, + if (absolute_max_time < absolute_min_time) { + (void) fprintf(stderr, _("%s: use of -v on system with floating time_t other than float or double\n"), - progname); - exit(EXIT_FAILURE); - } - } else if (0 > (time_t) -1) { - /* - ** time_t is signed. Assume overflow wraps around. - */ - time_t t = 0; - time_t t1 = 1; - - while (t < t1) { - t = t1; - t1 = 2 * t1 + 1; - } - - absolute_max_time = t; - t = -t; - absolute_min_time = t - 1; - if (t < absolute_min_time) - absolute_min_time = t; - } else { - /* - ** time_t is unsigned. - */ - absolute_min_time = 0; - absolute_max_time = absolute_min_time - 1; + progname); + exit(EXIT_FAILURE); } } static time_t -yeartot(y) -const long y; +yeartot(const long y) { register long myy; register long seconds; @@ -530,9 +521,7 @@ 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; @@ -586,8 +575,7 @@ show(char *zone, time_t t, int v) } static char * -abbr(tmp) -struct tm * tmp; +abbr(struct tm *tmp) { register char * result; static char nada; @@ -626,8 +614,7 @@ tformat(void) } static void -dumptime(timeptr) -register const struct tm * timeptr; +dumptime(register const struct tm *timeptr) { static const char wday_name[][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" diff --git a/timezone/zic.c b/timezone/zic.c index 1ea7b18eb6..64af1b21b3 100644 --- a/timezone/zic.c +++ b/timezone/zic.c @@ -3,8 +3,7 @@ ** 2006-07-17 by Arthur David Olson. */ -static char elsieid[] = "@(#)zic.c 8.25"; - +#include "version.h" #include "private.h" #include "locale.h" #include "tzfile.h" @@ -111,17 +110,8 @@ static int addtype(long gmtoff, const char * abbr, int isdst, 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 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); @@ -132,32 +122,18 @@ 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(char * result, long offset); -static int stringrule(char * result, const struct rule * rp, - long dstoff, long gmtoff); -static void stringzone(char * result, - 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 writezone(const char * name, const char * string); static int yearistype(int year, const char * type); static int charcnt; @@ -170,9 +146,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; @@ -378,9 +352,8 @@ static char roll[TZ_MAX_LEAPS]; ** Memory allocation. */ -static char * -memcheck(ptr) -char * const ptr; +static ATTRIBUTE_PURE void * +memcheck(void *const ptr) { if (ptr == NULL) { const char *e = strerror(errno); @@ -392,8 +365,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))) @@ -402,11 +375,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; @@ -415,16 +385,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 @@ -441,15 +408,14 @@ const |
