summaryrefslogtreecommitdiffstats
path: root/icu/src/main/native
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:57 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:57 -0800
commitb7926325a1c1a370c84c81db80372f59af240a53 (patch)
treeb1d0214be443ea674d0ded8c502a8e074e50bdd2 /icu/src/main/native
parent687f18b91f4a0a728a027579110953ee729adcb8 (diff)
downloadlibcore-b7926325a1c1a370c84c81db80372f59af240a53.zip
libcore-b7926325a1c1a370c84c81db80372f59af240a53.tar.gz
libcore-b7926325a1c1a370c84c81db80372f59af240a53.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'icu/src/main/native')
-rw-r--r--icu/src/main/native/ConverterInterface.c16
-rw-r--r--icu/src/main/native/ResourceInterface.cpp26
2 files changed, 34 insertions, 8 deletions
diff --git a/icu/src/main/native/ConverterInterface.c b/icu/src/main/native/ConverterInterface.c
index 3996146..d7f5c9b 100644
--- a/icu/src/main/native/ConverterInterface.c
+++ b/icu/src/main/native/ConverterInterface.c
@@ -805,9 +805,13 @@ static jobjectArray getAvailable(JNIEnv *env, jclass jClass) {
}
printf("canonical name for %s\n", canonicalName);
-#endif
- (*env)->SetObjectArrayElement(env,ret,i,(*env)->NewStringUTF(env,canonicalName));
- /*printf("canonical name : %s at %i\n", name,i); */
+#endif
+ // BEGIN android-changed
+ jstring canonName = (*env)->NewStringUTF(env,canonicalName);
+ (*env)->SetObjectArrayElement(env,ret,i,canonName);
+ (*env)->DeleteLocalRef(env, canonName);
+ // END android-changed
+ /*printf("canonical name : %s at %i\n", name,i); */
canonicalName[0]='\0';/* nul terminate */
}
return (ret);
@@ -881,7 +885,11 @@ static jobjectArray getAliases(JNIEnv *env, jclass jClass, jstring enc) {
(*env)->FindClass(env,"java/lang/String"),
(*env)->NewStringUTF(env,""));
for(;--j>=0;) {
- (*env)->SetObjectArrayElement(env,ret,j,(*env)->NewStringUTF(env,aliasArray[j]));
+ // BEGIN android-changed
+ jstring alias = (*env)->NewStringUTF(env, aliasArray[j]);
+ (*env)->SetObjectArrayElement(env, ret, j, alias);
+ (*env)->DeleteLocalRef(env, alias);
+ // END android-changed
}
}
}
diff --git a/icu/src/main/native/ResourceInterface.cpp b/icu/src/main/native/ResourceInterface.cpp
index 562f480..5f9d442 100644
--- a/icu/src/main/native/ResourceInterface.cpp
+++ b/icu/src/main/native/ResourceInterface.cpp
@@ -157,16 +157,30 @@ static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz,
ures_close(currency);
ures_close(currencyMap);
ures_close(supplData);
+ return env->NewStringUTF("None");
+ }
+
+ // check if there is a to date. If there is, the currency isn't used anymore.
+ UResourceBundle *currencyTo = ures_getByKey(currencyElem, "to", NULL, &status);
+ if(!U_FAILURE(status)) {
+ // return and let the ResourceBundle throw an exception
+ ures_close(currencyElem);
+ ures_close(currency);
+ ures_close(currencyMap);
+ ures_close(supplData);
return NULL;
}
+ status = U_ZERO_ERROR;
+ ures_close(currencyTo);
UResourceBundle *currencyId = ures_getByKey(currencyElem, "id", NULL, &status);
if(U_FAILURE(status)) {
+ // No id defined for this country
ures_close(currencyElem);
ures_close(currency);
ures_close(currencyMap);
ures_close(supplData);
- return NULL;
+ return env->NewStringUTF("None");
}
int length;
@@ -177,7 +191,7 @@ static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz,
ures_close(currency);
ures_close(currencyMap);
ures_close(supplData);
- return NULL;
+ return env->NewStringUTF("None");
}
ures_close(currencyId);
@@ -187,7 +201,7 @@ static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz,
ures_close(supplData);
if(length == 0) {
- return NULL;
+ return env->NewStringUTF("None");
}
return env->NewString(id, length);
}
@@ -1227,7 +1241,11 @@ endOfCalendar:
counter++;
// integer pattern derived from number pattern
- decSepOffset = u_strcspn(pattern, (jchar *)".\0");
+ // We need to convert a C string literal to a UChar string for u_strcspn.
+ static const char c_decSep[] = ".";
+ UChar decSep[sizeof(c_decSep)];
+ u_charsToUChars(c_decSep, decSep, sizeof(c_decSep));
+ decSepOffset = u_strcspn(pattern, decSep);
tmpPattern = (jchar *) malloc((decSepOffset + 1) * sizeof(jchar));
u_strncpy(tmpPattern, pattern, decSepOffset);
integerPattern = env->NewString(tmpPattern, decSepOffset);