aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-07-22 14:10:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-07-22 17:57:00 +0200
commit1f138ddc8fbda86c6d059f3392439cdce3438bb5 (patch)
tree315b672bb16ce81dc3433c19346c8073bb56b703
parentbc9e3154a6ebe08c65c3be66cf642c30c5c1a726 (diff)
Fix SQL lexer to handle double-quoting instead of escape-sequences
-rw-r--r--odb/sql-lexer.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/odb/sql-lexer.cxx b/odb/sql-lexer.cxx
index 660f48e..689a03f 100644
--- a/odb/sql-lexer.cxx
+++ b/odb/sql-lexer.cxx
@@ -209,7 +209,7 @@ sql_token sql_lexer::
string_literal (xchar c)
{
//size_t ln (c.line ()), cl (c.column ());
- char q (c), p ('\0');
+ char q (c);
string lexeme;
lexeme += c;
@@ -223,16 +223,16 @@ string_literal (xchar c)
lexeme += c;
- if (c == q && p != '\\')
- break;
-
- // We need to keep track of \\ escapings so we don't confuse
- // them with \", as in "\\".
+ // In SQL, double-quote is used to encode a single quote inside
+ // a string.
//
- if (c == '\\' && p == '\\')
- p = '\0';
- else
- p = c;
+ if (c == q)
+ {
+ if (peek () == q)
+ get ();
+ else
+ break;
+ }
}
return sql_token (sql_token::t_string_lit, lexeme);