mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-07 18:06:55 -06:00
Update to 7-Zip 17.00 Beta
This commit is contained in:
@@ -4,20 +4,6 @@
|
||||
|
||||
#include "CommandLineParser.h"
|
||||
|
||||
static bool IsString1PrefixedByString2_NoCase(const wchar_t *u, const char *a)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char c = *a;
|
||||
if (c == 0)
|
||||
return true;
|
||||
if ((unsigned char)MyCharLower_Ascii(c) != MyCharLower_Ascii(*u))
|
||||
return false;
|
||||
a++;
|
||||
u++;
|
||||
}
|
||||
}
|
||||
|
||||
namespace NCommandLineParser {
|
||||
|
||||
bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
|
||||
@@ -44,7 +30,7 @@ bool SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
|
||||
|
||||
void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
{
|
||||
UString sTemp = s;
|
||||
UString sTemp (s);
|
||||
sTemp.Trim();
|
||||
parts.Clear();
|
||||
for (;;)
|
||||
@@ -59,18 +45,17 @@ void SplitCommandLine(const UString &s, UStringVector &parts)
|
||||
}
|
||||
|
||||
|
||||
static const char *kStopSwitchParsing = "--";
|
||||
static const char * const kStopSwitchParsing = "--";
|
||||
|
||||
static bool inline IsItSwitchChar(wchar_t c)
|
||||
{
|
||||
return (c == '-');
|
||||
}
|
||||
|
||||
CParser::CParser(unsigned numSwitches):
|
||||
_numSwitches(numSwitches),
|
||||
_switches(0)
|
||||
CParser::CParser():
|
||||
_switches(NULL),
|
||||
StopSwitchIndex(-1)
|
||||
{
|
||||
_switches = new CSwitchResult[numSwitches];
|
||||
}
|
||||
|
||||
CParser::~CParser()
|
||||
@@ -81,7 +66,7 @@ CParser::~CParser()
|
||||
|
||||
// if (s) contains switch then function updates switch structures
|
||||
// out: true, if (s) is a switch
|
||||
bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms, unsigned numSwitches)
|
||||
{
|
||||
if (s.IsEmpty() || !IsItSwitchChar(s[0]))
|
||||
return false;
|
||||
@@ -90,13 +75,13 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
unsigned switchIndex = 0;
|
||||
int maxLen = -1;
|
||||
|
||||
for (unsigned i = 0; i < _numSwitches; i++)
|
||||
for (unsigned i = 0; i < numSwitches; i++)
|
||||
{
|
||||
const char *key = switchForms[i].Key;
|
||||
const char * const key = switchForms[i].Key;
|
||||
unsigned switchLen = MyStringLen(key);
|
||||
if ((int)switchLen <= maxLen || pos + switchLen > s.Len())
|
||||
continue;
|
||||
if (IsString1PrefixedByString2_NoCase((const wchar_t *)s + pos, key))
|
||||
if (IsString1PrefixedByString2_NoCase_Ascii((const wchar_t *)s + pos, key))
|
||||
{
|
||||
switchIndex = i;
|
||||
maxLen = switchLen;
|
||||
@@ -161,8 +146,10 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
break;
|
||||
|
||||
case NSwitchType::kString:
|
||||
sw.PostStrings.Add((const wchar_t *)s + pos);
|
||||
{
|
||||
sw.PostStrings.Add(s.Ptr(pos));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos != s.Len())
|
||||
@@ -173,23 +160,30 @@ bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CParser::ParseStrings(const CSwitchForm *switchForms, const UStringVector &commandStrings)
|
||||
|
||||
bool CParser::ParseStrings(const CSwitchForm *switchForms, unsigned numSwitches, const UStringVector &commandStrings)
|
||||
{
|
||||
StopSwitchIndex = -1;
|
||||
ErrorMessage.Empty();
|
||||
ErrorLine.Empty();
|
||||
bool stopSwitch = false;
|
||||
NonSwitchStrings.Clear();
|
||||
delete []_switches;
|
||||
_switches = NULL;
|
||||
_switches = new CSwitchResult[numSwitches];
|
||||
|
||||
FOR_VECTOR (i, commandStrings)
|
||||
{
|
||||
const UString &s = commandStrings[i];
|
||||
if (!stopSwitch)
|
||||
if (StopSwitchIndex < 0)
|
||||
{
|
||||
if (s.IsEqualTo(kStopSwitchParsing))
|
||||
{
|
||||
stopSwitch = true;
|
||||
StopSwitchIndex = NonSwitchStrings.Size();
|
||||
continue;
|
||||
}
|
||||
if (!s.IsEmpty() && IsItSwitchChar(s[0]))
|
||||
{
|
||||
if (ParseString(s, switchForms))
|
||||
if (ParseString(s, switchForms, numSwitches))
|
||||
continue;
|
||||
ErrorLine = s;
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user