diff --git a/src/Alias.cpp b/src/Alias.cpp index 10a27e9a3..0f86e7f16 100644 --- a/src/Alias.cpp +++ b/src/Alias.cpp @@ -92,7 +92,7 @@ void Alias::resolve (Tree* tree) something = true; std::vector words; - Lexer::split (words, context.aliases[raw]); + Lexer::word_split (words, context.aliases[raw]); std::vector ::iterator word; for (word = words.begin (); word != words.end (); ++word) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 82e9f0a83..885378908 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -619,7 +619,7 @@ bool Lexer::is_ws (int c) //////////////////////////////////////////////////////////////////////////////// // Split 'input' into 'words' on Lexer::is_ws boundaries, observing quotes. -void Lexer::split (std::vector & words, const std::string& input) +void Lexer::word_split (std::vector & words, const std::string& input) { words.clear (); diff --git a/src/Lexer.h b/src/Lexer.h index 5ce76bc3e..6194dac06 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -65,7 +65,7 @@ public: static const std::string type_name (const Type&); static bool is_ws (int); - static void split (std::vector &, const std::string&); + static void word_split (std::vector &, const std::string&); private: bool is_punct (int) const; diff --git a/src/Parser.cpp b/src/Parser.cpp index eb26f3ca2..0b97a2dc2 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -468,7 +468,7 @@ void Parser::injectDefaults () // because captureFirst inserts args immediately after the command, and // so has the effect of reversing the list. std::vector args; - Lexer::split (args, defaultCommand); + Lexer::word_split (args, defaultCommand); std::vector ::reverse_iterator r; for (r = args.rbegin (); r != args.rend (); ++r) { diff --git a/test/lexer.t.cpp b/test/lexer.t.cpp index fa398a070..7071cfa9d 100644 --- a/test/lexer.t.cpp +++ b/test/lexer.t.cpp @@ -299,25 +299,25 @@ int main (int argc, char** argv) t.is (tokens[20].first, ")", "tokens[20] == ')'"); t.is (tokens[20].second, Lexer::typeOperator, "tokens[20] == typeOperator"); // 170 - // void splitq (std::vector&, const std::string&); + // void word_split (std::vector&, const std::string&); std::string unsplit = " ( A or B ) "; std::vector items; - Lexer::split (items, unsplit); - t.is (items.size (), (size_t) 5, "split ' ( A or B ) '"); - t.is (items[0], "(", "split ' ( A or B ) ' -> [0] '('"); - t.is (items[1], "A", "split ' ( A or B ) ' -> [1] 'A'"); - t.is (items[2], "or", "split ' ( A or B ) ' -> [2] 'or'"); - t.is (items[3], "B", "split ' ( A or B ) ' -> [3] 'B'"); - t.is (items[4], ")", "split ' ( A or B ) ' -> [4] ')'"); + Lexer::word_split (items, unsplit); + t.is (items.size (), (size_t) 5, "word_split ' ( A or B ) '"); + t.is (items[0], "(", "word_split ' ( A or B ) ' -> [0] '('"); + t.is (items[1], "A", "word_split ' ( A or B ) ' -> [1] 'A'"); + t.is (items[2], "or", "word_split ' ( A or B ) ' -> [2] 'or'"); + t.is (items[3], "B", "word_split ' ( A or B ) ' -> [3] 'B'"); + t.is (items[4], ")", "word_split ' ( A or B ) ' -> [4] ')'"); // Test simple mode with contrived tokens that ordinarily split. unsplit = " +-* a+b 12.3e4 'c d'"; - Lexer::split (items, unsplit); - t.is (items.size (), (size_t) 4, "split ' +-* a+b 12.3e4 'c d''"); - t.is (items[0], "+-*", "split ' +-* a+b 12.3e4 'c d'' -> [0] '+-*'"); - t.is (items[1], "a+b", "split ' +-* a+b 12.3e4 'c d'' -> [1] 'a+b'"); - t.is (items[2], "12.3e4", "split ' +-* a+b 12.3e4 'c d'' -> [2] '12.3e4'"); - t.is (items[3], "c d", "split ' +-* a+b 12.3e4 'c d'' -> [3] 'c d'"); + Lexer::word_split (items, unsplit); + t.is (items.size (), (size_t) 4, "word_split ' +-* a+b 12.3e4 'c d''"); + t.is (items[0], "+-*", "word_split ' +-* a+b 12.3e4 'c d'' -> [0] '+-*'"); + t.is (items[1], "a+b", "word_split ' +-* a+b 12.3e4 'c d'' -> [1] 'a+b'"); + t.is (items[2], "12.3e4", "word_split ' +-* a+b 12.3e4 'c d'' -> [2] '12.3e4'"); + t.is (items[3], "c d", "word_split ' +-* a+b 12.3e4 'c d'' -> [3] 'c d'"); return 0; }