< prev index next >
src/java.base/windows/native/libjava/TimeZone_md.c
Print this page
rev 50439 : 8204539: improve error messages in matchJavaTZ [windows]
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -435,10 +435,12 @@
char *javaTZName = NULL;
char *items[TZ_NITEMS];
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) {
return NULL;
}
@@ -470,21 +472,27 @@
for (itemIndex = 0; itemIndex < TZ_NITEMS; itemIndex++) {
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 character \0 found";
+ offset = (int)(idx - lineBuffer);
goto illegal_format;
}
*idx++ = '\0';
start = idx;
}
if (*idx != '\n') {
+ errorMessage = "illegal non-newline character found";
+ offset = (int)(idx - lineBuffer);
goto illegal_format;
}
if (noMapID || strcmp(mapID, items[TZ_MAPID]) == 0) {
/*
@@ -514,11 +522,12 @@
return javaTZName;
illegal_format:
(void) fclose(fp);
- jio_fprintf(stderr, "tzmappings: Illegal format at line %d.\n", line);
+ jio_fprintf(stderr, "tzmappings: Illegal format at line %d (%s at offset %d, file: %s).\n",
+ line, message, offset, mapFileName);
return NULL;
}
/*
* Detects the platform time zone which maps to a Java time zone ID.
< prev index next >