Bug 455381 - WinCE XPCOM Explicit Unicode API Calls, Wide Char CheckVersion Function nsCommonProcess changes r=bsmedberg

This commit is contained in:
Brad Lassey 2008-12-03 08:41:12 -05:00
Родитель 418f5366f7
Коммит d08b2bd837
1 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@ -106,10 +106,11 @@ nsProcess::Init(nsIFile* executable)
#if defined(XP_WIN)
static int assembleCmdLine(char *const *argv, char **cmdLine)
// out param must be freed by caller
static int assembleCmdLine(char *const *argv, PRUnichar **wideCmdLine)
{
char *const *arg;
char *p, *q;
char *p, *q, **cmdLine;
int cmdLineSize;
int numBackslashes;
int i;
@ -131,7 +132,7 @@ static int assembleCmdLine(char *const *argv, char **cmdLine)
+ 2 /* we quote every argument */
+ 1; /* space in between, or final null */
}
p = *cmdLine = (char *) PR_MALLOC(cmdLineSize);
p = *cmdLine = (char *) PR_MALLOC(cmdLineSize*sizeof(char));
if (p == NULL) {
return -1;
}
@ -205,6 +206,10 @@ static int assembleCmdLine(char *const *argv, char **cmdLine)
}
*p = '\0';
PRInt32 numChars = MultiByteToWideChar(CP_ACP, 0, *cmdLine, -1, NULL, 0);
*wideCmdLine = (PRUnichar *) PR_MALLOC(numChars*sizeof(PRUnichar));
MultiByteToWideChar(CP_ACP, 0, *cmdLine, -1, *wideCmdLine, numChars);
PR_Free(cmdLine);
return 0;
}
#endif
@ -237,10 +242,10 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count,
my_argv[count+1] = NULL;
#if defined(XP_WIN) && !defined (WINCE) /* wince uses nspr */
STARTUPINFO startupInfo;
STARTUPINFOW startupInfo;
PROCESS_INFORMATION procInfo;
BOOL retVal;
char *cmdLine;
PRUnichar *cmdLine;
if (assembleCmdLine(my_argv, &cmdLine) == -1) {
nsMemory::Free(my_argv);
@ -256,20 +261,20 @@ nsProcess::Run(PRBool blocking, const char **args, PRUint32 count,
* not have any effect on non-console applications.
*/
retVal = CreateProcess(NULL,
// const_cast<char*>(mTargetPath.get()),
cmdLine,
NULL, /* security attributes for the new
* process */
NULL, /* security attributes for the primary
* thread in the new process */
FALSE, /* inherit handles */
CREATE_NO_WINDOW, /* creation flags */
NULL, /* env */
NULL, /* current drive and directory */
&startupInfo,
&procInfo
);
retVal = CreateProcessW(NULL,
// const_cast<char*>(mTargetPath.get()),
cmdLine,
NULL, /* security attributes for the new
* process */
NULL, /* security attributes for the primary
* thread in the new process */
FALSE, /* inherit handles */
CREATE_NO_WINDOW, /* creation flags */
NULL, /* env */
NULL, /* current drive and directory */
&startupInfo,
&procInfo
);
PR_Free( cmdLine );
if (blocking) {