Skip to content

Commit 516fd0d

Browse files
committed
Some bug fix: resolves one more parser bug
1 parent 4d4b9b6 commit 516fd0d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

resources/minitscript/tests/string-test.tscript

+7
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@ function: main()
2121
end
2222
console.printLine("\" ABCDEF \"->toLowerCase()->trim(): " + " ABCDEF "->toLowerCase()->trim());
2323
console.printLine("C:\\msys64\\usr\\bin\\bash -c \"export PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig && ")
24+
console.printLine(
25+
"/DEF:" + "linker/Def/File"->replace("/", "\\") +
26+
" " +
27+
"$compilationUnits" +
28+
" " +
29+
"/OUT:" + "library/DLL/File"->replace("/", "\\")
30+
)
2431
end

src/minitscript/minitscript/MinitScript.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -2711,9 +2711,9 @@ const string MinitScript::doStatementPreProcessing(const string& processedStatem
27112711
for (int i = position; i >= 0; i--) {
27122712
auto c = statement[i];
27132713
auto lc = i > 0?statement[i - 1]:'\0';
2714-
if (lc == '\\' && c == '\\') lc = '\0';
2714+
auto llc = i > 1?statement[i - 2]:'\0';
27152715
//
2716-
if ((c == '"' || c == '\'') && lc != '\\') {
2716+
if ((c == '"' || c == '\'') && (lc != '\\' || llc == '\\')) {
27172717
if (quote == '\0') {
27182718
quote = c;
27192719
} else
@@ -2780,13 +2780,14 @@ const string MinitScript::doStatementPreProcessing(const string& processedStatem
27802780
auto squareBracketCount = 0;
27812781
auto curlyBracketCount = 0;
27822782
auto quote = '\0';
2783-
auto lc = '\0';
27842783
string argument;
27852784
length = 0;
27862785
for (auto i = position; i < statement.size(); i++) {
27872786
auto c = statement[i];
2787+
auto lc = i > 0?statement[i - 1]:'\0';
2788+
auto llc = i > 1?statement[i - 2]:'\0';
27882789
// quote?
2789-
if ((c == '"' || c == '\'') && lc != '\\') {
2790+
if ((c == '"' || c == '\'') && (lc != '\\' || llc == '\\')) {
27902791
if (quote == '\0') {
27912792
quote = c;
27922793
} else
@@ -2858,8 +2859,6 @@ const string MinitScript::doStatementPreProcessing(const string& processedStatem
28582859
argument+= c;
28592860
}
28602861
length++;
2861-
//
2862-
lc = lc == '\\' && c == '\\'?'\0':c;
28632862
}
28642863
//
28652864
return trimArgument(argument, removeBrackets);

0 commit comments

Comments
 (0)