diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-13 16:47:15 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-13 16:47:15 +0200 |
commit | 07a9c704fc6b0022a06597c514019e12466711c4 (patch) | |
tree | 0fa969f9248aa19b3a33185865fc202c83c62dbd /comphelper/source | |
parent | 8c72ab48bf150da05435d93991e1e9c9f47ce4fd (diff) |
Revert "cppcheck: variableScope"
This reverts the updater related code changes. I still might need to
merge Mozilla changes into the code once more which becomes much more difficult
with unrelated changes.
Only helpful fixes for now please.
Change-Id: I67b386d12d03250323cce21f4f65b262ce4abcf9
Diffstat (limited to 'comphelper/source')
-rw-r--r-- | comphelper/source/windows/windows_process.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/comphelper/source/windows/windows_process.cxx b/comphelper/source/windows/windows_process.cxx index ccebbd712bf0..1c782d7a289f 100644 --- a/comphelper/source/windows/windows_process.cxx +++ b/comphelper/source/windows/windows_process.cxx @@ -19,6 +19,7 @@ */ static int ArgStrLen(const wchar_t *s) { + int backslashes = 0; int i = wcslen(s); BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr; // Only add doublequotes if the string contains a space or a tab @@ -31,7 +32,6 @@ static int ArgStrLen(const wchar_t *s) if (hasDoubleQuote) { - int backslashes = 0; while (*s) { if (*s == '\\') @@ -67,6 +67,7 @@ static int ArgStrLen(const wchar_t *s) */ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) { + int backslashes = 0; BOOL hasDoubleQuote = wcschr(s, L'"') != nullptr; // Only add doublequotes if the string contains a space or a tab BOOL addDoubleQuotes = wcspbrk(s, L" \t") != nullptr; @@ -79,7 +80,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) if (hasDoubleQuote) { - int backslashes = 0; + int i; while (*s) { if (*s == '\\') @@ -91,7 +92,7 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) if (*s == '"') { // Escape the doublequote and all backslashes preceding the doublequote - for (int i = 0; i <= backslashes; ++i) + for (i = 0; i <= backslashes; ++i) { *d = '\\'; ++d; @@ -130,10 +131,11 @@ static wchar_t* ArgToString(wchar_t *d, const wchar_t *s) wchar_t* MakeCommandLine(int argc, wchar_t **argv) { + int i; int len = 0; // The + 1 of the last argument handles the allocation for null termination - for (int i = 0; i < argc; ++i) + for (i = 0; i < argc; ++i) len += ArgStrLen(argv[i]) + 1; // Protect against callers that pass 0 arguments @@ -145,7 +147,7 @@ MakeCommandLine(int argc, wchar_t **argv) return nullptr; wchar_t *c = s; - for (int i = 0; i < argc; ++i) + for (i = 0; i < argc; ++i) { c = ArgToString(c, argv[i]); if (i + 1 != argc) |