From 1f138ddc8fbda86c6d059f3392439cdce3438bb5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Jul 2011 14:10:59 +0200 Subject: Fix SQL lexer to handle double-quoting instead of escape-sequences --- odb/sql-lexer.cxx | 20 ++++++++++---------- 1 file 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); -- cgit v1.1