Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: third_party/icu/patches/linuxtz3.patch

Issue 3598015: Fix the default timezone detection in ICU.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/icu/README.chromium ('k') | third_party/icu/source/common/putil.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/icu/patches/linuxtz3.patch
===================================================================
--- third_party/icu/patches/linuxtz3.patch (revision 0)
+++ third_party/icu/patches/linuxtz3.patch (revision 0)
@@ -0,0 +1,74 @@
+Index: source/common/putil.c
+===================================================================
+--- source/common/putil.c (revision 60495)
++++ source/common/putil.c (working copy)
+@@ -661,6 +661,26 @@
+ || uprv_strcmp(id, "CST6CDT") == 0
+ || uprv_strcmp(id, "EST5EDT") == 0);
+ }
++
++/* On some Unix-like OS, 'posix' subdirectory in
++ /usr/share/zoneinfo replicates the top-level contents. 'right'
++ subdirectory has the same set of files, but individual files
++ are different from those in the top-level directory or 'posix'
++ because 'right' has files for TAI (Int'l Atomic Time) while 'posix'
++ has files for UTC.
++ When the first match for /etc/localtime is in either of them
++ (usually in posix because 'right' has different file contents),
++ or TZ environment variable points to one of them, createTimeZone
++ fails because, say, 'posix/America/New_York' is not an Olson
++ timezone id ('America/New_York' is). So, we have to remove
++ 'posix/' and 'right/' at the beginning. */
++static void removeZoneIDPrefix(const char** id) {
Evan Martin 2010/10/08 22:00:14 "skip" might be a better verb than "remove", as th
++ if (uprv_strncmp(*id, "posix/", 6) == 0
++ || uprv_strncmp(*id, "right/", 6) == 0)
++ {
++ *id += 6;
++ }
++}
+ #endif
+
+ #if defined(U_TZNAME) && !defined(U_WINDOWS)
+@@ -869,11 +889,12 @@
+
+ /* Check each entry in the directory. */
+ while((dirEntry = readdir(dirp)) != NULL) {
+- if (uprv_strcmp(dirEntry->d_name, SKIP1) != 0 && uprv_strcmp(dirEntry->d_name, SKIP2) != 0) {
++ const char* dirName = dirEntry->d_name;
++ if (uprv_strcmp(dirName, SKIP1) != 0 && uprv_strcmp(dirName, SKIP2) != 0) {
+ /* Create a newpath with the new entry to test each entry in the directory. */
+ char newpath[MAX_PATH_SIZE];
+ uprv_strcpy(newpath, curpath);
+- uprv_strcat(newpath, dirEntry->d_name);
++ uprv_strcat(newpath, dirName);
+
+ if ((subDirp = opendir(newpath)) != NULL) {
+ /* If this new path is a directory, make a recursive call with the newpath. */
+@@ -890,9 +911,11 @@
+ */
+ if (result != NULL)
+ break;
+- } else if (uprv_strcmp(TZFILE_SKIP, dirEntry->d_name) != 0 && uprv_strcmp(TZFILE_SKIP2, dirEntry->d_name) != 0) {
++ } else if (uprv_strcmp(TZFILE_SKIP, dirName) != 0 && uprv_strcmp(TZFILE_SKIP2, dirName) != 0) {
+ if(compareBinaryFiles(TZDEFAULT, newpath, tzInfo)) {
+- uprv_strcpy(SEARCH_TZFILE_RESULT, newpath + (sizeof(TZZONEINFO) - 1));
++ const char* zoneid = newpath + (sizeof(TZZONEINFO)) - 1;
++ removeZoneIDPrefix(&zoneid);
++ uprv_strcpy(SEARCH_TZFILE_RESULT, zoneid);
+ result = SEARCH_TZFILE_RESULT;
+ /* Get out after the first one found. */
+ break;
+@@ -931,12 +954,7 @@
+ if (tzid != NULL && isValidOlsonID(tzid))
+ {
+ /* This might be a good Olson ID. */
+- if (uprv_strncmp(tzid, "posix/", 6) == 0
+- || uprv_strncmp(tzid, "right/", 6) == 0)
+- {
+- /* Remove the posix/ or right/ prefix. */
+- tzid += 6;
+- }
++ removeZoneIDPrefix(&tzid);
+ return tzid;
+ }
+ /* else U_TZNAME will give a better result. */
« no previous file with comments | « third_party/icu/README.chromium ('k') | third_party/icu/source/common/putil.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698