simplify
This commit is contained in:
@@ -74,11 +74,12 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
CStringArray parts;
|
CStringArray parts;
|
||||||
|
|
||||||
split(line, ":", parts);
|
split(line, ":", parts);
|
||||||
|
nextLine++;
|
||||||
|
|
||||||
#pragma mark LABEL
|
#pragma mark LABEL
|
||||||
if (parts[0] == "LABEL")
|
if (parts[0] == "LABEL")
|
||||||
{
|
{
|
||||||
printf("%u: %s\n", nextLine, line.c_str());
|
printf("%u: %s\n", nextLine - 1, line.c_str());
|
||||||
if (parts.size() != 2)
|
if (parts.size() != 2)
|
||||||
goto error;
|
goto error;
|
||||||
if (mDoGoto && parts[1] == mLabel)
|
if (mDoGoto && parts[1] == mLabel)
|
||||||
@@ -86,17 +87,14 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
mDoGoto = false;
|
mDoGoto = false;
|
||||||
mLabel = "";
|
mLabel = "";
|
||||||
}
|
}
|
||||||
mLabels[parts[1]] = ++nextLine; // set mLabel to be the next line
|
mLabels[parts[1]] = nextLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDoGoto)
|
if (mDoGoto)
|
||||||
{
|
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
printf("%u: %s\n", nextLine, line.c_str());
|
printf("%u: %s\n", nextLine - 1, line.c_str());
|
||||||
|
|
||||||
#pragma mark FILE
|
#pragma mark FILE
|
||||||
if (parts[0] == "FILE")
|
if (parts[0] == "FILE")
|
||||||
@@ -137,7 +135,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
(*mHandleFile)(file, dir, mPath, true);
|
(*mHandleFile)(file, dir, mPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +144,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 3)
|
if (parts.size() != 3)
|
||||||
goto error;
|
goto error;
|
||||||
mVars[parts[2]] = (*mGetPath)(parts[1]);
|
mVars[parts[2]] = (*mGetPath)(parts[1]);
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +152,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
{
|
{
|
||||||
if (parts.size() != 3)
|
if (parts.size() != 3)
|
||||||
goto error;
|
goto error;
|
||||||
++nextLine;
|
|
||||||
if (!ResolveConditional(parts[2]))
|
if (!ResolveConditional(parts[2]))
|
||||||
return;
|
return;
|
||||||
CString path = ResolveVar(parts[1]);
|
CString path = ResolveVar(parts[1]);
|
||||||
@@ -175,13 +170,11 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 2)
|
if (parts.size() != 2)
|
||||||
goto error;
|
goto error;
|
||||||
mIgnore.insert(ResolveVar(parts[1]));
|
mIgnore.insert(ResolveVar(parts[1]));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mInstalling)
|
if (!mInstalling)
|
||||||
{
|
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark GOTO
|
#pragma mark GOTO
|
||||||
if (parts[0] == "GOTO")
|
if (parts[0] == "GOTO")
|
||||||
@@ -199,7 +192,7 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDoGoto = true;
|
mDoGoto = true;
|
||||||
mReturnStack.push(++nextLine);
|
mReturnStack.push(nextLine);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +207,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
mLabel = parts[3];
|
mLabel = parts[3];
|
||||||
if (mLabel == "")
|
if (mLabel == "")
|
||||||
{
|
{
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mReturnStack.push(nextLine + 1);
|
mReturnStack.push(nextLine + 1);
|
||||||
@@ -225,7 +217,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDoGoto = true;
|
mDoGoto = true;
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +242,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
for (unsigned i=2; i<parts.size(); ++i)
|
for (unsigned i=2; i<parts.size(); ++i)
|
||||||
temp += ResolveVar(parts[i]);
|
temp += ResolveVar(parts[i]);
|
||||||
mVars[parts[1]] = temp;
|
mVars[parts[1]] = temp;
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +255,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
path = mCWD + "/" + path;
|
path = mCWD + "/" + path;
|
||||||
if (mkdir_p(path))
|
if (mkdir_p(path))
|
||||||
(*mError)(strerror(errno));
|
(*mError)(strerror(errno));
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +291,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
(*mError)("%s", strerror(errno));
|
(*mError)("%s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +300,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 3)
|
if (parts.size() != 3)
|
||||||
goto error;
|
goto error;
|
||||||
mConditionals[parts[1]] = (*mAsk)(parts[2]);
|
mConditionals[parts[1]] = (*mAsk)(parts[2]);
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +309,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 2)
|
if (parts.size() != 2)
|
||||||
goto error;
|
goto error;
|
||||||
mConditionals[parts[1]] = (*mAuth)();
|
mConditionals[parts[1]] = (*mAuth)();
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +318,6 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 3)
|
if (parts.size() != 3)
|
||||||
goto error;
|
goto error;
|
||||||
(mEcho)(parts[1], ResolveConditional(parts[2]));
|
(mEcho)(parts[1], ResolveConditional(parts[2]));
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,13 +327,11 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine)
|
|||||||
if (parts.size() != 2)
|
if (parts.size() != 2)
|
||||||
goto error;
|
goto error;
|
||||||
(mPriv)(ResolveConditional(parts[1]));
|
(mPriv)(ResolveConditional(parts[1]));
|
||||||
++nextLine;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
(*mError)("%s is an invalid command", line.c_str());
|
(*mError)("%s is an invalid command", line.c_str());
|
||||||
++nextLine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CString& Processor::ResolveVar(const CString& var)
|
const CString& Processor::ResolveVar(const CString& var)
|
||||||
|
|||||||
Reference in New Issue
Block a user