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/zdump/zdump.c
          +++ new/usr/src/cmd/zdump/zdump.c
   1    1  /*
   2    2   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
   3    3   * Use is subject to license terms.
   4    4   */
   5    5  
   6      -#pragma ident   "%Z%%M% %I%     %E% SMI"
   7      -
   8    6  /*
   9    7   * zdump 7.24
  10    8   * Taken from elsie.nci.nih.gov to replace the existing Solaris zdump,
  11    9   * which was based on an earlier version of the elsie code.
  12   10   *
  13   11   * For zdump 7.24, the following changes were made to the elsie code:
  14   12   *   locale/textdomain/messages to match existing Solaris style.
  15   13   *   Solaris verbose mode is documented to display the current time first.
  16   14   *   cstyle cleaned code.
  17   15   *   removed old locale/textdomain code.
↓ open down ↓ 117 lines elided ↑ open up ↑
 135  133                          (void) fprintf(stderr, " -> ");
 136  134                          (void) fprintf(stderr, tformat(), t);
 137  135                          (void) fprintf(stderr, "\n");
 138  136                  }
 139  137          }
 140  138          return (tmp);
 141  139  }
 142  140  #endif /* !defined TYPECHECK */
 143  141  
 144  142  static void
 145      -abbrok(abbrp, zone)
 146      -const char * const      abbrp;
 147      -const char * const      zone;
      143 +abbrok(const char * const abbrp, const char * const zone)
 148  144  {
 149  145          register const char *cp;
 150  146          int error = 0;
 151  147  
 152  148          if (warned)
 153  149                  return;
 154  150          cp = abbrp;
 155      -        while (isascii(*cp) && isalpha((unsigned char)*cp))
      151 +        while (isalpha(*cp) || isdigit(*cp) || *cp == '-' || *cp == '+')
 156  152                  ++cp;
 157  153          (void) fflush(stdout);
 158      -        if (cp - abbrp == 0) {
 159      -                /*
 160      -                 * TRANSLATION_NOTE
 161      -                 * The first %s prints for the program name (zdump),
 162      -                 * the second %s prints the timezone name, the third
 163      -                 * %s prints the timezone abbreviation (tzname[0] or
 164      -                 * tzname[1]).
 165      -                 */
      154 +        if (cp - abbrp < 3) {
 166  155                  (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
 167      -                    "abbreviation \"%s\" lacks alphabetic at start\n"),
 168      -                    progname, zone, abbrp);
 169      -                error = 1;
 170      -        } else if (cp - abbrp < 3) {
 171      -                (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
 172  156                      "abbreviation \"%s\" has fewer than 3 alphabetics\n"),
 173  157                      progname, zone, abbrp);
 174  158                  error = 1;
 175  159          } else if (cp - abbrp > 6) {
 176  160                  (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
 177      -                    "abbreviation \"%s\" has more than 6 alphabetics\n"),
      161 +                    "abbreviation \"%s\" has more than 6 characters\n"),
 178  162                      progname, zone, abbrp);
 179  163                  error = 1;
      164 +        } else if (*cp != '\0') {
      165 +                (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
      166 +                    "abbreviation \"%s\" has characters other than "
      167 +                    "alphanumerics\n"), progname, zone, abbrp);
      168 +                error = 1;
 180  169          }
 181      -        if (error == 0 && (*cp == '+' || *cp == '-')) {
 182      -                ++cp;
 183      -                if (isascii(*cp) && isdigit((unsigned char)*cp))
 184      -                        if (*cp++ == '1' && *cp >= '0' && *cp <= '4')
 185      -                                ++cp;
 186      -                if (*cp != '\0') {
 187      -                        (void) fprintf(stderr, gettext("%s: warning: "
 188      -                            "zone \"%s\" abbreviation \"%s\" differs from "
 189      -                            "POSIX standard\n"), progname, zone, abbrp);
 190      -                        error = 1;
 191      -                }
 192      -        }
 193  170          if (error)
 194  171                  warned = TRUE;
 195  172  }
 196  173  
 197  174  int
 198  175  main(argc, argv)
 199  176  int     argc;
 200  177  char    *argv[];
 201  178  {
 202  179          register int            i;
↓ open down ↓ 462 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX