public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: gcc-patches@gcc.gnu.org
Cc: java-patches@gcc.gnu.org
Subject: [libjava] Fix md5test, shatest on Tru64 UNIX with native libiconv (PR libgcj/49314)
Date: Tue, 21 Jun 2011 13:55:00 -0000	[thread overview]
Message-ID: <yddpqm7i90w.fsf@manam.CeBiTec.Uni-Bielefeld.DE> (raw)

As described in the PR, unless the UTF-8 encoding of \ufeff is padded
with a NUL byte, the iconv_init test fails for the native Tru64 UNIX
libiconv, iconv_byte_swap isn't set correctly and later iconv calls
fail.  This patch fixes this, allowing the arraycopy testcase in the PR
and the actual md5test and shatest testcases to succeed.  This way, I
get clean libjava testsuite results.

Tested by rebuilding libgcj.so with the fixed natIconv.cc.  A full
rebuild and test of libgcj is currently running on alpha-dec-osf5.1b.

Ok for mainline if it passes?

Thanks.
	Rainer


2011-06-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libgcj/49314
	* gnu/gcj/convert/natIconv.cc (iconv_init): Pad in[] with NUL byte.

diff --git a/libjava/gnu/gcj/convert/natIconv.cc b/libjava/gnu/gcj/convert/natIconv.cc
--- a/libjava/gnu/gcj/convert/natIconv.cc
+++ b/libjava/gnu/gcj/convert/natIconv.cc
@@ -1,6 +1,6 @@
 // natIconv.cc -- Java side of iconv() reader.
 
-/* Copyright (C) 2000, 2001, 2003, 2006  Free Software Foundation
+/* Copyright (C) 2000, 2001, 2003, 2006, 2011  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -264,17 +264,19 @@ gnu::gcj::convert::IOConverter::iconv_in
   if (handle != (iconv_t) -1)
     {
       jchar c;
-      unsigned char in[3];
+      unsigned char in[4];
       char *inp, *outp;
       size_t inc, outc, r;
 
-      // This is the UTF-8 encoding of \ufeff.
+      // 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 = 3;
+      inc = 4;
       outp = (char *) &c;
       outc = 2;
 

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

                 reply	other threads:[~2011-06-21 13:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yddpqm7i90w.fsf@manam.CeBiTec.Uni-Bielefeld.DE \
    --to=ro@cebitec.uni-bielefeld.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=java-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).