Parcourir la source

[2665] use istream::ignore() (and ignore result) to skip chars instead of get()

ignoring the result fixes a scan-build error.  besides, ignore() should be
more appropriate choice for what it intends to do anyway.
JINMEI Tatuya il y a 12 ans
Parent
commit
50e61198ea
1 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 5 5
      src/lib/cc/data.cc

+ 5 - 5
src/lib/cc/data.cc

@@ -261,7 +261,7 @@ skipChars(std::istream& in, const char* chars, int& line, int& pos) {
         } else {
         } else {
             ++pos;
             ++pos;
         }
         }
-        in.get();
+        in.ignore();
         c = in.peek();
         c = in.peek();
     }
     }
 }
 }
@@ -291,7 +291,7 @@ skipTo(std::istream& in, const std::string& file, int& line,
                     pos = 1;
                     pos = 1;
                     ++line;
                     ++line;
                 }
                 }
-                in.get();
+                in.ignore();
                 ++pos;
                 ++pos;
             }
             }
             in.putback(c);
             in.putback(c);
@@ -352,7 +352,7 @@ strFromStringstream(std::istream& in, const std::string& file,
                 throwJSONError("Bad escape", file, line, pos);
                 throwJSONError("Bad escape", file, line, pos);
             }
             }
             // drop the escaped char
             // drop the escaped char
-            in.get();
+            in.ignore();
             ++pos;
             ++pos;
         }
         }
         ss.put(c);
         ss.put(c);
@@ -490,14 +490,14 @@ fromStringstreamMap(std::istream& in, const std::string& file, int& line,
         throwJSONError(std::string("Unterminated map, <string> or } expected"), file, line, pos);
         throwJSONError(std::string("Unterminated map, <string> or } expected"), file, line, pos);
     } else if (c == '}') {
     } else if (c == '}') {
         // empty map, skip closing curly
         // empty map, skip closing curly
-        c = in.get();
+        in.ignore();
     } else {
     } else {
         while (c != EOF && c != '}') {
         while (c != EOF && c != '}') {
             std::string key = strFromStringstream(in, file, line, pos);
             std::string key = strFromStringstream(in, file, line, pos);
 
 
             skipTo(in, file, line, pos, ":", WHITESPACE);
             skipTo(in, file, line, pos, ":", WHITESPACE);
             // skip the :
             // skip the :
-            in.get();
+            in.ignore();
             pos++;
             pos++;
 
 
             ConstElementPtr value = Element::fromJSON(in, file, line, pos);
             ConstElementPtr value = Element::fromJSON(in, file, line, pos);