diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2010-11-11 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:04 +0300 |
commit | b75af1bba61529be6787dc470f9db60906a182e5 (patch) | |
tree | 9e0ffa6bd9ed8ac72856630225cfe07cbc63cede /CPP/Common | |
parent | c65230d8585317f7cd58ae2982067385269fdee9 (diff) |
9.199.19
Diffstat (limited to 'CPP/Common')
-rwxr-xr-x | CPP/Common/CommandLineParser.cpp | 19 | ||||
-rwxr-xr-x | CPP/Common/CommandLineParser.h | 6 | ||||
-rwxr-xr-x | CPP/Common/Wildcard.cpp | 2 |
3 files changed, 13 insertions, 14 deletions
diff --git a/CPP/Common/CommandLineParser.cpp b/CPP/Common/CommandLineParser.cpp index 6de5e63b..80b467fc 100755 --- a/CPP/Common/CommandLineParser.cpp +++ b/CPP/Common/CommandLineParser.cpp @@ -6,7 +6,7 @@ namespace NCommandLineParser { -void SplitCommandLine(const UString &src, UString &dest1, UString &dest2) +bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2) { dest1.Empty(); dest2.Empty(); @@ -15,17 +15,17 @@ void SplitCommandLine(const UString &src, UString &dest1, UString &dest2) for (i = 0; i < src.Length(); i++) { wchar_t c = src[i]; - if (c == L'\"') - quoteMode = !quoteMode; - else if (c == L' ' && !quoteMode) + if (c == L' ' && !quoteMode) { - i++; - break; + dest2 = src.Mid(i + 1); + return i != 0; } + if (c == L'\"') + quoteMode = !quoteMode; else dest1 += c; } - dest2 = src.Mid(i); + return i != 0; } void SplitCommandLine(const UString &s, UStringVector &parts) @@ -36,10 +36,7 @@ void SplitCommandLine(const UString &s, UStringVector &parts) for (;;) { UString s1, s2; - SplitCommandLine(sTemp, s1, s2); - // s1.Trim(); - // s2.Trim(); - if (!s1.IsEmpty()) + if (SplitCommandLine(sTemp, s1, s2)) parts.Add(s1); if (s2.IsEmpty()) break; diff --git a/CPP/Common/CommandLineParser.h b/CPP/Common/CommandLineParser.h index c57da9c4..3d0b41dd 100755 --- a/CPP/Common/CommandLineParser.h +++ b/CPP/Common/CommandLineParser.h @@ -1,13 +1,13 @@ // Common/CommandLineParser.h -#ifndef __COMMON_COMMANDLINEPARSER_H -#define __COMMON_COMMANDLINEPARSER_H +#ifndef __COMMON_COMMAND_LINE_PARSER_H +#define __COMMON_COMMAND_LINE_PARSER_H #include "MyString.h" namespace NCommandLineParser { -void SplitCommandLine(const UString &src, UString &dest1, UString &dest2); +bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2); void SplitCommandLine(const UString &s, UStringVector &parts); namespace NSwitchType { diff --git a/CPP/Common/Wildcard.cpp b/CPP/Common/Wildcard.cpp index ac77e39b..476ddebd 100755 --- a/CPP/Common/Wildcard.cpp +++ b/CPP/Common/Wildcard.cpp @@ -374,6 +374,8 @@ int CCensor::FindPrefix(const UString &prefix) const void CCensor::AddItem(bool include, const UString &path, bool recursive) { UStringVector pathParts; + if (path.IsEmpty()) + throw "Empty file path"; SplitPathToParts(path, pathParts); bool forFile = true; if (pathParts.Back().IsEmpty()) |