From f2459ee02f5cc384d0254bee7d16101056ae0fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Timm?= Date: Mon, 9 Jun 2008 12:02:48 +0000 Subject: [PATCH] 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 --- .../win32/source/extendloaderenvironment.hxx | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/desktop/win32/source/extendloaderenvironment.hxx b/desktop/win32/source/extendloaderenvironment.hxx index dd60d2eddea9..f819047401c9 100644 --- a/desktop/win32/source/extendloaderenvironment.hxx +++ b/desktop/win32/source/extendloaderenvironment.hxx @@ -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 + #include #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: //