From 1ca1c91bd9800301188e167d169dfde8947b4f54 Mon Sep 17 00:00:00 2001 From: Tom 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. From-SVN: r47862 --- libjava/ChangeLog | 6 ++++++ libjava/prims.cc | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index eb5742ab724..227bcc12196 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/libjava/prims.cc b/libjava/prims.cc index f2f2d6578a2..5a4c3a6cbd8 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