diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-06-09 12:02:48 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-06-09 12:02:48 +0000 |
commit | f2459ee02f5cc384d0254bee7d16101056ae0fbd (patch) | |
tree | ed80cbb952836e7cc9e911cb41c1c9970411fe19 /desktop/win32/source/extendloaderenvironment.hxx | |
parent | fab6aeaeab4cd18ac0ce104f3b990963619c24f7 (diff) |
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
Diffstat (limited to 'desktop/win32/source/extendloaderenvironment.hxx')
-rw-r--r-- | desktop/win32/source/extendloaderenvironment.hxx | 41 |
1 files changed, 40 insertions, 1 deletions
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 <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: // |