From 9e1687143cafca22c81037529c1d8cfe2048340b Mon Sep 17 00:00:00 2001 From: tromey Date: Tue, 11 Dec 2001 04:03:57 +0000 Subject: [PATCH] For PR libgcj/1147: * prims.cc (JvConvertArgv): Convert using current locale's encoding. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47862 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 6 ++++++ libjava/prims.cc | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index eb5742a..227bcc1 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,11 @@ 2001-12-10 Tom Tromey + For PR libgcj/1147: + * prims.cc (JvConvertArgv): Convert using current locale's + encoding. + +2001-12-10 Tom Tromey + Fix for PR libgcj/5064. * java/lang/natClassLoader.cc: Don't include stdio.h. (_Jv_RegisterClassHookDefault): Don't use snprintf. diff --git a/libjava/prims.cc b/libjava/prims.cc index f2f2d65..5a4c3a6 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -657,12 +657,20 @@ JvConvertArgv (int argc, const char **argv) if (argc < 0) argc = 0; jobjectArray ar = JvNewObjectArray(argc, &StringClass, NULL); - jobject* ptr = elements(ar); + jobject *ptr = elements(ar); + jbyteArray bytes = NULL; for (int i = 0; i < argc; i++) { const char *arg = argv[i]; - // FIXME - should probably use JvNewStringUTF. - *ptr++ = JvNewStringLatin1(arg, strlen(arg)); + int len = strlen (arg); + if (bytes == NULL || bytes->length < len) + bytes = JvNewByteArray (len); + jbyte *bytePtr = elements (bytes); + // We assume jbyte == char. + memcpy (bytePtr, arg, len); + + // Now convert using the default encoding. + *ptr++ = new java::lang::String (bytes, 0, len); } return (JArray*) ar; } @@ -993,7 +1001,7 @@ _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv, runtime = java::lang::Runtime::getRuntime (); arg_vec = JvConvertArgv (argc - 1, argv + 1); - + if (klass) main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec); else -- 2.7.4