Print this page
6869 Update zdump to better-handle POSIX timezones
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zic/zic.c
          +++ new/usr/src/cmd/zic/zic.c
   1    1  /*
   2    2   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
   3    3   * Use is subject to license terms.
   4    4   */
   5      -#pragma ident   "%Z%%M% %I%     %E% SMI"
   6    5  
   7      -static char     elsieid[] = "@(#)zic.c  7.128.1";
        6 +static char    elsieid[] = "@(#)zic.c  7.128.1";
   8    7  
   9    8  /*
  10    9   * #define      LEAPSECOND_SUPPORT
  11   10   */
  12   11  
  13   12  /*
  14   13   * Regardless of the type of time_t, we do our work using this type.
  15   14   */
  16   15  
  17   16  typedef int     zic_t;
↓ open down ↓ 2205 lines elided ↑ open up ↑
2223 2222                  return (min_time);
2224 2223          if (dayoff < min_time / SECSPERDAY)
2225 2224                  return (min_time);
2226 2225          if (dayoff > max_time / SECSPERDAY)
2227 2226                  return (max_time);
2228 2227          t = (zic_t)dayoff * SECSPERDAY;
2229 2228          return (tadd(t, rp->r_tod));
2230 2229  }
2231 2230  
2232 2231  static void
2233      -newabbr(string)
2234      -const char * const      string;
     2232 +newabbr(const char * const string)
2235 2233  {
2236 2234          register int    i;
2237 2235  
2238 2236          if (strcmp(string, GRANDPARENTED) != 0) {
2239 2237                  register const char *cp;
2240 2238                  register char *wp;
2241 2239  
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 2240                  cp = string;
2247 2241                  wp = NULL;
2248      -                while (isascii(*cp) && isalpha(*cp))
     2242 +                while (isalpha(*cp) || ('0' <= *cp && *cp <= '9') ||
     2243 +                    *cp == '-' || *cp == '+') {
2249 2244                          ++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 "
     2245 +                }
     2246 +                if (noise && cp - string < 3)
     2247 +                        wp = gettext(("time zone abbreviation has less than 3 "
2255 2248                              "alphabetics"));
2256      -                if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
     2249 +                if (wp == NULL && cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
2257 2250                          wp = gettext(("time zone abbreviation has too many "
2258      -                            "alphabetics"));
     2251 +                            "characters"));
2259 2252                  if (wp == NULL && (*cp == '+' || *cp == '-')) {
2260 2253                          ++cp;
2261 2254                          if (isascii(*cp) && isdigit(*cp))
2262 2255                                  if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
2263 2256                                          ++cp;
2264 2257                  }
2265      -                if (*cp != '\0')
     2258 +                if (wp == NULL && *cp != '\0')
2266 2259                          wp = gettext("time zone abbreviation differs from "
2267 2260                              "POSIX standard");
2268 2261                  if (wp != NULL) {
2269 2262                          wp = ecpyalloc(wp);
2270 2263                          wp = ecatalloc(wp, " (");
2271 2264                          wp = ecatalloc(wp, string);
2272 2265                          wp = ecatalloc(wp, ")");
2273 2266                          warning(wp);
2274 2267                          ifree(wp);
2275 2268                  }
↓ open down ↓ 67 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX