summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/broker/SelectorToken.cpp15
-rw-r--r--qpid/cpp/src/tests/Selector.cpp3
2 files changed, 10 insertions, 8 deletions
diff --git a/qpid/cpp/src/qpid/broker/SelectorToken.cpp b/qpid/cpp/src/qpid/broker/SelectorToken.cpp
index 309c0891df..eb56833178 100644
--- a/qpid/cpp/src/qpid/broker/SelectorToken.cpp
+++ b/qpid/cpp/src/qpid/broker/SelectorToken.cpp
@@ -113,26 +113,26 @@ bool tokeniseReservedWord(Token& tok)
return true;
}
-// parsing strings is complicated by the need to allow "''" as an embedded single quote
-bool processString(std::string::const_iterator& s, std::string::const_iterator& e, Token& tok)
+// parsing strings is complicated by the need to allow embedded quotes by doubling the quote character
+bool processString(std::string::const_iterator& s, std::string::const_iterator& e, char quoteChar, TokenType type, Token& tok)
{
// We only get here once the tokeniser recognises the initial quote for a string
// so we don't need to check for it again.
- std::string::const_iterator q = std::find(s+1, e, '\'');
+ std::string::const_iterator q = std::find(s+1, e, quoteChar);
if ( q==e ) return false;
std::string content(s+1, q);
++q;
- while ( q!=e && *q=='\'' ) {
+ while ( q!=e && *q==quoteChar ) {
std::string::const_iterator p = q;
- q = std::find(p+1, e, '\'');
+ q = std::find(p+1, e, quoteChar);
if ( q==e ) return false;
content += std::string(p, q);
++q;
}
- tok = Token(T_STRING, s, content);
+ tok = Token(type, s, content);
s = q;
return true;
}
@@ -198,7 +198,8 @@ bool tokenise(std::string::const_iterator& s, std::string::const_iterator& e, To
break;
}
if (isIdentifierStart(*t)) {++t; state = IDENTIFIER;}
- else if (*t=='\'') {return processString(s, e, tok);}
+ else if (*t=='\'') {return processString(s, e, '\'', T_STRING, tok);}
+ else if (*t=='\"') {return processString(s, e, '\"', T_IDENTIFIER, tok);}
else if (std::isdigit(*t)) {++t; state = DIGIT;}
else if (*t=='.') {++t; state = DECIMAL_START;}
else state = REJECT;
diff --git a/qpid/cpp/src/tests/Selector.cpp b/qpid/cpp/src/tests/Selector.cpp
index 951f124d3a..23c192bc63 100644
--- a/qpid/cpp/src/tests/Selector.cpp
+++ b/qpid/cpp/src/tests/Selector.cpp
@@ -152,7 +152,8 @@ QPID_AUTO_TEST_CASE(tokeniseSuccess)
{
verifyTokeniserSuccess(&tokenise, "", qb::T_EOS, "", "");
verifyTokeniserSuccess(&tokenise, "null_123+blah", qb::T_IDENTIFIER, "null_123", "+blah");
- verifyTokeniserSuccess(&tokenise, "null_123+blah", qb::T_IDENTIFIER, "null_123", "+blah");
+ verifyTokeniserSuccess(&tokenise, "\"null-123\"+blah", qb::T_IDENTIFIER, "null-123", "+blah");
+ verifyTokeniserSuccess(&tokenise, "\"This is an \"\"odd!\"\" identifier\"+blah", qb::T_IDENTIFIER, "This is an \"odd!\" identifier", "+blah");
verifyTokeniserSuccess(&tokenise, "null+blah", qb::T_NULL, "null", "+blah");
verifyTokeniserSuccess(&tokenise, "null+blah", qb::T_NULL, "null", "+blah");
verifyTokeniserSuccess(&tokenise, "Is nOt null", qb::T_IS, "Is", " nOt null");