]> granicus.if.org Git - icu/commitdiff
ICU-9408 minor changes in indentation, comments and if statements
authorDebabrata Sengupta <dsengup@svn.icu-project.org>
Thu, 12 Jul 2012 21:38:53 +0000 (21:38 +0000)
committerDebabrata Sengupta <dsengup@svn.icu-project.org>
Thu, 12 Jul 2012 21:38:53 +0000 (21:38 +0000)
X-SVN-Rev: 32039

icu4c/source/common/wintz.c

index 595919437828aaa78bb44ac0194cac4e714ccfa4..4b22ca27dd12f6e261a612b14dd613a6fc3e4206 100644 (file)
@@ -252,12 +252,13 @@ uprv_detectWindowsTimeZone() {
     char* icuid = NULL;
     UChar apiStd[MAX_LENGTH_ID];
     char apiStdName[MAX_LENGTH_ID];
-       char regStdName[MAX_LENGTH_ID];
+    char regStdName[MAX_LENGTH_ID];
     char tmpid[MAX_LENGTH_ID];
     int32_t apiStdLength = 0;
     int32_t len;
-       int id;
-       char ISOcode[3]; //2 letter iso code 
+    int id;
+    int errorCode;
+    char ISOcode[3]; //2 letter iso code 
 
     LONG result;
     TZI tziKey;
@@ -283,9 +284,9 @@ uprv_detectWindowsTimeZone() {
     u_austrncpy(apiStdName, apiStd, apiStdLength);
 
     tmpid[0] = 0;
-               
-       id = GetUserGeoID(GEOCLASS_NATION);
-       GetGeoInfo(id,GEO_ISO2,ISOcode,3,0);
+
+    id = GetUserGeoID(GEOCLASS_NATION);
+    errorCode = GetGeoInfo(id,GEO_ISO2,ISOcode,3,0);
 
     bundle = ures_openDirect(NULL, "windowsZones", &status);
     ures_getByKey(bundle, "mapTimezones", bundle, &status);
@@ -309,13 +310,15 @@ uprv_detectWindowsTimeZone() {
             tziKey.daylightBias = tziReg.daylightBias;
 
             if (uprv_memcmp((char *)&tziKey, (char*)&tziReg, sizeof(tziKey)) == 0) {
-                               const UChar* icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
-
-                               if (icuTZ==NULL) {
-                                       //fallback to default "001" and reset status
-                                       status = U_ZERO_ERROR;
-                                       icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
-                               }
+            const UChar* icuTZ;
+                if (errorCode != 0) {
+                    icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
+                }
+                if (errorCode==0 || icuTZ==NULL) {
+                    //fallback to default "001" and reset status
+                    status = U_ZERO_ERROR;
+                    icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
+                }
 
                 if (U_SUCCESS(status)) {
                     /* Get the standard name from the registry key to compare with
@@ -333,15 +336,12 @@ uprv_detectWindowsTimeZone() {
                      * the current time zone information)
                      */
                     if (idFound || tmpid[0] == 0) {
-                                               //if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space)
-                                               int index=0;
-                                               while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
-                                                       tmpid[index++]=*icuTZ++;
-                                               }
-                                               tmpid[index]='\0';                                      
-
-                        //uprv_memset(tmpid, 0, sizeof(tmpid));
-                        //u_austrncpy(tmpid, icuTZ, len);
+                        //if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space)
+                        int index=0;
+                        while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
+                            tmpid[index++]=*icuTZ++;
+                        }
+                        tmpid[index]='\0';
                     }
                 }
             }
@@ -365,7 +365,7 @@ uprv_detectWindowsTimeZone() {
 
     ures_close(bundle);
     
-       return icuid;
+    return icuid;
 }
 
 #endif /* U_PLATFORM_HAS_WIN32_API */