changeset 50867:102ae98c917c

8204539: improve error messages in matchJavaTZ [windows] Reviewed-by: coffeys, clanger, goetz
author mbaesken
date Fri, 08 Jun 2018 13:06:08 +0200
parents 929cd9246fc9
children 7b004b4548d8
files src/java.base/windows/native/libjava/TimeZone_md.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/windows/native/libjava/TimeZone_md.c	Fri Jun 08 11:41:43 2018 +0200
+++ b/src/java.base/windows/native/libjava/TimeZone_md.c	Fri Jun 08 13:06:08 2018 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -437,6 +437,8 @@
     char *mapFileName;
     char lineBuffer[MAX_ZONE_CHAR * 4];
     int noMapID = *mapID == '\0';       /* no mapID on Vista and later */
+    int offset = 0;
+    const char* errorMessage = "unknown error";
 
     mapFileName = malloc(strlen(java_home_dir) + strlen(MAPPINGS_FILE) + 1);
     if (mapFileName == NULL) {
@@ -472,10 +474,14 @@
             items[itemIndex] = start;
             while (*idx && *idx != ':') {
                 if (++idx >= endp) {
+                    errorMessage = "premature end of line";
+                    offset = (int)(idx - lineBuffer);
                     goto illegal_format;
                 }
             }
             if (*idx == '\0') {
+                errorMessage = "illegal null character found";
+                offset = (int)(idx - lineBuffer);
                 goto illegal_format;
             }
             *idx++ = '\0';
@@ -483,6 +489,8 @@
         }
 
         if (*idx != '\n') {
+            errorMessage = "illegal non-newline character found";
+            offset = (int)(idx - lineBuffer);
             goto illegal_format;
         }
 
@@ -516,7 +524,8 @@
 
  illegal_format:
     (void) fclose(fp);
-    jio_fprintf(stderr, "tzmappings: Illegal format at line %d.\n", line);
+    jio_fprintf(stderr, "Illegal format in tzmappings file: %s at line %d, offset %d.\n",
+                errorMessage, line, offset);
     return NULL;
 }