mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fixes from Alex
This commit is contained in:
parent
280c95fcfe
commit
bb4a4631b5
1 changed files with 53 additions and 35 deletions
|
@ -22,7 +22,7 @@
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
#define DEBUG_MONITOR
|
// #define DEBUG_MONITOR
|
||||||
|
|
||||||
#define PIPE_SIZE 512
|
#define PIPE_SIZE 512
|
||||||
#define MAX_CMD_SIZE 1024
|
#define MAX_CMD_SIZE 1024
|
||||||
|
@ -156,15 +156,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
||||||
jsize len = (*env) -> GetStringUTFLength(env, item);
|
jsize len = (*env) -> GetStringUTFLength(env, item);
|
||||||
int nCpyLen;
|
int nCpyLen;
|
||||||
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
||||||
if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, MAX_CMD_SIZE - nPos)))
|
if(NULL != str)
|
||||||
{
|
{
|
||||||
ThrowByName(env, "java/Exception", "Too long command line");
|
if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, MAX_CMD_SIZE - nPos)))
|
||||||
return 0;
|
{
|
||||||
|
ThrowByName(env, "java/Exception", "Too long command line");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nPos += nCpyLen;
|
||||||
|
szCmdLine[nPos] = ' ';
|
||||||
|
++nPos;
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, item, str);
|
||||||
}
|
}
|
||||||
nPos += nCpyLen;
|
|
||||||
szCmdLine[nPos] = ' ';
|
|
||||||
++nPos;
|
|
||||||
(*env) -> ReleaseStringUTFChars(env, item, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
szCmdLine[nPos] = '\0';
|
szCmdLine[nPos] = '\0';
|
||||||
|
@ -178,15 +181,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
||||||
jsize len = (*env) -> GetStringUTFLength(env, item);
|
jsize len = (*env) -> GetStringUTFLength(env, item);
|
||||||
int nCpyLen;
|
int nCpyLen;
|
||||||
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
||||||
if(0 > (nCpyLen = copyTo(szEnvBlock + nPos, str, len, MAX_ENV_SIZE - nPos - 1)))
|
if(NULL != str)
|
||||||
{
|
{
|
||||||
ThrowByName(env, "java/Exception", "Too many environment variables");
|
if(0 > (nCpyLen = copyTo(szEnvBlock + nPos, str, len, MAX_ENV_SIZE - nPos - 1)))
|
||||||
return 0;
|
{
|
||||||
|
ThrowByName(env, "java/Exception", "Too many environment variables");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nPos += nCpyLen;
|
||||||
|
szEnvBlock[nPos] = '\0';
|
||||||
|
++nPos;
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, item, str);
|
||||||
}
|
}
|
||||||
nPos += nCpyLen;
|
|
||||||
szEnvBlock[nPos] = '\0';
|
|
||||||
++nPos;
|
|
||||||
(*env) -> ReleaseStringUTFChars(env, item, str);
|
|
||||||
}
|
}
|
||||||
szEnvBlock[nPos] = '\0';
|
szEnvBlock[nPos] = '\0';
|
||||||
envBlk = szEnvBlock;
|
envBlk = szEnvBlock;
|
||||||
|
@ -196,9 +202,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
||||||
|
|
||||||
if (dir != 0)
|
if (dir != 0)
|
||||||
{
|
{
|
||||||
const char * str = NULL;
|
const char * str = (*env) -> GetStringUTFChars(env, dir, 0);
|
||||||
cwd = strdup((*env) -> GetStringUTFChars(env, dir, 0));
|
if(NULL != str)
|
||||||
(*env) -> ReleaseStringUTFChars(env, dir, str);
|
{
|
||||||
|
cwd = strdup(str);
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, dir, str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,15 +364,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
|
||||||
jsize len = (*env) -> GetStringUTFLength(env, item);
|
jsize len = (*env) -> GetStringUTFLength(env, item);
|
||||||
int nCpyLen;
|
int nCpyLen;
|
||||||
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
||||||
if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, MAX_CMD_SIZE - nPos)))
|
if(NULL != str)
|
||||||
{
|
{
|
||||||
ThrowByName(env, "java/Exception", "Too long command line");
|
if(0 > (nCpyLen = copyTo(szCmdLine + nPos, str, len, MAX_CMD_SIZE - nPos)))
|
||||||
return 0;
|
{
|
||||||
|
ThrowByName(env, "java/Exception", "Too long command line");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nPos += nCpyLen;
|
||||||
|
szCmdLine[nPos] = ' ';
|
||||||
|
++nPos;
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, item, str);
|
||||||
}
|
}
|
||||||
nPos += nCpyLen;
|
|
||||||
szCmdLine[nPos] = ' ';
|
|
||||||
++nPos;
|
|
||||||
(*env) -> ReleaseStringUTFChars(env, item, str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
szCmdLine[nPos] = '\0';
|
szCmdLine[nPos] = '\0';
|
||||||
|
@ -377,15 +389,18 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
|
||||||
jsize len = (*env) -> GetStringUTFLength(env, item);
|
jsize len = (*env) -> GetStringUTFLength(env, item);
|
||||||
int nCpyLen;
|
int nCpyLen;
|
||||||
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
const char * str = (*env) -> GetStringUTFChars(env, item, 0);
|
||||||
if(0 > (nCpyLen = copyTo(szEnvBlock + nPos, str, len, MAX_ENV_SIZE - nPos - 1)))
|
if(NULL != str)
|
||||||
{
|
{
|
||||||
ThrowByName(env, "java/Exception", "Too many environment variables");
|
if(0 > (nCpyLen = copyTo(szEnvBlock + nPos, str, len, MAX_ENV_SIZE - nPos - 1)))
|
||||||
return 0;
|
{
|
||||||
|
ThrowByName(env, "java/Exception", "Too many environment variables");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nPos += nCpyLen;
|
||||||
|
szEnvBlock[nPos] = '\0';
|
||||||
|
++nPos;
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, item, str);
|
||||||
}
|
}
|
||||||
nPos += nCpyLen;
|
|
||||||
szEnvBlock[nPos] = '\0';
|
|
||||||
++nPos;
|
|
||||||
(*env) -> ReleaseStringUTFChars(env, item, str);
|
|
||||||
}
|
}
|
||||||
szEnvBlock[nPos] = '\0';
|
szEnvBlock[nPos] = '\0';
|
||||||
envBlk = szEnvBlock;
|
envBlk = szEnvBlock;
|
||||||
|
@ -395,9 +410,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
|
||||||
|
|
||||||
if (dir != 0)
|
if (dir != 0)
|
||||||
{
|
{
|
||||||
const char * str = NULL;
|
const char * str = (*env) -> GetStringUTFChars(env, dir, 0);
|
||||||
cwd = strdup((*env) -> GetStringUTFChars(env, dir, 0));
|
if(NULL != str)
|
||||||
(*env) -> ReleaseStringUTFChars(env, dir, str);
|
{
|
||||||
|
cwd = strdup(str);
|
||||||
|
(*env) -> ReleaseStringUTFChars(env, dir, str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue