Browse Source

Fix VariantParser::StreamString EOF determination

(cherry picked from commit 521da75380be712157fa172e27dda4dabba1de51)
Pedro J. Estébanez 5 years ago
parent
commit
edb70682d5
1 changed files with 8 additions and 2 deletions
  1. 8 2
      core/variant_parser.cpp

+ 8 - 2
core/variant_parser.cpp

@@ -51,10 +51,16 @@ bool VariantParser::StreamFile::is_eof() const {
 
 
 CharType VariantParser::StreamString::get_char() {
 CharType VariantParser::StreamString::get_char() {
 
 
-	if (pos >= s.length())
+	if (pos > s.length()) {
 		return 0;
 		return 0;
-	else
+	} else if (pos == s.length()) {
+		// You need to try to read again when you have reached the end for EOF to be reported,
+		// so this works the same as files (like StreamFile does)
+		pos++;
+		return 0;
+	} else {
 		return s[pos++];
 		return s[pos++];
+	}
 }
 }
 
 
 bool VariantParser::StreamString::is_utf8() const {
 bool VariantParser::StreamString::is_utf8() const {