summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorMohan Embar <gnustuff@thisiscool.com>2006-11-26 19:53:11 +0000
committerMohan Embar <membar@gcc.gnu.org>2006-11-26 19:53:11 +0000
commitbe5f186090ad4b60c38b7dcf9177694dff72dae4 (patch)
treed4ce0649c5fcfcfbcc4b71e2f2d1848ec5eaa67e /libjava
parent03e9913945d7ce039d385e10fbef9f329e41158f (diff)
downloadgcc-be5f186090ad4b60c38b7dcf9177694dff72dae4.tar.gz
re PR libgcj/29151 ([win32] Runtime.exec(String[] cmdarray, String[] envp) -> envp doesn't work)
PR libgcj/29151: * java/lang/natWin32Process.cc (startProcess): Unconditionally create a UNICODE environment for CreateProcess call. From-SVN: r119230
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/lang/natWin32Process.cc20
2 files changed, 17 insertions, 9 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 21ec8473968..ca0ce451e15 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-26 Mohan Embar <gnustuff@thisiscool.com>
+
+ PR libgcj/29151:
+ * java/lang/natWin32Process.cc (startProcess): Unconditionally
+ create a UNICODE environment for CreateProcess call.
+
2006-10-20 Tom Tromey <tromey@redhat.com>
* testsuite/libjava.jvmti/natevents.cc (do_callback_arg_tests):
diff --git a/libjava/java/lang/natWin32Process.cc b/libjava/java/lang/natWin32Process.cc
index 3c1a4f02c8b..1ac3a2abd80 100644
--- a/libjava/java/lang/natWin32Process.cc
+++ b/libjava/java/lang/natWin32Process.cc
@@ -240,8 +240,10 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
}
*cmdLineCurPos = _T('\0');
- // Get the environment, if any.
- LPTSTR env = NULL;
+ // Get the environment, if any. Unconditionally
+ // create a UNICODE environment, even on ANSI
+ // builds.
+ LPWSTR env = NULL;
if (envp)
{
elts = elements (envp);
@@ -250,22 +252,22 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
for (int i = 0; i < envp->length; ++i)
envLen += (elts[i]->length() + 1);
- env = (LPTSTR) _Jv_Malloc ((envLen + 1) * sizeof(TCHAR));
+ env = (LPWSTR) _Jv_Malloc ((envLen + 1) * sizeof(WCHAR));
int j = 0;
for (int i = 0; i < envp->length; ++i)
{
- jint len = elts[i]->length();
+ jstring elt = elts[i];
+ jint len = elt->length();
- JV_TEMP_STRING_WIN32(thiselt, elts[i]);
- _tcscpy(env + j, thiselt);
+ wcsncpy(env + j, (LPCWSTR) JvGetStringChars(elt), len);
j += len;
- // Skip past the null terminator that _tcscpy just inserted.
- j++;
+ // Insert the null terminator and skip past it.
+ env[j++] = 0;
}
- *(env + j) = _T('\0');
+ *(env + j) = 0;
}
// Get the working directory path, if specified.