diff options
Diffstat (limited to 'thirdparty/embree/common/lexers')
-rw-r--r-- | thirdparty/embree/common/lexers/stream.h | 20 | ||||
-rw-r--r-- | thirdparty/embree/common/lexers/stringstream.cpp | 4 | ||||
-rw-r--r-- | thirdparty/embree/common/lexers/tokenstream.cpp | 2 |
3 files changed, 14 insertions, 12 deletions
diff --git a/thirdparty/embree/common/lexers/stream.h b/thirdparty/embree/common/lexers/stream.h index a40c15f8eb..9ad72af4e6 100644 --- a/thirdparty/embree/common/lexers/stream.h +++ b/thirdparty/embree/common/lexers/stream.h @@ -6,7 +6,7 @@ #include "../sys/platform.h" #include "../sys/ref.h" #include "../sys/filename.h" -#include "../sys/string.h" +#include "../sys/estring.h" #include <vector> #include <iostream> @@ -122,17 +122,16 @@ namespace embree class FileStream : public Stream<int> { public: - - FileStream (FILE* file, const std::string& name = "file") - : file(file), lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(name))) {} - FileStream (const FileName& fileName) : lineNumber(1), colNumber(0), charNumber(0), name(std::shared_ptr<std::string>(new std::string(fileName.str()))) { - file = fopen(fileName.c_str(),"r"); - if (file == nullptr) THROW_RUNTIME_ERROR("cannot open file " + fileName.str()); + if (ifs) ifs.close(); + ifs.open(fileName.str()); + if (!ifs.is_open()) THROW_RUNTIME_ERROR("cannot open file " + fileName.str()); + } + ~FileStream() { + if (ifs) ifs.close(); } - ~FileStream() { if (file) fclose(file); } public: ParseLocation location() { @@ -140,14 +139,15 @@ namespace embree } int next() { - int c = fgetc(file); + int c = ifs.get(); if (c == '\n') { lineNumber++; colNumber = 0; } else if (c != '\r') colNumber++; charNumber++; return c; } + private: - FILE* file; + std::ifstream ifs; ssize_t lineNumber; /// the line number the token is from ssize_t colNumber; /// the character number in the current line ssize_t charNumber; /// the character in the file diff --git a/thirdparty/embree/common/lexers/stringstream.cpp b/thirdparty/embree/common/lexers/stringstream.cpp index a037869506..c93da0b420 100644 --- a/thirdparty/embree/common/lexers/stringstream.cpp +++ b/thirdparty/embree/common/lexers/stringstream.cpp @@ -41,7 +41,9 @@ namespace embree int c = cin->get(); // -- GODOT start -- // if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input"); - if (!isValidChar(c)) abort(); + if (!isValidChar(c)) { + abort(); + } // -- GODOT end -- str.push_back((char)c); } diff --git a/thirdparty/embree/common/lexers/tokenstream.cpp b/thirdparty/embree/common/lexers/tokenstream.cpp index 6ed6f2045a..fe9de641db 100644 --- a/thirdparty/embree/common/lexers/tokenstream.cpp +++ b/thirdparty/embree/common/lexers/tokenstream.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "tokenstream.h" -#include "../math/math.h" +#include "../math/emath.h" namespace embree { |