author | naoto |
Tue, 31 Aug 2010 11:27:10 -0700 | |
changeset 6489 | 9e7015635425 |
parent 5506 | 202f599c92aa |
child 7017 | f3bfa15db005 |
child 6850 | 56966b0a6a0d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <windows.h> |
|
27 |
#include <shlobj.h> |
|
28 |
#include <objidl.h> |
|
29 |
#include <locale.h> |
|
30 |
#include <sys/types.h> |
|
31 |
#include <sys/timeb.h> |
|
32 |
#include <tchar.h> |
|
33 |
||
34 |
#include "locale_str.h" |
|
35 |
#include "java_props.h" |
|
36 |
||
37 |
#ifndef VER_PLATFORM_WIN32_WINDOWS |
|
38 |
#define VER_PLATFORM_WIN32_WINDOWS 1 |
|
39 |
#endif |
|
40 |
||
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
41 |
#ifndef PROCESSOR_ARCHITECTURE_AMD64 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
42 |
#define PROCESSOR_ARCHITECTURE_AMD64 9 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
43 |
#endif |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
44 |
|
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
45 |
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
46 |
static void SetupI18nProps(LCID lcid, char** language, char** country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
47 |
char** variant, char** encoding); |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
48 |
|
2 | 49 |
#define SHELL_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" |
50 |
||
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
51 |
static char * |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
52 |
getEncodingInternal(LCID lcid) |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
53 |
{ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
54 |
char * ret = malloc(16); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
55 |
int codepage; |
2 | 56 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
57 |
if (GetLocaleInfo(lcid, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
58 |
LOCALE_IDEFAULTANSICODEPAGE, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
59 |
ret+2, 14) == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
60 |
codepage = 1252; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
61 |
} else { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
62 |
codepage = atoi(ret+2); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
63 |
} |
2 | 64 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
65 |
switch (codepage) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
66 |
case 0: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
67 |
strcpy(ret, "UTF-8"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
68 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
69 |
case 874: /* 9:Thai */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
70 |
case 932: /* 10:Japanese */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
71 |
case 949: /* 12:Korean Extended Wansung */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
72 |
case 950: /* 13:Chinese (Taiwan, Hongkong, Macau) */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
73 |
case 1361: /* 15:Korean Johab */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
74 |
ret[0] = 'M'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
75 |
ret[1] = 'S'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
76 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
77 |
case 936: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
78 |
strcpy(ret, "GBK"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
79 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
80 |
case 54936: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
81 |
strcpy(ret, "GB18030"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
82 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
83 |
default: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
84 |
ret[0] = 'C'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
85 |
ret[1] = 'p'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
86 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
87 |
} |
2 | 88 |
|
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
89 |
//Traditional Chinese Windows should use MS950_HKSCS_XP as the |
2 | 90 |
//default encoding, if HKSCS patch has been installed. |
91 |
// "old" MS950 0xfa41 -> u+e001 |
|
92 |
// "new" MS950 0xfa41 -> u+92db |
|
93 |
if (strcmp(ret, "MS950") == 0) { |
|
94 |
TCHAR mbChar[2] = {(char)0xfa, (char)0x41}; |
|
95 |
WCHAR unicodeChar; |
|
96 |
MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1); |
|
97 |
if (unicodeChar == 0x92db) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
98 |
strcpy(ret, "MS950_HKSCS_XP"); |
2 | 99 |
} |
100 |
} else { |
|
101 |
//SimpChinese Windows should use GB18030 as the default |
|
102 |
//encoding, if gb18030 patch has been installed (on windows |
|
103 |
//2000/XP, (1)Codepage 54936 will be available |
|
104 |
//(2)simsun18030.ttc will exist under system fonts dir ) |
|
105 |
if (strcmp(ret, "GBK") == 0 && IsValidCodePage(54936)) { |
|
106 |
char systemPath[MAX_PATH + 1]; |
|
107 |
char* gb18030Font = "\\FONTS\\SimSun18030.ttc"; |
|
108 |
FILE *f = NULL; |
|
109 |
if (GetWindowsDirectory(systemPath, MAX_PATH + 1) != 0 && |
|
110 |
strlen(systemPath) + strlen(gb18030Font) < MAX_PATH + 1) { |
|
111 |
strcat(systemPath, "\\FONTS\\SimSun18030.ttc"); |
|
112 |
if ((f = fopen(systemPath, "r")) != NULL) { |
|
113 |
fclose(f); |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
114 |
strcpy(ret, "GB18030"); |
2 | 115 |
} |
116 |
} |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
return ret; |
|
121 |
} |
|
122 |
||
123 |
// Exported entries for AWT |
|
124 |
DllExport const char * |
|
125 |
getEncodingFromLangID(LANGID langID) |
|
126 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
127 |
return getEncodingInternal(MAKELCID(langID, SORT_DEFAULT)); |
2 | 128 |
} |
129 |
||
130 |
DllExport const char * |
|
131 |
getJavaIDFromLangID(LANGID langID) |
|
132 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
133 |
char * lang; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
134 |
char * ctry; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
135 |
char * vrnt; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
136 |
char * enc; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
137 |
char * ret = malloc(16); |
2 | 138 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
139 |
SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), &lang, &ctry, &vrnt, &enc); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
140 |
if (ctry[0] != '\0') { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
141 |
if (vrnt[0] != '\0') { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
142 |
sprintf(ret, "%s_%s_%s", lang, ctry, vrnt); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
143 |
} else { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
144 |
sprintf(ret, "%s_%s", lang, ctry); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
145 |
} |
2 | 146 |
} else { |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
147 |
strcpy(ret, lang); |
2 | 148 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
149 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
150 |
free(lang); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
151 |
free(ctry); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
152 |
free(vrnt); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
153 |
free(enc); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
154 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
155 |
return ret; |
2 | 156 |
} |
157 |
||
158 |
/* |
|
159 |
* Code to figure out the user's home directory using the registry |
|
160 |
*/ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
161 |
static WCHAR* |
2 | 162 |
getHomeFromRegistry() |
163 |
{ |
|
164 |
HKEY key; |
|
165 |
int rc; |
|
166 |
DWORD type; |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
167 |
WCHAR *p; |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
168 |
WCHAR path[MAX_PATH+1]; |
2 | 169 |
int size = MAX_PATH+1; |
170 |
||
171 |
rc = RegOpenKeyEx(HKEY_CURRENT_USER, SHELL_KEY, 0, KEY_READ, &key); |
|
172 |
if (rc != ERROR_SUCCESS) { |
|
173 |
// Shell folder doesn't exist??!! |
|
174 |
return NULL; |
|
175 |
} |
|
176 |
||
177 |
path[0] = 0; |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
178 |
rc = RegQueryValueExW(key, L"Desktop", 0, &type, (LPBYTE)path, &size); |
2 | 179 |
if (rc != ERROR_SUCCESS || type != REG_SZ) { |
180 |
return NULL; |
|
181 |
} |
|
182 |
RegCloseKey(key); |
|
183 |
/* Get the parent of Desktop directory */ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
184 |
p = wcsrchr(path, L'\\'); |
2 | 185 |
if (p == NULL) { |
186 |
return NULL; |
|
187 |
} |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
188 |
*p = L'\0'; |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
189 |
return _wcsdup(path); |
2 | 190 |
} |
191 |
||
192 |
/* |
|
193 |
* Code to figure out the user's home directory using shell32.dll |
|
194 |
*/ |
|
195 |
typedef HRESULT (WINAPI *GetSpecialFolderType)(HWND, int, LPITEMIDLIST *); |
|
196 |
typedef BOOL (WINAPI *GetPathFromIDListType)(LPCITEMIDLIST, LPSTR); |
|
197 |
||
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
198 |
WCHAR* |
2 | 199 |
getHomeFromShell32() |
200 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
201 |
HMODULE lib = LoadLibraryW(L"SHELL32.DLL"); |
2 | 202 |
GetSpecialFolderType do_get_folder; |
203 |
GetPathFromIDListType do_get_path; |
|
204 |
HRESULT rc; |
|
205 |
LPITEMIDLIST item_list = 0; |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
206 |
WCHAR *p; |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
207 |
WCHAR path[MAX_PATH+1]; |
2 | 208 |
int size = MAX_PATH+1; |
209 |
||
210 |
if (lib == 0) { |
|
211 |
// We can't load the library !!?? |
|
212 |
return NULL; |
|
213 |
} |
|
214 |
||
215 |
do_get_folder = (GetSpecialFolderType)GetProcAddress(lib, "SHGetSpecialFolderLocation"); |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
216 |
do_get_path = (GetPathFromIDListType)GetProcAddress(lib, "SHGetPathFromIDListW"); |
2 | 217 |
|
218 |
if (do_get_folder == 0 || do_get_path == 0) { |
|
219 |
// the library doesn't hold the right functions !!?? |
|
220 |
return NULL; |
|
221 |
} |
|
222 |
||
223 |
rc = (*do_get_folder)(NULL, CSIDL_DESKTOPDIRECTORY, &item_list); |
|
224 |
if (!SUCCEEDED(rc)) { |
|
225 |
// we can't find the shell folder. |
|
226 |
return NULL; |
|
227 |
} |
|
228 |
||
229 |
path[0] = 0; |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
230 |
(*do_get_path)(item_list, (LPSTR)path); |
2 | 231 |
|
232 |
/* Get the parent of Desktop directory */ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
233 |
p = wcsrchr(path, L'\\'); |
2 | 234 |
if (p) { |
235 |
*p = 0; |
|
236 |
} |
|
237 |
||
238 |
/* |
|
239 |
* We've been successful. Note that we don't free the memory allocated |
|
240 |
* by ShGetSpecialFolderLocation. We only ever come through here once, |
|
241 |
* and only if the registry lookup failed, so it's just not worth it. |
|
242 |
* |
|
243 |
* We also don't unload the SHELL32 DLL. We've paid the hit for loading |
|
244 |
* it and we may need it again later. |
|
245 |
*/ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
246 |
return _wcsdup(path); |
2 | 247 |
} |
248 |
||
249 |
static boolean |
|
250 |
haveMMX(void) |
|
251 |
{ |
|
252 |
boolean mmx = 0; |
|
253 |
HMODULE lib = LoadLibrary("KERNEL32"); |
|
254 |
if (lib != NULL) { |
|
255 |
BOOL (WINAPI *isProcessorFeaturePresent)(DWORD) = |
|
256 |
(BOOL (WINAPI *)(DWORD)) |
|
257 |
GetProcAddress(lib, "IsProcessorFeaturePresent"); |
|
258 |
if (isProcessorFeaturePresent != NULL) |
|
259 |
mmx = isProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE); |
|
260 |
FreeLibrary(lib); |
|
261 |
} |
|
262 |
return mmx; |
|
263 |
} |
|
264 |
||
265 |
static const char * |
|
266 |
cpu_isalist(void) |
|
267 |
{ |
|
268 |
SYSTEM_INFO info; |
|
269 |
GetSystemInfo(&info); |
|
270 |
switch (info.wProcessorArchitecture) { |
|
271 |
#ifdef PROCESSOR_ARCHITECTURE_IA64 |
|
272 |
case PROCESSOR_ARCHITECTURE_IA64: return "ia64"; |
|
273 |
#endif |
|
274 |
#ifdef PROCESSOR_ARCHITECTURE_AMD64 |
|
275 |
case PROCESSOR_ARCHITECTURE_AMD64: return "amd64"; |
|
276 |
#endif |
|
277 |
case PROCESSOR_ARCHITECTURE_INTEL: |
|
278 |
switch (info.wProcessorLevel) { |
|
279 |
case 6: return haveMMX() |
|
280 |
? "pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86" |
|
281 |
: "pentium_pro pentium i486 i386 i86"; |
|
282 |
case 5: return haveMMX() |
|
283 |
? "pentium+mmx pentium i486 i386 i86" |
|
284 |
: "pentium i486 i386 i86"; |
|
285 |
case 4: return "i486 i386 i86"; |
|
286 |
case 3: return "i386 i86"; |
|
287 |
} |
|
288 |
} |
|
289 |
return NULL; |
|
290 |
} |
|
291 |
||
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
292 |
#define PROPSIZE 3 // two-letter + null terminator |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
293 |
static void |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
294 |
SetupI18nProps(LCID lcid, char** language, char** country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
295 |
char** variant, char** encoding) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
296 |
/* country */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
297 |
*country = malloc(PROPSIZE); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
298 |
if (GetLocaleInfo(lcid, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
299 |
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
300 |
(*country)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
301 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
302 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
303 |
/* language */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
304 |
*language = malloc(PROPSIZE); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
305 |
if (lcid == 0x46c) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
306 |
/* Windows returns non-existent language code "ns" for Northern Sotho. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
307 |
* Defaults to en_US |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
308 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
309 |
strcpy(*language, "en"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
310 |
strcpy(*country, "US"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
311 |
} else if (GetLocaleInfo(lcid, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
312 |
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
313 |
if (lcid == 0x465) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
314 |
/* for some reason, Windows returns "div" for this Divehi LCID, even though |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
315 |
* there is a two letter language code "dv". Tweak it here. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
316 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
317 |
strcpy(*language, "dv"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
318 |
strcpy(*country, "MV"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
319 |
} else { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
320 |
/* defaults to en_US */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
321 |
strcpy(*language, "en"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
322 |
strcpy(*country, "US"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
323 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
324 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
325 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
326 |
/* variant */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
327 |
*variant = malloc(PROPSIZE); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
328 |
(*variant)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
329 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
330 |
/* handling for Norwegian */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
331 |
if (strcmp(*language, "nb") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
332 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
333 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
334 |
} else if (strcmp(*language, "nn") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
335 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
336 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
337 |
strcpy(*variant, "NY"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
338 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
339 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
340 |
/* encoding */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
341 |
*encoding = getEncodingInternal(lcid); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
342 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
343 |
|
2 | 344 |
java_props_t * |
345 |
GetJavaProperties(JNIEnv* env) |
|
346 |
{ |
|
347 |
static java_props_t sprops = {0}; |
|
348 |
||
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
349 |
OSVERSIONINFOEX ver; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
350 |
|
2 | 351 |
if (sprops.user_dir) { |
352 |
return &sprops; |
|
353 |
} |
|
354 |
||
355 |
/* AWT properties */ |
|
356 |
sprops.awt_toolkit = "sun.awt.windows.WToolkit"; |
|
357 |
||
358 |
/* tmp dir */ |
|
359 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
360 |
WCHAR tmpdir[MAX_PATH + 1]; |
2 | 361 |
/* we might want to check that this succeed */ |
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
362 |
GetTempPathW(MAX_PATH + 1, tmpdir); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
363 |
sprops.tmp_dir = _wcsdup(tmpdir); |
2 | 364 |
} |
365 |
||
366 |
/* Printing properties */ |
|
367 |
sprops.printerJob = "sun.awt.windows.WPrinterJob"; |
|
368 |
||
369 |
/* Java2D properties */ |
|
370 |
sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment"; |
|
371 |
||
372 |
{ /* This is used only for debugging of font problems. */ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
373 |
WCHAR *path = _wgetenv(L"JAVA2D_FONTPATH"); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
374 |
sprops.font_dir = (path != NULL) ? _wcsdup(path) : NULL; |
2 | 375 |
} |
376 |
||
377 |
/* OS properties */ |
|
378 |
{ |
|
379 |
char buf[100]; |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
380 |
SYSTEM_INFO si; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
381 |
PGNSI pGNSI; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
382 |
|
2 | 383 |
ver.dwOSVersionInfoSize = sizeof(ver); |
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
384 |
GetVersionEx((OSVERSIONINFO *) &ver); |
2 | 385 |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
386 |
ZeroMemory(&si, sizeof(SYSTEM_INFO)); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
387 |
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
388 |
pGNSI = (PGNSI) GetProcAddress( |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
389 |
GetModuleHandle(TEXT("kernel32.dll")), |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
390 |
"GetNativeSystemInfo"); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
391 |
if(NULL != pGNSI) |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
392 |
pGNSI(&si); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
393 |
else |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
394 |
GetSystemInfo(&si); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
395 |
|
2 | 396 |
/* |
397 |
* From msdn page on OSVERSIONINFOEX, current as of this |
|
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
398 |
* writing, decoding of dwMajorVersion and dwMinorVersion. |
2 | 399 |
* |
400 |
* Operating system dwMajorVersion dwMinorVersion |
|
401 |
* ================== ============== ============== |
|
402 |
* |
|
403 |
* Windows 95 4 0 |
|
404 |
* Windows 98 4 10 |
|
405 |
* Windows ME 4 90 |
|
406 |
* Windows 3.51 3 51 |
|
407 |
* Windows NT 4.0 4 0 |
|
408 |
* Windows 2000 5 0 |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
409 |
* Windows XP 32 bit 5 1 |
2 | 410 |
* Windows Server 2003 family 5 2 |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
411 |
* Windows XP 64 bit 5 2 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
412 |
* where ((&ver.wServicePackMinor) + 2) = 1 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
413 |
* and si.wProcessorArchitecture = 9 |
3212 | 414 |
* Windows Vista family 6 0 (VER_NT_WORKSTATION) |
415 |
* Windows Server 2008 6 0 (!VER_NT_WORKSTATION) |
|
416 |
* Windows 7 6 1 (VER_NT_WORKSTATION) |
|
417 |
* Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION) |
|
2 | 418 |
* |
419 |
* This mapping will presumably be augmented as new Windows |
|
420 |
* versions are released. |
|
421 |
*/ |
|
422 |
switch (ver.dwPlatformId) { |
|
423 |
case VER_PLATFORM_WIN32s: |
|
424 |
sprops.os_name = "Windows 3.1"; |
|
425 |
break; |
|
426 |
case VER_PLATFORM_WIN32_WINDOWS: |
|
427 |
if (ver.dwMajorVersion == 4) { |
|
428 |
switch (ver.dwMinorVersion) { |
|
429 |
case 0: sprops.os_name = "Windows 95"; break; |
|
430 |
case 10: sprops.os_name = "Windows 98"; break; |
|
431 |
case 90: sprops.os_name = "Windows Me"; break; |
|
432 |
default: sprops.os_name = "Windows 9X (unknown)"; break; |
|
433 |
} |
|
434 |
} else { |
|
435 |
sprops.os_name = "Windows 9X (unknown)"; |
|
436 |
} |
|
437 |
break; |
|
438 |
case VER_PLATFORM_WIN32_NT: |
|
439 |
if (ver.dwMajorVersion <= 4) { |
|
440 |
sprops.os_name = "Windows NT"; |
|
441 |
} else if (ver.dwMajorVersion == 5) { |
|
442 |
switch (ver.dwMinorVersion) { |
|
443 |
case 0: sprops.os_name = "Windows 2000"; break; |
|
444 |
case 1: sprops.os_name = "Windows XP"; break; |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
445 |
case 2: |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
446 |
/* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
447 |
* From MSDN OSVERSIONINFOEX and SYSTEM_INFO documentation: |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
448 |
* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
449 |
* "Because the version numbers for Windows Server 2003 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
450 |
* and Windows XP 6u4 bit are identical, you must also test |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
451 |
* whether the wProductType member is VER_NT_WORKSTATION. |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
452 |
* and si.wProcessorArchitecture is |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
453 |
* PROCESSOR_ARCHITECTURE_AMD64 (which is 9) |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
454 |
* If it is, the operating system is Windows XP 64 bit; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
455 |
* otherwise, it is Windows Server 2003." |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
456 |
*/ |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
457 |
if(ver.wProductType == VER_NT_WORKSTATION && |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
458 |
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
459 |
sprops.os_name = "Windows XP"; /* 64 bit */ |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
460 |
} else { |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
461 |
sprops.os_name = "Windows 2003"; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
462 |
} |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
463 |
break; |
2 | 464 |
default: sprops.os_name = "Windows NT (unknown)"; break; |
465 |
} |
|
466 |
} else if (ver.dwMajorVersion == 6) { |
|
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
467 |
/* |
3212 | 468 |
* See table in MSDN OSVERSIONINFOEX documentation. |
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
469 |
*/ |
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
470 |
if (ver.wProductType == VER_NT_WORKSTATION) { |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
471 |
switch (ver.dwMinorVersion) { |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
472 |
case 0: sprops.os_name = "Windows Vista"; break; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
473 |
case 1: sprops.os_name = "Windows 7"; break; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
474 |
default: sprops.os_name = "Windows NT (unknown)"; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
475 |
} |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
476 |
} else { |
3212 | 477 |
switch (ver.dwMinorVersion) { |
478 |
case 0: sprops.os_name = "Windows Server 2008"; break; |
|
479 |
case 1: sprops.os_name = "Windows Server 2008 R2"; break; |
|
480 |
default: sprops.os_name = "Windows NT (unknown)"; |
|
481 |
} |
|
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
482 |
} |
2 | 483 |
} else { |
484 |
sprops.os_name = "Windows NT (unknown)"; |
|
485 |
} |
|
486 |
break; |
|
487 |
default: |
|
488 |
sprops.os_name = "Windows (unknown)"; |
|
489 |
break; |
|
490 |
} |
|
491 |
sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); |
|
492 |
sprops.os_version = strdup(buf); |
|
493 |
#if _M_IA64 |
|
494 |
sprops.os_arch = "ia64"; |
|
495 |
#elif _M_AMD64 |
|
496 |
sprops.os_arch = "amd64"; |
|
497 |
#elif _X86_ |
|
498 |
sprops.os_arch = "x86"; |
|
499 |
#else |
|
500 |
sprops.os_arch = "unknown"; |
|
501 |
#endif |
|
502 |
||
503 |
sprops.patch_level = strdup(ver.szCSDVersion); |
|
504 |
||
505 |
sprops.desktop = "windows"; |
|
506 |
} |
|
507 |
||
508 |
/* Endianness of platform */ |
|
509 |
{ |
|
510 |
unsigned int endianTest = 0xff000000; |
|
511 |
if (((char*)(&endianTest))[0] != 0) { |
|
512 |
sprops.cpu_endian = "big"; |
|
513 |
} else { |
|
514 |
sprops.cpu_endian = "little"; |
|
515 |
} |
|
516 |
} |
|
517 |
||
518 |
/* CPU ISA list */ |
|
519 |
sprops.cpu_isalist = cpu_isalist(); |
|
520 |
||
521 |
/* |
|
522 |
* User name |
|
523 |
* We try to avoid calling GetUserName as it turns out to |
|
524 |
* be surprisingly expensive on NT. It pulls in an extra |
|
525 |
* 100 K of footprint. |
|
526 |
*/ |
|
527 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
528 |
WCHAR *uname = _wgetenv(L"USERNAME"); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
529 |
if (uname != NULL && wcslen(uname) > 0) { |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
530 |
sprops.user_name = _wcsdup(uname); |
2 | 531 |
} else { |
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
532 |
WCHAR buf[100]; |
2 | 533 |
int buflen = sizeof(buf); |
534 |
sprops.user_name = |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
535 |
GetUserNameW(buf, &buflen) ? _wcsdup(buf) : L"unknown"; |
2 | 536 |
} |
537 |
} |
|
538 |
||
539 |
/* |
|
540 |
* Home directory/ |
|
541 |
* |
|
542 |
* We first look under a standard registry key. If that fails we |
|
543 |
* fall back on using a SHELL32.DLL API. If that fails we use a |
|
544 |
* default value. |
|
545 |
* |
|
546 |
* Note: To save space we want to avoid loading SHELL32.DLL |
|
547 |
* unless really necessary. However if we do load it, we leave it |
|
548 |
* in memory, as it may be needed again later. |
|
549 |
* |
|
550 |
* The normal result is that for a given user name XXX: |
|
551 |
* On multi-user NT, user.home gets set to c:\winnt\profiles\XXX. |
|
552 |
* On multi-user Win95, user.home gets set to c:\windows\profiles\XXX. |
|
553 |
* On single-user Win95, user.home gets set to c:\windows. |
|
554 |
*/ |
|
555 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
556 |
WCHAR *homep = getHomeFromRegistry(); |
2 | 557 |
if (homep == NULL) { |
558 |
homep = getHomeFromShell32(); |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
559 |
if (homep == NULL) |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
560 |
homep = L"C:\\"; |
2 | 561 |
} |
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
562 |
sprops.user_home = _wcsdup(homep); |
2 | 563 |
} |
564 |
||
565 |
/* |
|
566 |
* user.language |
|
567 |
* user.country, user.variant (if user's environment specifies them) |
|
568 |
* file.encoding |
|
569 |
* file.encoding.pkg |
|
570 |
*/ |
|
571 |
{ |
|
572 |
/* |
|
573 |
* query the system for the current system default locale |
|
574 |
* (which is a Windows LCID value), |
|
575 |
*/ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
576 |
LCID userDefaultLCID = GetUserDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
577 |
LCID systemDefaultLCID = GetSystemDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
578 |
LCID userDefaultUILang = GetUserDefaultUILanguage(); |
2 | 579 |
|
580 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
581 |
char * display_encoding; |
2 | 582 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
583 |
SetupI18nProps(userDefaultUILang, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
584 |
&sprops.language, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
585 |
&sprops.country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
586 |
&sprops.variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
587 |
&display_encoding); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
588 |
SetupI18nProps(userDefaultLCID, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
589 |
&sprops.format_language, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
590 |
&sprops.format_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
591 |
&sprops.format_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
592 |
&sprops.encoding); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
593 |
SetupI18nProps(userDefaultUILang, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
594 |
&sprops.display_language, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
595 |
&sprops.display_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
596 |
&sprops.display_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
597 |
&display_encoding); |
2 | 598 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
599 |
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
600 |
if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) { |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
601 |
// MS claims "Vista has built-in support for HKSCS-2004. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
602 |
// All of the HKSCS-2004 characters have Unicode 4.1. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
603 |
// PUA code point assignments". But what it really means |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
604 |
// is that the HKSCS-2004 is ONLY supported in Unicode. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
605 |
// Test indicates the MS950 in its zh_HK locale is a |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
606 |
// "regular" MS950 which does not handle HKSCS-2004 at |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
607 |
// all. Set encoding to MS950_HKSCS. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
608 |
sprops.encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
609 |
sprops.sun_jnu_encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
610 |
} |
2 | 611 |
} |
612 |
} |
|
613 |
||
614 |
sprops.unicode_encoding = "UnicodeLittle"; |
|
615 |
/* User TIMEZONE */ |
|
616 |
{ |
|
617 |
/* |
|
618 |
* We defer setting up timezone until it's actually necessary. |
|
619 |
* Refer to TimeZone.getDefault(). However, the system |
|
620 |
* property is necessary to be able to be set by the command |
|
621 |
* line interface -D. Here temporarily set a null string to |
|
622 |
* timezone. |
|
623 |
*/ |
|
624 |
sprops.timezone = ""; |
|
625 |
} |
|
626 |
||
627 |
/* Current directory */ |
|
628 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
629 |
WCHAR buf[MAX_PATH]; |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
630 |
GetCurrentDirectoryW(sizeof(buf), buf); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
631 |
sprops.user_dir = _wcsdup(buf); |
2 | 632 |
} |
633 |
||
634 |
sprops.file_separator = "\\"; |
|
635 |
sprops.path_separator = ";"; |
|
636 |
sprops.line_separator = "\r\n"; |
|
637 |
||
638 |
return &sprops; |
|
639 |
} |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
640 |
|
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
641 |
jstring |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
642 |
GetStringPlatform(JNIEnv *env, nchar* wcstr) |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
643 |
{ |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
644 |
return (*env)->NewString(env, wcstr, wcslen(wcstr)); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
645 |
} |