提交 35ba97e3 编写于 作者: N naoto

8033370: [parfait] warning from b126 for...

8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
Reviewed-by: msheppar
上级 63607e11
...@@ -287,8 +287,6 @@ SUNWprivate_1.1 { ...@@ -287,8 +287,6 @@ SUNWprivate_1.1 {
# Java_sun_misc_VM_unsuspendSomeThreads; threads.c # Java_sun_misc_VM_unsuspendSomeThreads; threads.c
# Java_sun_misc_VM_unsuspendThreads; threads.c # Java_sun_misc_VM_unsuspendThreads; threads.c
Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern;
# Outcalls from libjvm done using dlsym(). # Outcalls from libjvm done using dlsym().
VerifyClassCodes; VerifyClassCodes;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
#include "jni_util.h"
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include <stdio.h> #include <stdio.h>
...@@ -63,6 +64,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -63,6 +64,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
localeString = getMacOSXLocale(posixCat); localeString = getMacOSXLocale(posixCat);
if (localeString == NULL) { if (localeString == NULL) {
localeString = getPosixLocale(posixCat); localeString = getPosixLocale(posixCat);
if (localeString == NULL) {
JNU_ThrowOutOfMemoryError(env, NULL);
return NULL;
}
} }
ret = (*env)->NewStringUTF(env, localeString); ret = (*env)->NewStringUTF(env, localeString);
free(localeString); free(localeString);
...@@ -127,6 +132,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -127,6 +132,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) { (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
CFLocaleRef cflocale = CFLocaleCopyCurrent(); CFLocaleRef cflocale = CFLocaleCopyCurrent();
jstring tmp_string;
if (cflocale != NULL) { if (cflocale != NULL) {
CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault, CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault,
cflocale, cflocale,
...@@ -138,13 +144,18 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA ...@@ -138,13 +144,18 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA
if (amStr != NULL) { if (amStr != NULL) {
CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8); CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8);
CFRelease(amStr); CFRelease(amStr);
(*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewStringUTF(env, buf)); tmp_string = (*env)->NewStringUTF(env, buf);
if (tmp_string != NULL) {
(*env)->SetObjectArrayElement(env, ampms, 0, tmp_string);
}
} }
CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol); if (!(*env)->ExceptionCheck(env)){
if (pmStr != NULL) { CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol);
CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8); if (pmStr != NULL) {
CFRelease(pmStr); CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8);
(*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf)); CFRelease(pmStr);
(*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf));
}
} }
CFRelease(df); CFRelease(df);
} }
...@@ -647,10 +658,16 @@ static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle) { ...@@ -647,10 +658,16 @@ static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle) {
static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count) { static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count) {
char buf[BUFLEN]; char buf[BUFLEN];
jstring tmp_string;
for (; count > 0; sindex++, dindex++, count--) { for (; count > 0; sindex++, dindex++, count--) {
CFStringGetCString(CFArrayGetValueAtIndex(cfarray, sindex), buf, BUFLEN, kCFStringEncodingUTF8); CFStringGetCString(CFArrayGetValueAtIndex(cfarray, sindex), buf, BUFLEN, kCFStringEncodingUTF8);
(*env)->SetObjectArrayElement(env, jarray, dindex, (*env)->NewStringUTF(env, buf)); tmp_string = (*env)->NewStringUTF(env, buf);
if (tmp_string != NULL) {
(*env)->SetObjectArrayElement(env, jarray, dindex, tmp_string);
} else {
break;
}
} }
} }
......
/* /*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,100 +25,10 @@ ...@@ -25,100 +25,10 @@
package sun.util.locale.provider; package sun.util.locale.provider;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.spi.DateFormatProvider;
import java.util.Locale;
/** /**
* LocaleProviderAdapter implementation for the Unix locale data * LocaleProviderAdapter implementation for the Unix locale data
* *
* @author Naoto Sato * @author Naoto Sato
*/ */
public class HostLocaleProviderAdapterImpl { public class HostLocaleProviderAdapterImpl {
static Locale[] supported = {Locale.getDefault(Locale.Category.FORMAT)};
public static DateFormatProvider getDateFormatProvider() {
return new DateFormatProvider() {
String posixPattern;
@Override
public Locale[] getAvailableLocales() {
// not implemented yet
return new Locale[0];
}
@Override
public DateFormat getDateInstance(int style, Locale locale) {
posixPattern = getPattern(style, -1, locale.toLanguageTag());
return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
}
@Override
public DateFormat getTimeInstance(int style, Locale locale) {
posixPattern = getPattern(-1, style, locale.toLanguageTag());
return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
} }
@Override
public DateFormat getDateTimeInstance(int dateStyle,
int timeStyle, Locale locale) {
posixPattern = getPattern(dateStyle, timeStyle, locale.toLanguageTag());
return new SimpleDateFormat(convertPosixToJava(posixPattern), locale);
}
};
}
private static String convertPosixToJava(String posixPattern) {
StringBuilder sb = new StringBuilder();
boolean conversion = false;
for (int index = 0; index < posixPattern.length(); index++) {
char c = posixPattern.charAt(index);
if (conversion) {
switch (c) {
case 'a':
sb.append("EEE");
break;
case 'b':
sb.append("MMM");
break;
case 'e':
sb.append("dd");
break;
case 'H':
sb.append("kk");
break;
case 'M':
sb.append("mm");
break;
case 'S':
sb.append("ss");
break;
case 'Y':
sb.append("yyyy");
break;
case 'm':
sb.append("MM");
break;
case 'd':
sb.append("dd");
break;
case 'r':
sb.append("hh:mm:ss aa");
break;
case 'Z':
sb.append("zzz");
break;
}
conversion = false;
} else {
if (c == '%') {
conversion = true;
} else {
sb.append(c);
}
}
}
return sb.toString();
}
private static native String getPattern(int dateStyle, int timeStyle, String langtag);
}
/*
* Copyright (c) 2012, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
#include <gdefs.h>
#include <string.h>
#include <langinfo.h>
#include <locale.h>
#define BUFLEN 64
/*
* Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl
* Method: getPattern
* Signature: (IILjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern
(JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) {
// TEMPORARY!
char locale[BUFLEN];
char * pch;
char * old;
char * ret;
const char *langtag = (*env)->GetStringUTFChars(env, jlangtag, JNI_FALSE);
strcpy(locale, langtag);
pch = strchr(locale, '-');
if (pch != NULL) {
*pch = '_';
}
pch = strchr(locale, '-');
if (pch != NULL) {
*pch = '\0';
}
strcat(locale, ".UTF-8");
old = setlocale(LC_TIME, "");
setlocale(LC_TIME, locale);
if (dateStyle != (-1) && timeStyle != (-1)) {
ret = nl_langinfo(D_T_FMT);
} else if (dateStyle != (-1)) {
ret = nl_langinfo(D_FMT);
} else if (timeStyle != (-1)) {
ret = nl_langinfo(T_FMT);
} else {
ret = "yyyy/MM/dd";
}
setlocale(LC_TIME, old);
(*env)->ReleaseStringUTFChars(env, jlangtag, langtag);
return (*env)->NewStringUTF(env, ret);
}
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#define _WIN32_WINNT 0x0601 #define _WIN32_WINNT 0x0601
#endif #endif
#include "jni.h"
#include "jni_util.h"
#include <windows.h> #include <windows.h>
#include <shlobj.h> #include <shlobj.h>
#include <objidl.h> #include <objidl.h>
...@@ -51,7 +54,7 @@ ...@@ -51,7 +54,7 @@
#endif #endif
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
static void SetupI18nProps(LCID lcid, char** language, char** script, char** country, static boolean SetupI18nProps(LCID lcid, char** language, char** script, char** country,
char** variant, char** encoding); char** variant, char** encoding);
#define PROPSIZE 9 // eight-letter + null terminator #define PROPSIZE 9 // eight-letter + null terminator
...@@ -60,8 +63,11 @@ static void SetupI18nProps(LCID lcid, char** language, char** script, char** cou ...@@ -60,8 +63,11 @@ static void SetupI18nProps(LCID lcid, char** language, char** script, char** cou
static char * static char *
getEncodingInternal(LCID lcid) getEncodingInternal(LCID lcid)
{ {
char * ret = malloc(16);
int codepage; int codepage;
char * ret = malloc(16);
if (ret == NULL) {
return NULL;
}
if (GetLocaleInfo(lcid, if (GetLocaleInfo(lcid,
LOCALE_IDEFAULTANSICODEPAGE, LOCALE_IDEFAULTANSICODEPAGE,
...@@ -132,7 +138,11 @@ getEncodingInternal(LCID lcid) ...@@ -132,7 +138,11 @@ getEncodingInternal(LCID lcid)
static char* getConsoleEncoding() static char* getConsoleEncoding()
{ {
char* buf = malloc(16); char* buf = malloc(16);
int cp = GetConsoleCP(); int cp;
if (buf == NULL) {
return NULL;
}
cp = GetConsoleCP();
if (cp >= 874 && cp <= 950) if (cp >= 874 && cp <= 950)
sprintf(buf, "ms%d", cp); sprintf(buf, "ms%d", cp);
else else
...@@ -152,11 +162,16 @@ DllExport const char * ...@@ -152,11 +162,16 @@ DllExport const char *
getJavaIDFromLangID(LANGID langID) getJavaIDFromLangID(LANGID langID)
{ {
char * elems[5]; // lang, script, ctry, variant, encoding char * elems[5]; // lang, script, ctry, variant, encoding
char * ret = malloc(SNAMESIZE); char * ret;
int index; int index;
SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), ret = malloc(SNAMESIZE);
&(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4])); if (ret == NULL) {
return NULL;
}
if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
&(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) {
// there always is the "language" tag // there always is the "language" tag
strcpy(ret, elems[0]); strcpy(ret, elems[0]);
...@@ -172,6 +187,9 @@ getJavaIDFromLangID(LANGID langID) ...@@ -172,6 +187,9 @@ getJavaIDFromLangID(LANGID langID)
for (index = 0; index < 5; index++) { for (index = 0; index < 5; index++) {
free(elems[index]); free(elems[index]);
} }
} else {
ret = NULL;
}
return ret; return ret;
} }
...@@ -259,12 +277,15 @@ cpu_isalist(void) ...@@ -259,12 +277,15 @@ cpu_isalist(void)
return NULL; return NULL;
} }
static void static boolean
SetupI18nProps(LCID lcid, char** language, char** script, char** country, SetupI18nProps(LCID lcid, char** language, char** script, char** country,
char** variant, char** encoding) { char** variant, char** encoding) {
/* script */ /* script */
char tmp[SNAMESIZE]; char tmp[SNAMESIZE];
*script = malloc(PROPSIZE); *script = malloc(PROPSIZE);
if (*script == NULL) {
return FALSE;
}
if (GetLocaleInfo(lcid, if (GetLocaleInfo(lcid,
LOCALE_SNAME, tmp, SNAMESIZE) == 0 || LOCALE_SNAME, tmp, SNAMESIZE) == 0 ||
sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 || sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 ||
...@@ -274,6 +295,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, ...@@ -274,6 +295,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country,
/* country */ /* country */
*country = malloc(PROPSIZE); *country = malloc(PROPSIZE);
if (*country == NULL) {
return FALSE;
}
if (GetLocaleInfo(lcid, if (GetLocaleInfo(lcid,
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 && LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 &&
GetLocaleInfo(lcid, GetLocaleInfo(lcid,
...@@ -283,6 +307,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, ...@@ -283,6 +307,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country,
/* language */ /* language */
*language = malloc(PROPSIZE); *language = malloc(PROPSIZE);
if (*language == NULL) {
return FALSE;
}
if (GetLocaleInfo(lcid, if (GetLocaleInfo(lcid,
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 && LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 &&
GetLocaleInfo(lcid, GetLocaleInfo(lcid,
...@@ -294,6 +321,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, ...@@ -294,6 +321,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country,
/* variant */ /* variant */
*variant = malloc(PROPSIZE); *variant = malloc(PROPSIZE);
if (*variant == NULL) {
return FALSE;
}
(*variant)[0] = '\0'; (*variant)[0] = '\0';
/* handling for Norwegian */ /* handling for Norwegian */
...@@ -308,6 +338,10 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, ...@@ -308,6 +338,10 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country,
/* encoding */ /* encoding */
*encoding = getEncodingInternal(lcid); *encoding = getEncodingInternal(lcid);
if (*encoding == NULL) {
return FALSE;
}
return TRUE;
} }
java_props_t * java_props_t *
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h"
#include "jni_util.h"
#include <windows.h> #include <windows.h>
#include <gdefs.h> #include <gdefs.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -197,8 +198,13 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -197,8 +198,13 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
} }
localeString = (char *)getJavaIDFromLangID(langid); localeString = (char *)getJavaIDFromLangID(langid);
if (localeString != NULL) {
ret = (*env)->NewStringUTF(env, localeString); ret = (*env)->NewStringUTF(env, localeString);
free(localeString); free(localeString);
} else {
JNU_ThrowOutOfMemoryError(env, "memory allocation error");
ret = NULL;
}
return ret; return ret;
} }
...@@ -211,6 +217,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -211,6 +217,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
(JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) { (JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) {
WCHAR pattern[BUFLEN]; WCHAR pattern[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, NULL);
pattern[0] = L'\0'; pattern[0] = L'\0';
...@@ -238,8 +245,11 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -238,8 +245,11 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
*/ */
JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarID JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarID
(JNIEnv *env, jclass cls, jstring jlangtag) { (JNIEnv *env, jclass cls, jstring jlangtag) {
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
jint ret = getCalendarID(langtag); jint ret;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, 0);
ret = getCalendarID(langtag);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
return ret; return ret;
} }
...@@ -252,10 +262,13 @@ JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterIm ...@@ -252,10 +262,13 @@ JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterIm
JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) { (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
// AM // AM
int got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN); int got;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, NULL);
got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN);
if (got) { if (got) {
(*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewString(env, buf, wcslen(buf))); (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewString(env, buf, wcslen(buf)));
} }
...@@ -280,6 +293,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA ...@@ -280,6 +293,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA
(JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) { (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) {
WCHAR ad[BUFLEN]; WCHAR ad[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, eras);
getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL, getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL,
CAL_SERASTRING, ad, BUFLEN, NULL); CAL_SERASTRING, ad, BUFLEN, NULL);
...@@ -347,10 +361,14 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA ...@@ -347,10 +361,14 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA
*/ */
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNumberPattern JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNumberPattern
(JNIEnv *env, jclass cls, jint numberStyle, jstring jlangtag) { (JNIEnv *env, jclass cls, jint numberStyle, jstring jlangtag) {
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
jstring ret; jstring ret;
WCHAR * pattern;
WCHAR * pattern = getNumberPattern(langtag, numberStyle); langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, NULL);
pattern = getNumberPattern(langtag, numberStyle);
CHECK_NULL_RETURN(pattern, NULL);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
ret = (*env)->NewString(env, pattern, wcslen(pattern)); ret = (*env)->NewString(env, pattern, wcslen(pattern));
...@@ -367,8 +385,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -367,8 +385,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit
(JNIEnv *env, jclass cls, jstring jlangtag) { (JNIEnv *env, jclass cls, jstring jlangtag) {
DWORD num; DWORD num;
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, CHECK_NULL_RETURN(langtag, JNI_FALSE);
got = getLocaleInfoWrapper(langtag,
LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER,
(LPWSTR)&num, sizeof(num)); (LPWSTR)&num, sizeof(num));
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
...@@ -384,8 +404,10 @@ JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapt ...@@ -384,8 +404,10 @@ JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapt
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol
(JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) { (JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN); CHECK_NULL_RETURN(langtag, currencySymbol);
got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -403,8 +425,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -403,8 +425,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN); CHECK_NULL_RETURN(langtag, decimalSeparator);
got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -422,8 +446,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -422,8 +446,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN); CHECK_NULL_RETURN(langtag, groupingSeparator);
got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -441,8 +467,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -441,8 +467,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity
(JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) { (JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN); CHECK_NULL_RETURN(langtag, infinity);
got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -460,8 +488,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -460,8 +488,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol
(JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) { (JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN); CHECK_NULL_RETURN(langtag, internationalCurrencySymbol);
got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -479,8 +509,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -479,8 +509,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign
(JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN); CHECK_NULL_RETURN(langtag, minusSign);
got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -498,8 +530,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -498,8 +530,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator
(JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN); CHECK_NULL_RETURN(langtag, monetaryDecimalSeparator);
got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -517,8 +551,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -517,8 +551,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN
(JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) { (JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN); CHECK_NULL_RETURN(langtag, nan);
got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -536,8 +572,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -536,8 +572,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent
(JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
int got;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
int got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN); CHECK_NULL_RETURN(langtag, percent);
got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -555,8 +593,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -555,8 +593,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill
(JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
int got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN); int got;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, perMill);
got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -574,8 +616,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -574,8 +616,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit
(JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) { (JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) {
WCHAR buf[BUFLEN]; WCHAR buf[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
int got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN); int got;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, zeroDigit);
got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jlangtag, langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag);
if (got) { if (got) {
...@@ -593,9 +639,11 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI ...@@ -593,9 +639,11 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI
JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue
(JNIEnv *env, jclass cls, jstring jlangtag, jint type) { (JNIEnv *env, jclass cls, jstring jlangtag, jint type) {
DWORD num; DWORD num;
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
int got = 0; int got = 0;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL_RETURN(langtag, -1);
switch (type) { switch (type) {
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK: case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK:
got = getLocaleInfoWrapper(langtag, got = getLocaleInfoWrapper(langtag,
...@@ -648,6 +696,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte ...@@ -648,6 +696,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte
} }
pjChar = (*env)->GetStringChars(env, jStr, JNI_FALSE); pjChar = (*env)->GetStringChars(env, jStr, JNI_FALSE);
CHECK_NULL_RETURN(pjChar, NULL);
got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN); got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN);
(*env)->ReleaseStringChars(env, jStr, pjChar); (*env)->ReleaseStringChars(env, jStr, pjChar);
...@@ -705,8 +754,11 @@ jint getCalendarID(const jchar *langtag) { ...@@ -705,8 +754,11 @@ jint getCalendarID(const jchar *langtag) {
void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) { void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) {
WCHAR name[BUFLEN]; WCHAR name[BUFLEN];
const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); const jchar *langtag;
int calid = getCalendarID(langtag); int calid;
langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE);
CHECK_NULL(langtag);
calid = getCalendarID(langtag);
if (calid != -1) { if (calid != -1) {
int i; int i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册