This is the first part of an effort to allow bootstrapping openjdk without downloading any binaries. The next part will be an openjdk7 package that will be used to bootstrap openjdk8. After that, we can proceed to add the missing parts to go all the way up to 11. [ci skip]
120 lines
3.3 KiB
Diff
120 lines
3.3 KiB
Diff
--- gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc.orig 2014-02-18 18:46:14.897880526 +0200
|
|
+++ gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc 2014-02-18 18:50:08.766613550 +0200
|
|
@@ -24,6 +24,13 @@
|
|
|
|
#ifdef HAVE_ICONV
|
|
#include <iconv.h>
|
|
+#include <endian.h>
|
|
+
|
|
+#if __BYTE_ORDER == __BIG_ENDIAN
|
|
+#define UCS2_CHARSET "UCS-2BE"
|
|
+#else
|
|
+#define UCS2_CHARSET "UCS-2LE"
|
|
+#endif
|
|
|
|
template<typename T>
|
|
static inline size_t
|
|
@@ -45,7 +52,7 @@
|
|
_Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer);
|
|
buffer[len] = '\0';
|
|
|
|
- iconv_t h = iconv_open ("UCS-2", buffer);
|
|
+ iconv_t h = iconv_open (UCS2_CHARSET, buffer);
|
|
if (h == (iconv_t) -1)
|
|
throw new ::java::io::UnsupportedEncodingException (encoding);
|
|
|
|
@@ -99,18 +106,6 @@
|
|
throw new ::java::io::CharConversionException ();
|
|
}
|
|
|
|
- if (iconv_byte_swap)
|
|
- {
|
|
- size_t max = (old_out - outavail) / sizeof (jchar);
|
|
- for (size_t i = 0; i < max; ++i)
|
|
- {
|
|
- // Byte swap.
|
|
- jchar c = (((out[outpos + i] & 0xff) << 8)
|
|
- | ((out[outpos + i] >> 8) & 0xff));
|
|
- outbuf[i] = c;
|
|
- }
|
|
- }
|
|
-
|
|
inpos += old_in - inavail;
|
|
return (old_out - outavail) / sizeof (jchar);
|
|
#else /* HAVE_ICONV */
|
|
@@ -145,7 +140,7 @@
|
|
_Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer);
|
|
buffer[len] = '\0';
|
|
|
|
- iconv_t h = iconv_open (buffer, "UCS-2");
|
|
+ iconv_t h = iconv_open (buffer, UCS2_CHARSET);
|
|
if (h == (iconv_t) -1)
|
|
throw new ::java::io::UnsupportedEncodingException (encoding);
|
|
|
|
@@ -187,20 +182,6 @@
|
|
char *inbuf = (char *) &chars[inpos];
|
|
char *outbuf = (char *) &out[count];
|
|
|
|
- if (iconv_byte_swap)
|
|
- {
|
|
- // Ugly performance penalty -- don't use losing systems!
|
|
- temp_buffer = (jchar *) _Jv_Malloc (inlength * sizeof (jchar));
|
|
- for (int i = 0; i < inlength; ++i)
|
|
- {
|
|
- // Byte swap.
|
|
- jchar c = (((chars[inpos + i] & 0xff) << 8)
|
|
- | ((chars[inpos + i] >> 8) & 0xff));
|
|
- temp_buffer[i] = c;
|
|
- }
|
|
- inbuf = (char *) temp_buffer;
|
|
- }
|
|
-
|
|
size_t loop_old_in = old_in;
|
|
while (1)
|
|
{
|
|
@@ -252,44 +233,7 @@
|
|
jboolean
|
|
gnu::gcj::convert::IOConverter::iconv_init (void)
|
|
{
|
|
- // Some versions of iconv() always return their UCS-2 results in
|
|
- // big-endian order, and they also require UCS-2 inputs to be in
|
|
- // big-endian order. For instance, glibc 2.1.3 does this. If the
|
|
- // UTF-8=>UCS-2 iconv converter has this feature, then we assume
|
|
- // that all UCS-2 converters do. (This might not be the best
|
|
- // heuristic, but is is all we've got.)
|
|
- jboolean result = false;
|
|
-#ifdef HAVE_ICONV
|
|
- iconv_t handle = iconv_open ("UCS-2", "UTF-8");
|
|
- if (handle != (iconv_t) -1)
|
|
- {
|
|
- jchar c;
|
|
- unsigned char in[4];
|
|
- char *inp, *outp;
|
|
- size_t inc, outc, r;
|
|
-
|
|
- // This is the UTF-8 encoding of \ufeff. At least Tru64 UNIX libiconv
|
|
- // needs the trailing NUL byte, otherwise iconv fails with EINVAL.
|
|
- in[0] = 0xef;
|
|
- in[1] = 0xbb;
|
|
- in[2] = 0xbf;
|
|
- in[3] = 0x00;
|
|
-
|
|
- inp = (char *) in;
|
|
- inc = 4;
|
|
- outp = (char *) &c;
|
|
- outc = 2;
|
|
-
|
|
- r = iconv_adapter (iconv, handle, &inp, &inc, &outp, &outc);
|
|
- // Conversion must be complete for us to use the result.
|
|
- if (r != (size_t) -1 && inc == 0 && outc == 0)
|
|
- result = (c != 0xfeff);
|
|
-
|
|
- // Release iconv handle.
|
|
- iconv_close (handle);
|
|
- }
|
|
-#endif /* HAVE_ICONV */
|
|
- return result;
|
|
+ return false;
|
|
}
|
|
|
|
void
|