1 /*
2 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5 #pragma ident "%Z%%M% %I% %E% SMI"
6
7 static char elsieid[] = "@(#)zic.c 7.128.1";
8
9 /*
10 * #define LEAPSECOND_SUPPORT
11 */
12
13 /*
14 * Regardless of the type of time_t, we do our work using this type.
15 */
16
17 typedef int zic_t;
18
19 #include "private.h"
20 #include <tzfile.h> /* this is in system headers at Sun */
21
22 #include <sys/stat.h> /* for umask manifest constants */
23 #include <ctype.h>
24 #include <locale.h>
25 #include <stdlib.h> /* for getopt */
2213 --i;
2214 }
2215 if (i < 0 || i >= len_months[isleap(y)][m]) {
2216 if (noise)
2217 warning(gettext("rule goes past start/end of "
2218 "month--will not work with pre-2004 "
2219 "versions of zic"));
2220 }
2221 }
2222 if (dayoff < 0 && !TYPE_SIGNED(zic_t))
2223 return (min_time);
2224 if (dayoff < min_time / SECSPERDAY)
2225 return (min_time);
2226 if (dayoff > max_time / SECSPERDAY)
2227 return (max_time);
2228 t = (zic_t)dayoff * SECSPERDAY;
2229 return (tadd(t, rp->r_tod));
2230 }
2231
2232 static void
2233 newabbr(string)
2234 const char * const string;
2235 {
2236 register int i;
2237
2238 if (strcmp(string, GRANDPARENTED) != 0) {
2239 register const char *cp;
2240 register char *wp;
2241
2242 /*
2243 * Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics
2244 * optionally followed by a + or - and a number from 1 to 14.
2245 */
2246 cp = string;
2247 wp = NULL;
2248 while (isascii(*cp) && isalpha(*cp))
2249 ++cp;
2250 if (cp - string == 0)
2251 wp = gettext(("time zone abbreviation lacks "
2252 "alphabetic at start"));
2253 if (noise && cp - string > 3)
2254 wp = gettext(("time zone abbreviation has more than 3 "
2255 "alphabetics"));
2256 if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
2257 wp = gettext(("time zone abbreviation has too many "
2258 "alphabetics"));
2259 if (wp == NULL && (*cp == '+' || *cp == '-')) {
2260 ++cp;
2261 if (isascii(*cp) && isdigit(*cp))
2262 if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
2263 ++cp;
2264 }
2265 if (*cp != '\0')
2266 wp = gettext("time zone abbreviation differs from "
2267 "POSIX standard");
2268 if (wp != NULL) {
2269 wp = ecpyalloc(wp);
2270 wp = ecatalloc(wp, " (");
2271 wp = ecatalloc(wp, string);
2272 wp = ecatalloc(wp, ")");
2273 warning(wp);
2274 ifree(wp);
2275 }
2276 }
2277 i = strlen(string) + 1;
2278 if (charcnt + i > TZ_MAX_CHARS) {
2279 error(gettext("too many, or too long, time zone "
2280 "abbreviations"));
2281 exit(EXIT_FAILURE);
2282 }
2283 (void) strcpy(&chars[charcnt], string);
2284 charcnt += eitol(i);
2285 }
|
1 /*
2 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 static char elsieid[] = "@(#)zic.c 7.128.1";
7
8 /*
9 * #define LEAPSECOND_SUPPORT
10 */
11
12 /*
13 * Regardless of the type of time_t, we do our work using this type.
14 */
15
16 typedef int zic_t;
17
18 #include "private.h"
19 #include <tzfile.h> /* this is in system headers at Sun */
20
21 #include <sys/stat.h> /* for umask manifest constants */
22 #include <ctype.h>
23 #include <locale.h>
24 #include <stdlib.h> /* for getopt */
2212 --i;
2213 }
2214 if (i < 0 || i >= len_months[isleap(y)][m]) {
2215 if (noise)
2216 warning(gettext("rule goes past start/end of "
2217 "month--will not work with pre-2004 "
2218 "versions of zic"));
2219 }
2220 }
2221 if (dayoff < 0 && !TYPE_SIGNED(zic_t))
2222 return (min_time);
2223 if (dayoff < min_time / SECSPERDAY)
2224 return (min_time);
2225 if (dayoff > max_time / SECSPERDAY)
2226 return (max_time);
2227 t = (zic_t)dayoff * SECSPERDAY;
2228 return (tadd(t, rp->r_tod));
2229 }
2230
2231 static void
2232 newabbr(const char * const string)
2233 {
2234 register int i;
2235
2236 if (strcmp(string, GRANDPARENTED) != 0) {
2237 register const char *cp;
2238 register char *wp;
2239
2240 cp = string;
2241 wp = NULL;
2242 while (isalpha(*cp) || ('0' <= *cp && *cp <= '9') ||
2243 *cp == '-' || *cp == '+') {
2244 ++cp;
2245 }
2246 if (noise && cp - string < 3)
2247 wp = gettext(("time zone abbreviation has less than 3 "
2248 "alphabetics"));
2249 if (wp == NULL && cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
2250 wp = gettext(("time zone abbreviation has too many "
2251 "characters"));
2252 if (wp == NULL && (*cp == '+' || *cp == '-')) {
2253 ++cp;
2254 if (isascii(*cp) && isdigit(*cp))
2255 if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
2256 ++cp;
2257 }
2258 if (wp == NULL && *cp != '\0')
2259 wp = gettext("time zone abbreviation differs from "
2260 "POSIX standard");
2261 if (wp != NULL) {
2262 wp = ecpyalloc(wp);
2263 wp = ecatalloc(wp, " (");
2264 wp = ecatalloc(wp, string);
2265 wp = ecatalloc(wp, ")");
2266 warning(wp);
2267 ifree(wp);
2268 }
2269 }
2270 i = strlen(string) + 1;
2271 if (charcnt + i > TZ_MAX_CHARS) {
2272 error(gettext("too many, or too long, time zone "
2273 "abbreviations"));
2274 exit(EXIT_FAILURE);
2275 }
2276 (void) strcpy(&chars[charcnt], string);
2277 charcnt += eitol(i);
2278 }
|