zdump.c (46c599340f187db577b9212ab18022f3c7380c68) | zdump.c (a979394afeb5c20fc58c5f5b005d51eb8f92f666) |
---|---|
1/* Dump time zone data in a textual format. */ 2 3/* 4** This file is in the public domain, so clarified as of 5** 2009-05-17 by Arthur David Olson. 6*/ 7 8#include "version.h" --- 75 unchanged lines hidden (view full) --- 84 ? (((time_t) 1 << atime_shift) - 1 + ((time_t) 1 << atime_shift)) 85 : -1); 86static size_t longest; 87static char const *progname; 88static bool warned; 89static bool errout; 90 91static char const *abbr(struct tm const *); | 1/* Dump time zone data in a textual format. */ 2 3/* 4** This file is in the public domain, so clarified as of 5** 2009-05-17 by Arthur David Olson. 6*/ 7 8#include "version.h" --- 75 unchanged lines hidden (view full) --- 84 ? (((time_t) 1 << atime_shift) - 1 + ((time_t) 1 << atime_shift)) 85 : -1); 86static size_t longest; 87static char const *progname; 88static bool warned; 89static bool errout; 90 91static char const *abbr(struct tm const *); |
92ATTRIBUTE_REPRODUCIBLE static intmax_t delta(struct tm *, struct tm *); | 92static intmax_t delta(struct tm *, struct tm *); |
93static void dumptime(struct tm const *); 94static time_t hunt(timezone_t, time_t, time_t, bool); 95static void show(timezone_t, char *, time_t, bool); 96static void showextrema(timezone_t, char *, time_t, struct tm *, time_t); 97static void showtrans(char const *, struct tm const *, time_t, char const *, 98 char const *); 99static const char *tformat(void); | 93static void dumptime(struct tm const *); 94static time_t hunt(timezone_t, time_t, time_t, bool); 95static void show(timezone_t, char *, time_t, bool); 96static void showextrema(timezone_t, char *, time_t, struct tm *, time_t); 97static void showtrans(char const *, struct tm const *, time_t, char const *, 98 char const *); 99static const char *tformat(void); |
100ATTRIBUTE_REPRODUCIBLE static time_t yeartot(intmax_t); | 100ATTRIBUTE_PURE_114833 static time_t yeartot(intmax_t); |
101 102/* Is C an ASCII digit? */ 103static bool 104is_digit(char c) 105{ 106 return '0' <= c && c <= '9'; 107} 108 --- 20 unchanged lines hidden (view full) --- 129size_overflow(void) 130{ 131 fprintf(stderr, _("%s: size overflow\n"), progname); 132 exit(EXIT_FAILURE); 133} 134 135/* Return A + B, exiting if the result would overflow either ptrdiff_t 136 or size_t. A and B are both nonnegative. */ | 101 102/* Is C an ASCII digit? */ 103static bool 104is_digit(char c) 105{ 106 return '0' <= c && c <= '9'; 107} 108 --- 20 unchanged lines hidden (view full) --- 129size_overflow(void) 130{ 131 fprintf(stderr, _("%s: size overflow\n"), progname); 132 exit(EXIT_FAILURE); 133} 134 135/* Return A + B, exiting if the result would overflow either ptrdiff_t 136 or size_t. A and B are both nonnegative. */ |
137ATTRIBUTE_REPRODUCIBLE static ptrdiff_t | 137ATTRIBUTE_PURE_114833 static ptrdiff_t |
138sumsize(ptrdiff_t a, ptrdiff_t b) 139{ 140#ifdef ckd_add 141 ptrdiff_t sum; 142 if (!ckd_add(&sum, a, b) && sum <= INDEX_MAX) 143 return sum; 144#else 145 if (a <= INDEX_MAX && b <= INDEX_MAX - a) --- 11 unchanged lines hidden (view full) --- 157 size_t len = strlen(str); 158 if (len < INDEX_MAX) 159 return len + 1; 160 size_overflow(); 161} 162 163/* Return a pointer to a newly allocated buffer of size SIZE, exiting 164 on failure. SIZE should be positive. */ | 138sumsize(ptrdiff_t a, ptrdiff_t b) 139{ 140#ifdef ckd_add 141 ptrdiff_t sum; 142 if (!ckd_add(&sum, a, b) && sum <= INDEX_MAX) 143 return sum; 144#else 145 if (a <= INDEX_MAX && b <= INDEX_MAX - a) --- 11 unchanged lines hidden (view full) --- 157 size_t len = strlen(str); 158 if (len < INDEX_MAX) 159 return len + 1; 160 size_overflow(); 161} 162 163/* Return a pointer to a newly allocated buffer of size SIZE, exiting 164 on failure. SIZE should be positive. */ |
165ATTRIBUTE_MALLOC static void * | 165static void * |
166xmalloc(ptrdiff_t size) 167{ 168 void *p = malloc(size); 169 if (!p) { 170 fprintf(stderr, _("%s: Memory exhausted\n"), progname); 171 exit(EXIT_FAILURE); 172 } 173 return p; --- 755 unchanged lines hidden (view full) --- 929} 930 931#if HAVE_SNPRINTF 932# define my_snprintf snprintf 933#else 934# include <stdarg.h> 935 936/* A substitute for snprintf that is good enough for zdump. */ | 166xmalloc(ptrdiff_t size) 167{ 168 void *p = malloc(size); 169 if (!p) { 170 fprintf(stderr, _("%s: Memory exhausted\n"), progname); 171 exit(EXIT_FAILURE); 172 } 173 return p; --- 755 unchanged lines hidden (view full) --- 929} 930 931#if HAVE_SNPRINTF 932# define my_snprintf snprintf 933#else 934# include <stdarg.h> 935 936/* A substitute for snprintf that is good enough for zdump. */ |
937ATTRIBUTE_FORMAT((printf, 3, 4)) static int | 937static int |
938my_snprintf(char *s, size_t size, char const *format, ...) 939{ 940 int n; 941 va_list args; 942 char const *arg; 943 size_t arglen, slen; 944 char buf[1024]; 945 va_start(args, format); --- 324 unchanged lines hidden --- | 938my_snprintf(char *s, size_t size, char const *format, ...) 939{ 940 int n; 941 va_list args; 942 char const *arg; 943 size_t arglen, slen; 944 char buf[1024]; 945 va_start(args, format); --- 324 unchanged lines hidden --- |