INTEGRATION: CWS sb87 (1.4.18); FILE MERGED
2008/04/24 13:22:17 sb 1.4.18.2: RESYNC: (1.4-1.5); FILE MERGED 2008/04/11 13:24:08 sb 1.4.18.1: #i87730# ${.verb:...} not needed after all, fixed now with individual backslash escapes instead
This commit is contained in:
parent
fab6aeaeab
commit
f2459ee02f
1 changed files with 40 additions and 1 deletions
|
@ -7,7 +7,7 @@
|
|||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: extendloaderenvironment.hxx,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Revision: 1.6 $
|
||||
*
|
||||
* This file is part of OpenOffice.org.
|
||||
*
|
||||
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "sal/config.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
|
||||
|
@ -40,6 +42,43 @@
|
|||
|
||||
namespace desktop_win32 {
|
||||
|
||||
inline WCHAR * commandLineAppend(
|
||||
WCHAR * buffer, WCHAR const * text, std::size_t length)
|
||||
{
|
||||
wcsncpy(buffer, text, length + 1); // trailing null
|
||||
return buffer + length;
|
||||
}
|
||||
|
||||
inline WCHAR * commandLineAppend(WCHAR * buffer, WCHAR const * text) {
|
||||
return commandLineAppend(buffer, text, wcslen(text));
|
||||
}
|
||||
|
||||
inline WCHAR * commandLineAppendEncoded(WCHAR * buffer, WCHAR const * text) {
|
||||
std::size_t n = 0;
|
||||
for (;;) {
|
||||
WCHAR c = *text++;
|
||||
if (c == L'\0') {
|
||||
break;
|
||||
} else if (c == L'$') {
|
||||
buffer = commandLineAppend(buffer, MY_STRING(L"\\$"));
|
||||
n = 0;
|
||||
} else if (c == L'\\') {
|
||||
buffer = commandLineAppend(buffer, MY_STRING(L"\\\\"));
|
||||
n += 2;
|
||||
} else {
|
||||
*buffer++ = c;
|
||||
n = 0;
|
||||
}
|
||||
}
|
||||
// The command line will continue with a double quote, so double any
|
||||
// preceding backslashes as required by Windows:
|
||||
for (std::size_t i = 0; i < n; ++i) {
|
||||
*buffer++ = L'\\';
|
||||
}
|
||||
*buffer = L'\0';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Set the PATH environment variable in the current (loader) process, so that a
|
||||
// following CreateProcess has the necessary environment:
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue