From d1732a4dca9f89176a920836ff1f974eb9754a8a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Nov 2015 02:10:38 +0100 Subject: [PATCH] Fix minor preprocessor bugs, particularly parsing files with CRLF --- dtool/src/cppparser/cppPreprocessor.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index ec2771ab06..e405f2cf4c 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -154,8 +154,10 @@ int CPPPreprocessor::InputFile:: get() { assert(_in != NULL); - _line_number = _next_line_number; - _col_number = _next_col_number; + if (!_lock_position) { + _line_number = _next_line_number; + _col_number = _next_col_number; + } int c = _in->get(); @@ -201,7 +203,7 @@ peek() { // shouldn't see any of these unless there was some DOS-to-Unix file // conversion problem. while (c == '\r') { - get(); + _in->get(); c = _in->peek(); } @@ -1872,10 +1874,11 @@ get_identifier(int c) { loc.last_line = get_line_number(); loc.last_column = get_col_number(); - if ((c == '\'' || c == '"') && name != "operator") { + if ((c == '\'' || c == '"') && + (name == "L" || name == "u8" || + name == "u" || name == "U")) { // This is actually a wide-character or wide-string literal or // some such. Figure out the correct character type to use. - // We had to add in an exception in order to support operator"". CPPExpression::Type type; if (name == "L") { @@ -1886,9 +1889,6 @@ get_identifier(int c) { type = CPPExpression::T_u16string; } else if (name == "U") { type = CPPExpression::T_u32string; - } else { - type = CPPExpression::T_string; - warning("unrecognized literal prefix " + name, loc); } get();