author | prr |
Fri, 03 May 2019 17:06:42 -0700 | |
changeset 54869 | 72d194129803 |
parent 54865 | 99337f94b04d |
child 54877 | dde07ac16610 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
50992
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1998, 2018, 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 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
26 |
#if defined(__linux__) || defined(_ALLBSD_SOURCE) |
2 | 27 |
#include <stdio.h> |
28 |
#include <ctype.h> |
|
29 |
#endif |
|
30 |
#include <pwd.h> |
|
31 |
#include <locale.h> |
|
32 |
#ifndef ARCHPROPNAME |
|
33 |
#error "The macro ARCHPROPNAME has not been defined" |
|
34 |
#endif |
|
35 |
#include <sys/utsname.h> /* For os_name and os_version */ |
|
36 |
#include <langinfo.h> /* For nl_langinfo */ |
|
37 |
#include <stdlib.h> |
|
38 |
#include <string.h> |
|
39 |
#include <sys/types.h> |
|
40 |
#include <unistd.h> |
|
41 |
#include <sys/param.h> |
|
42 |
#include <time.h> |
|
43 |
#include <errno.h> |
|
44 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
45 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
46 |
#include "java_props_macosx.h" |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
47 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
48 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
49 |
#if defined(_ALLBSD_SOURCE) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
50 |
#if !defined(P_tmpdir) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
51 |
#include <paths.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
52 |
#define P_tmpdir _PATH_VARTMP |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
53 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
54 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
55 |
|
2 | 56 |
#include "locale_str.h" |
57 |
#include "java_props.h" |
|
58 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
59 |
#if !defined(_ALLBSD_SOURCE) |
2 | 60 |
#ifdef __linux__ |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
61 |
#ifndef CODESET |
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
62 |
#define CODESET _NL_CTYPE_CODESET_NAME |
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
63 |
#endif |
2 | 64 |
#else |
65 |
#ifdef ALT_CODESET_KEY |
|
66 |
#define CODESET ALT_CODESET_KEY |
|
67 |
#endif |
|
68 |
#endif |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
69 |
#endif /* !_ALLBSD_SOURCE */ |
2 | 70 |
|
71 |
/* Take an array of string pairs (map of key->value) and a string (key). |
|
72 |
* Examine each pair in the map to see if the first string (key) matches the |
|
73 |
* string. If so, store the second string of the pair (value) in the value and |
|
74 |
* return 1. Otherwise do nothing and return 0. The end of the map is |
|
75 |
* indicated by an empty string at the start of a pair (key of ""). |
|
76 |
*/ |
|
77 |
static int |
|
78 |
mapLookup(char* map[], const char* key, char** value) { |
|
79 |
int i; |
|
80 |
for (i = 0; strcmp(map[i], ""); i += 2){ |
|
81 |
if (!strcmp(key, map[i])){ |
|
82 |
*value = map[i + 1]; |
|
83 |
return 1; |
|
84 |
} |
|
85 |
} |
|
86 |
return 0; |
|
87 |
} |
|
88 |
||
89 |
#ifndef P_tmpdir |
|
90 |
#define P_tmpdir "/var/tmp" |
|
91 |
#endif |
|
92 |
||
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
93 |
static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_script, |
7017 | 94 |
char ** std_country, char ** std_variant, char ** std_encoding) { |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
95 |
char *temp = NULL; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
96 |
char *language = NULL, *country = NULL, *variant = NULL, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
97 |
*encoding = NULL; |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
98 |
char *p, *encoding_variant, *old_temp, *old_ev; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
99 |
char *lc; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
100 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
101 |
/* Query the locale set for the category */ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
102 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
103 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
104 |
lc = setupMacOSXLocale(cat); // malloc'd memory, need to free |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
105 |
#else |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
106 |
lc = setlocale(cat, NULL); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
107 |
#endif |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
108 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
109 |
#ifndef __linux__ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
110 |
if (lc == NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
111 |
return 0; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
112 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
113 |
|
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
114 |
temp = malloc(strlen(lc) + 1); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
115 |
if (temp == NULL) { |
20776
6c440a257019
8025712: (props) Possible memory leak in java_props_md.c / ParseLocale
dxu
parents:
19857
diff
changeset
|
116 |
#ifdef MACOSX |
6c440a257019
8025712: (props) Possible memory leak in java_props_md.c / ParseLocale
dxu
parents:
19857
diff
changeset
|
117 |
free(lc); // malloced memory |
6c440a257019
8025712: (props) Possible memory leak in java_props_md.c / ParseLocale
dxu
parents:
19857
diff
changeset
|
118 |
#endif |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
119 |
JNU_ThrowOutOfMemoryError(env, NULL); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
120 |
return 0; |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
121 |
} |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
122 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
123 |
if (cat == LC_CTYPE) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
124 |
/* |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
125 |
* Workaround for Solaris bug 4201684: Xlib doesn't like @euro |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
126 |
* locales. Since we don't depend on the libc @euro behavior, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
127 |
* we just remove the qualifier. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
128 |
* On Linux, the bug doesn't occur; on the other hand, @euro |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
129 |
* is needed there because it's a shortcut that also determines |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
130 |
* the encoding - without it, we wouldn't get ISO-8859-15. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
131 |
* Therefore, this code section is Solaris-specific. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
132 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
133 |
strcpy(temp, lc); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
134 |
p = strstr(temp, "@euro"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
135 |
if (p != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
136 |
*p = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
137 |
setlocale(LC_ALL, temp); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
138 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
139 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
140 |
#else |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
141 |
if (lc == NULL || !strcmp(lc, "C") || !strcmp(lc, "POSIX")) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
142 |
lc = "en_US"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
143 |
} |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
144 |
|
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
145 |
temp = malloc(strlen(lc) + 1); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
146 |
if (temp == NULL) { |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
147 |
JNU_ThrowOutOfMemoryError(env, NULL); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
148 |
return 0; |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
149 |
} |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
150 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
151 |
#endif |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
152 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
153 |
/* |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
154 |
* locale string format in Solaris is |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
155 |
* <language name>_<country name>.<encoding name>@<variant name> |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
156 |
* <country name>, <encoding name>, and <variant name> are optional. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
157 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
158 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
159 |
strcpy(temp, lc); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
160 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
161 |
free(lc); // malloced memory |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
162 |
#endif |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
163 |
/* Parse the language, country, encoding, and variant from the |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
164 |
* locale. Any of the elements may be missing, but they must occur |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
165 |
* in the order language_country.encoding@variant, and must be |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
166 |
* preceded by their delimiter (except for language). |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
167 |
* |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
168 |
* If the locale name (without .encoding@variant, if any) matches |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
169 |
* any of the names in the locale_aliases list, map it to the |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
170 |
* corresponding full locale name. Most of the entries in the |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
171 |
* locale_aliases list are locales that include a language name but |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
172 |
* no country name, and this facility is used to map each language |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
173 |
* to a default country if that's possible. It's also used to map |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
174 |
* the Solaris locale aliases to their proper Java locale IDs. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
175 |
*/ |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
176 |
|
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
177 |
encoding_variant = malloc(strlen(temp)+1); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
178 |
if (encoding_variant == NULL) { |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
179 |
free(temp); |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
180 |
JNU_ThrowOutOfMemoryError(env, NULL); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
181 |
return 0; |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
182 |
} |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
183 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
184 |
if ((p = strchr(temp, '.')) != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
185 |
strcpy(encoding_variant, p); /* Copy the leading '.' */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
186 |
*p = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
187 |
} else if ((p = strchr(temp, '@')) != NULL) { |
7017 | 188 |
strcpy(encoding_variant, p); /* Copy the leading '@' */ |
189 |
*p = '\0'; |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
190 |
} else { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
191 |
*encoding_variant = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
192 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
193 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
194 |
if (mapLookup(locale_aliases, temp, &p)) { |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
195 |
old_temp = temp; |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
196 |
temp = realloc(temp, strlen(p)+1); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
197 |
if (temp == NULL) { |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
198 |
free(old_temp); |
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
199 |
free(encoding_variant); |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
200 |
JNU_ThrowOutOfMemoryError(env, NULL); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
201 |
return 0; |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
202 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
203 |
strcpy(temp, p); |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
204 |
old_ev = encoding_variant; |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
205 |
encoding_variant = realloc(encoding_variant, strlen(temp)+1); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
206 |
if (encoding_variant == NULL) { |
13414
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
207 |
free(old_ev); |
1e161ce0b69e
7189533: GetJavaProperties should free temporary file if subsequent allocations fails
andrew
parents:
13413
diff
changeset
|
208 |
free(temp); |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
209 |
JNU_ThrowOutOfMemoryError(env, NULL); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
210 |
return 0; |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
211 |
} |
7017 | 212 |
// check the "encoding_variant" again, if any. |
213 |
if ((p = strchr(temp, '.')) != NULL) { |
|
214 |
strcpy(encoding_variant, p); /* Copy the leading '.' */ |
|
215 |
*p = '\0'; |
|
216 |
} else if ((p = strchr(temp, '@')) != NULL) { |
|
217 |
strcpy(encoding_variant, p); /* Copy the leading '@' */ |
|
218 |
*p = '\0'; |
|
219 |
} |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
220 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
221 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
222 |
language = temp; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
223 |
if ((country = strchr(temp, '_')) != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
224 |
*country++ = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
225 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
226 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
227 |
p = encoding_variant; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
228 |
if ((encoding = strchr(p, '.')) != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
229 |
p[encoding++ - p] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
230 |
p = encoding; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
231 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
232 |
if ((variant = strchr(p, '@')) != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
233 |
p[variant++ - p] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
234 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
235 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
236 |
/* Normalize the language name */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
237 |
if (std_language != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
238 |
*std_language = "en"; |
7248
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
239 |
if (language != NULL && mapLookup(language_names, language, std_language) == 0) { |
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
240 |
*std_language = malloc(strlen(language)+1); |
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
241 |
strcpy(*std_language, language); |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
242 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
243 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
244 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
245 |
/* Normalize the country name */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
246 |
if (std_country != NULL && country != NULL) { |
7248
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
247 |
if (mapLookup(country_names, country, std_country) == 0) { |
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
248 |
*std_country = malloc(strlen(country)+1); |
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
249 |
strcpy(*std_country, country); |
6a95f692e203
6997999: Remove duplicated entries from ISO language/country code tables
naoto
parents:
7018
diff
changeset
|
250 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
251 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
252 |
|
7017 | 253 |
/* Normalize the script and variant name. Note that we only use |
254 |
* variants listed in the mapping array; others are ignored. |
|
255 |
*/ |
|
256 |
if (variant != NULL) { |
|
257 |
if (std_script != NULL) { |
|
258 |
mapLookup(script_names, variant, std_script); |
|
259 |
} |
|
260 |
||
261 |
if (std_variant != NULL) { |
|
262 |
mapLookup(variant_names, variant, std_variant); |
|
263 |
} |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
264 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
265 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
266 |
/* Normalize the encoding name. Note that we IGNORE the string |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
267 |
* 'encoding' extracted from the locale name above. Instead, we use the |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
268 |
* more reliable method of calling nl_langinfo(CODESET). This function |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
269 |
* returns an empty string if no encoding is set for the given locale |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
270 |
* (e.g., the C or POSIX locales); we use the default ISO 8859-1 |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
271 |
* converter for such locales. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
272 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
273 |
if (std_encoding != NULL) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
274 |
/* OK, not so reliable - nl_langinfo() gives wrong answers on |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
275 |
* Euro locales, in particular. */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
276 |
if (strcmp(p, "ISO8859-15") == 0) |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
277 |
p = "ISO8859-15"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
278 |
else |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
279 |
p = nl_langinfo(CODESET); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
280 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
281 |
/* Convert the bare "646" used on Solaris to a proper IANA name */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
282 |
if (strcmp(p, "646") == 0) |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
283 |
p = "ISO646-US"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
284 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
285 |
/* return same result nl_langinfo would return for en_UK, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
286 |
* in order to use optimizations. */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
287 |
*std_encoding = (*p != '\0') ? p : "ISO8859-1"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
288 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
289 |
#ifdef __linux__ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
290 |
/* |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
291 |
* Remap the encoding string to a different value for japanese |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
292 |
* locales on linux so that customized converters are used instead |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
293 |
* of the default converter for "EUC-JP". The customized converters |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
294 |
* omit support for the JIS0212 encoding which is not supported by |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
295 |
* the variant of "EUC-JP" encoding used on linux |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
296 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
297 |
if (strcmp(p, "EUC-JP") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
298 |
*std_encoding = "EUC-JP-LINUX"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
299 |
} |
50992
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
300 |
#endif |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
301 |
|
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
302 |
#ifdef _AIX |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
303 |
if (strcmp(p, "big5") == 0) { |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
304 |
/* On AIX Traditional Chinese Big5 codeset is mapped to IBM-950 */ |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
305 |
*std_encoding = "IBM-950"; |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
306 |
} else if (strcmp(p, "IBM-943") == 0) { |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
307 |
/* |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
308 |
* On AIX, IBM-943 is mapped to IBM-943C in which symbol 'yen' and |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
309 |
* 'overline' are replaced with 'backslash' and 'tilde' from ASCII |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
310 |
* making first 96 code points same as ASCII. |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
311 |
*/ |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
312 |
*std_encoding = "IBM-943C"; |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
313 |
} |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
314 |
#endif |
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
315 |
|
faf1cd52a5b7
8202329: [AIX] Fix codepage mappings for IBM-943 and Big5
simonis
parents:
47216
diff
changeset
|
316 |
#ifdef __solaris__ |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
317 |
if (strcmp(p,"eucJP") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
318 |
/* For Solaris use customized vendor defined character |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
319 |
* customized EUC-JP converter |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
320 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
321 |
*std_encoding = "eucJP-open"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
322 |
} else if (strcmp(p, "Big5") == 0 || strcmp(p, "BIG5") == 0) { |
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 |
* Remap the encoding string to Big5_Solaris which augments |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
325 |
* the default converter for Solaris Big5 locales to include |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
326 |
* seven additional ideographic characters beyond those included |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
327 |
* in the Java "Big5" converter. |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
328 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
329 |
*std_encoding = "Big5_Solaris"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
330 |
} else if (strcmp(p, "Big5-HKSCS") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
331 |
/* |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
332 |
* Solaris uses HKSCS2001 |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
333 |
*/ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
334 |
*std_encoding = "Big5-HKSCS-2001"; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
335 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
336 |
#endif |
19197
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
337 |
#ifdef MACOSX |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
338 |
/* |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
339 |
* For the case on MacOS X where encoding is set to US-ASCII, but we |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
340 |
* don't have any encoding hints from LANG/LC_ALL/LC_CTYPE, use UTF-8 |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
341 |
* instead. |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
342 |
* |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
343 |
* The contents of ASCII files will still be read and displayed |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
344 |
* correctly, but so will files containing UTF-8 characters beyond the |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
345 |
* standard ASCII range. |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
346 |
* |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
347 |
* Specifically, this allows apps launched by double-clicking a .jar |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
348 |
* file to correctly read UTF-8 files using the default encoding (see |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
349 |
* 8011194). |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
350 |
*/ |
51854
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
351 |
const char* env_lang = getenv("LANG"); |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
352 |
const char* env_lc_all = getenv("LC_ALL"); |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
353 |
const char* env_lc_ctype = getenv("LC_CTYPE"); |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
354 |
|
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
355 |
if (strcmp(p,"US-ASCII") == 0 && |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
356 |
(env_lang == NULL || strlen(env_lang) == 0) && |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
357 |
(env_lc_all == NULL || strlen(env_lc_all) == 0) && |
3c6d285c8168
8072130: java/lang/instrument/BootClassPath/BootClassPathTest.sh fails on Mac OSX
bchristi
parents:
50992
diff
changeset
|
358 |
(env_lc_ctype == NULL || strlen(env_lc_ctype) == 0)) { |
19197
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
359 |
*std_encoding = "UTF-8"; |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
360 |
} |
f557ac307d1b
8011194: Apps launched via double-clicked .jars have file.encoding value of US-ASCII on Mac OS X
bchristi
parents:
16041
diff
changeset
|
361 |
#endif |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
362 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
363 |
|
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
364 |
free(temp); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
365 |
free(encoding_variant); |
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
366 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
367 |
return 1; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
368 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
369 |
|
2 | 370 |
/* This function gets called very early, before VM_CALLS are setup. |
371 |
* Do not use any of the VM_CALLS entries!!! |
|
372 |
*/ |
|
373 |
java_props_t * |
|
374 |
GetJavaProperties(JNIEnv *env) |
|
375 |
{ |
|
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
376 |
static java_props_t sprops; |
2 | 377 |
char *v; /* tmp var */ |
378 |
||
379 |
if (sprops.user_dir) { |
|
380 |
return &sprops; |
|
381 |
} |
|
382 |
||
383 |
/* tmp dir */ |
|
384 |
sprops.tmp_dir = P_tmpdir; |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
385 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
386 |
/* darwin has a per-user temp dir */ |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
387 |
static char tmp_path[PATH_MAX]; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
388 |
int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, tmp_path, PATH_MAX); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
389 |
if (pathSize > 0 && pathSize <= PATH_MAX) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
390 |
sprops.tmp_dir = tmp_path; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
391 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
392 |
#endif /* MACOSX */ |
2 | 393 |
|
394 |
/* patches/service packs installed */ |
|
52478
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
395 |
sprops.patch_level = NULL; // leave it undefined |
2 | 396 |
|
21130 | 397 |
/* Java 2D/AWT properties */ |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
398 |
#ifdef MACOSX |
54865
99337f94b04d
8130266: Change the mechanism by which JDK loads the platform-specific GraphicsEnvironment class
prr
parents:
54858
diff
changeset
|
399 |
// Always the same Toolkit on Mac OS X |
21130 | 400 |
sprops.awt_toolkit = "sun.lwawt.macosx.LWCToolkit"; |
401 |
#else |
|
9002 | 402 |
sprops.awt_toolkit = "sun.awt.X11.XToolkit"; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
403 |
#endif |
2 | 404 |
|
405 |
#ifdef SI_ISALIST |
|
406 |
/* supported instruction sets */ |
|
407 |
{ |
|
408 |
char list[258]; |
|
409 |
sysinfo(SI_ISALIST, list, sizeof(list)); |
|
410 |
sprops.cpu_isalist = strdup(list); |
|
411 |
} |
|
412 |
#else |
|
413 |
sprops.cpu_isalist = NULL; |
|
414 |
#endif |
|
415 |
||
416 |
/* endianness of platform */ |
|
417 |
{ |
|
418 |
unsigned int endianTest = 0xff000000; |
|
419 |
if (((char*)(&endianTest))[0] != 0) |
|
420 |
sprops.cpu_endian = "big"; |
|
421 |
else |
|
422 |
sprops.cpu_endian = "little"; |
|
423 |
} |
|
424 |
||
425 |
/* os properties */ |
|
426 |
{ |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
427 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
428 |
setOSNameAndVersion(&sprops); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
429 |
#else |
2 | 430 |
struct utsname name; |
431 |
uname(&name); |
|
432 |
sprops.os_name = strdup(name.sysname); |
|
31875 | 433 |
#ifdef _AIX |
434 |
{ |
|
435 |
char *os_version = malloc(strlen(name.version) + |
|
436 |
strlen(name.release) + 2); |
|
437 |
if (os_version != NULL) { |
|
438 |
strcpy(os_version, name.version); |
|
439 |
strcat(os_version, "."); |
|
440 |
strcat(os_version, name.release); |
|
441 |
} |
|
442 |
sprops.os_version = os_version; |
|
443 |
} |
|
444 |
#else |
|
2 | 445 |
sprops.os_version = strdup(name.release); |
31875 | 446 |
#endif /* _AIX */ |
447 |
#endif /* MACOSX */ |
|
2 | 448 |
|
449 |
sprops.os_arch = ARCHPROPNAME; |
|
450 |
} |
|
451 |
||
16041
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
452 |
/* ABI property (optional) */ |
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
453 |
#ifdef JDK_ARCH_ABI_PROP_NAME |
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
454 |
sprops.sun_arch_abi = JDK_ARCH_ABI_PROP_NAME; |
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
455 |
#endif |
b9d38accf302
8005545: Add System property to identify ARCH specific details such as ARM hard-float binaries
vladidan
parents:
15004
diff
changeset
|
456 |
|
2 | 457 |
/* Determine the language, country, variant, and encoding from the host, |
458 |
* and store these in the user.language, user.country, user.variant and |
|
459 |
* file.encoding system properties. */ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
460 |
setlocale(LC_ALL, ""); |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
461 |
if (ParseLocale(env, LC_CTYPE, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
462 |
&(sprops.format_language), |
7017 | 463 |
&(sprops.format_script), |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
464 |
&(sprops.format_country), |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
465 |
&(sprops.format_variant), |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
466 |
&(sprops.encoding))) { |
13405
69267890f7d9
6844255: Potential stack corruption in GetJavaProperties
omajid
parents:
12818
diff
changeset
|
467 |
ParseLocale(env, LC_MESSAGES, |
52478
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
468 |
&(sprops.display_language), |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
469 |
&(sprops.display_script), |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
470 |
&(sprops.display_country), |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
471 |
&(sprops.display_variant), |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
472 |
NULL); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
473 |
} else { |
52478
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
474 |
sprops.display_language = "en"; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
475 |
sprops.encoding = "ISO8859-1"; |
2 | 476 |
} |
15004
cf5d2d5094cc
8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents:
14342
diff
changeset
|
477 |
|
22641
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
478 |
/* ParseLocale failed with OOME */ |
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
479 |
JNU_CHECK_EXCEPTION_RETURN(env, NULL); |
e47f8892133e
8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues
alanb
parents:
21130
diff
changeset
|
480 |
|
15004
cf5d2d5094cc
8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents:
14342
diff
changeset
|
481 |
#ifdef MACOSX |
cf5d2d5094cc
8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents:
14342
diff
changeset
|
482 |
sprops.sun_jnu_encoding = "UTF-8"; |
cf5d2d5094cc
8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents:
14342
diff
changeset
|
483 |
#else |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
484 |
sprops.sun_jnu_encoding = sprops.encoding; |
15004
cf5d2d5094cc
8003228: (props) sun.jnu.encoding should be set to UTF-8 [macosx]
bchristi
parents:
14342
diff
changeset
|
485 |
#endif |
2 | 486 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
487 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
488 |
#if BYTE_ORDER == _LITTLE_ENDIAN |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
489 |
sprops.unicode_encoding = "UnicodeLittle"; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
490 |
#else |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
491 |
sprops.unicode_encoding = "UnicodeBig"; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
492 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
493 |
#else /* !_ALLBSD_SOURCE */ |
2 | 494 |
#ifdef __linux__ |
495 |
#if __BYTE_ORDER == __LITTLE_ENDIAN |
|
496 |
sprops.unicode_encoding = "UnicodeLittle"; |
|
497 |
#else |
|
498 |
sprops.unicode_encoding = "UnicodeBig"; |
|
499 |
#endif |
|
500 |
#else |
|
501 |
sprops.unicode_encoding = "UnicodeBig"; |
|
502 |
#endif |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
503 |
#endif /* _ALLBSD_SOURCE */ |
2 | 504 |
|
505 |
/* user properties */ |
|
506 |
{ |
|
507 |
struct passwd *pwent = getpwuid(getuid()); |
|
508 |
sprops.user_name = pwent ? strdup(pwent->pw_name) : "?"; |
|
19857
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
509 |
#ifdef MACOSX |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
510 |
setUserHome(&sprops); |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
511 |
#else |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
512 |
sprops.user_home = pwent ? strdup(pwent->pw_dir) : NULL; |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
513 |
#endif |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
514 |
if (sprops.user_home == NULL) { |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
515 |
sprops.user_home = "?"; |
d3a868255edb
7199674: (props) user.home property does not return an accessible location in sandboxed environment [macosx]
bchristi
parents:
19197
diff
changeset
|
516 |
} |
2 | 517 |
} |
518 |
||
52478
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
519 |
/* User TIMEZONE |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
520 |
* We defer setting up timezone until it's actually necessary. |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
521 |
* Refer to TimeZone.getDefault(). The system property |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
522 |
* is able to be set by the command line interface -Duser.timezone. |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
523 |
*/ |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51854
diff
changeset
|
524 |
tzset(); /* for compatibility */ |
2 | 525 |
|
526 |
/* Current directory */ |
|
527 |
{ |
|
528 |
char buf[MAXPATHLEN]; |
|
529 |
errno = 0; |
|
530 |
if (getcwd(buf, sizeof(buf)) == NULL) |
|
531 |
JNU_ThrowByName(env, "java/lang/Error", |
|
532 |
"Properties init: Could not determine current working directory."); |
|
533 |
else |
|
534 |
sprops.user_dir = strdup(buf); |
|
535 |
} |
|
536 |
||
537 |
sprops.file_separator = "/"; |
|
538 |
sprops.path_separator = ":"; |
|
539 |
sprops.line_separator = "\n"; |
|
540 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
541 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
542 |
setProxyProperties(&sprops); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11665
diff
changeset
|
543 |
#endif |
2 | 544 |
|
545 |
return &sprops; |
|
546 |
} |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
547 |
|
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
548 |
jstring |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
549 |
GetStringPlatform(JNIEnv *env, nchar* cstr) |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
550 |
{ |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
551 |
return JNU_NewStringPlatform(env, cstr); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
552 |
} |