Browse Source

Fix minor preprocessor bugs, particularly parsing files with CRLF

rdb 10 years ago
parent
commit
d1732a4dca
1 changed files with 8 additions and 8 deletions
  1. 8 8
      dtool/src/cppparser/cppPreprocessor.cxx

+ 8 - 8
dtool/src/cppparser/cppPreprocessor.cxx

@@ -154,8 +154,10 @@ int CPPPreprocessor::InputFile::
 get() {
 get() {
   assert(_in != NULL);
   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();
   int c = _in->get();
 
 
@@ -201,7 +203,7 @@ peek() {
   // shouldn't see any of these unless there was some DOS-to-Unix file
   // shouldn't see any of these unless there was some DOS-to-Unix file
   // conversion problem.
   // conversion problem.
   while (c == '\r') {
   while (c == '\r') {
-    get();
+    _in->get();
     c = _in->peek();
     c = _in->peek();
   }
   }
 
 
@@ -1872,10 +1874,11 @@ get_identifier(int c) {
   loc.last_line = get_line_number();
   loc.last_line = get_line_number();
   loc.last_column = get_col_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
     // This is actually a wide-character or wide-string literal or
     // some such.  Figure out the correct character type to use.
     // 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;
     CPPExpression::Type type;
     if (name == "L") {
     if (name == "L") {
@@ -1886,9 +1889,6 @@ get_identifier(int c) {
       type = CPPExpression::T_u16string;
       type = CPPExpression::T_u16string;
     } else if (name == "U") {
     } else if (name == "U") {
       type = CPPExpression::T_u32string;
       type = CPPExpression::T_u32string;
-    } else {
-      type = CPPExpression::T_string;
-      warning("unrecognized literal prefix " + name, loc);
     }
     }
 
 
     get();
     get();