Print this page
XXXX Update zdump to better-handle POSIX timezones

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zdump/zdump.c
          +++ new/usr/src/cmd/zdump/zdump.c
↓ open down ↓ 134 lines elided ↑ open up ↑
 135  135                          (void) fprintf(stderr, " -> ");
 136  136                          (void) fprintf(stderr, tformat(), t);
 137  137                          (void) fprintf(stderr, "\n");
 138  138                  }
 139  139          }
 140  140          return (tmp);
 141  141  }
 142  142  #endif /* !defined TYPECHECK */
 143  143  
 144  144  static void
 145      -abbrok(abbrp, zone)
 146      -const char * const      abbrp;
 147      -const char * const      zone;
      145 +abbrok(const char * const abbrp, const char * const zone)
 148  146  {
 149  147          register const char *cp;
 150  148          int error = 0;
 151  149  
 152  150          if (warned)
 153  151                  return;
 154  152          cp = abbrp;
 155      -        while (isascii(*cp) && isalpha((unsigned char)*cp))
      153 +        while (isalpha(*cp) || isdigit(*cp) || *cp == '-' || *cp == '+')
 156  154                  ++cp;
 157  155          (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      -                 */
      156 +        if (cp - abbrp < 3) {
 166  157                  (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  158                      "abbreviation \"%s\" has fewer than 3 alphabetics\n"),
 173  159                      progname, zone, abbrp);
 174  160                  error = 1;
 175  161          } else if (cp - abbrp > 6) {
 176  162                  (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
 177      -                    "abbreviation \"%s\" has more than 6 alphabetics\n"),
      163 +                    "abbreviation \"%s\" has more than 6 characters\n"),
 178  164                      progname, zone, abbrp);
 179  165                  error = 1;
      166 +        } else if (*cp != '\0') {
      167 +                (void) fprintf(stderr, gettext("%s: warning: zone \"%s\" "
      168 +                    "abbreviation \"%s\" has characters other than "
      169 +                    "alphanumerics\n"), progname, zone, abbrp);
      170 +                error = 1;
 180  171          }
 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  172          if (error)
 194  173                  warned = TRUE;
 195  174  }
 196  175  
 197  176  int
 198  177  main(argc, argv)
 199  178  int     argc;
 200  179  char    *argv[];
 201  180  {
 202  181          register int            i;
↓ open down ↓ 462 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX