Skip to content

Commit 665f33e

Browse files
committed
fix "::" not split crrectly bug
1 parent f6985a3 commit 665f33e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

split.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ void split(const char * data, int datalen, int line, Meta_Vector & wordVector)
7676
case '\'':
7777
case ',':
7878
case ';':
79-
case ':':
8079
case '*':
8180
case '&':
8281
case '!':
@@ -90,6 +89,7 @@ void split(const char * data, int datalen, int line, Meta_Vector & wordVector)
9089
isStringMode = !isStringMode;
9190
break;
9291

92+
case ':':
9393
case '/':
9494
if (wordlen == 0){
9595
PRINT_LAST_TYPE();

test/split_unittest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,19 @@ TEST(SplitTest, Viriable) {
112112
"char", " ", "word", "[", "256", "]", " ", "=",
113113
" ", "{", "'", "\\", "0", "'", "}", ";");
114114
}
115+
116+
TEST(SplitTest, Special) {
117+
// check /=
118+
runTest("max/=10;", 4, "max", "/=", "10", ";");
119+
120+
// check ::
121+
runTest("QTextEdit::ExtraSelection selection;", 6,
122+
"QTextEdit", "::", "ExtraSelection", " ", "selection", ";");
123+
124+
// check (), )), ), );
125+
runTest("func(aa(), bb());", 12,
126+
"func", "(", "aa", "(", ")", ",", " ", "bb", "(", ")", ")", ";");
127+
128+
// check ++ and ++)
129+
runTest("func(i++)", 5, "func", "(", "i", "++", ")");
130+
}

0 commit comments

Comments
 (0)