diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/preprocessor/Input.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/preprocessor/Input.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp index 5541d46f72..0f2327b823 100644 --- a/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp +++ b/src/3rdparty/angle/src/compiler/preprocessor/Input.cpp @@ -4,12 +4,13 @@ // found in the LICENSE file. // -#include "Input.h" +#include "compiler/preprocessor/Input.h" #include <algorithm> -#include <cassert> #include <cstring> +#include "common/debug.h" + namespace pp { @@ -17,9 +18,12 @@ Input::Input() : mCount(0), mString(0) { } -Input::Input(size_t count, const char *const string[], const int length[]) : - mCount(count), - mString(string) +Input::~Input() +{ +} + +Input::Input(size_t count, const char *const string[], const int length[]) + : mCount(count), mString(string) { mLength.reserve(mCount); for (size_t i = 0; i < mCount; ++i) @@ -32,7 +36,7 @@ Input::Input(size_t count, const char *const string[], const int length[]) : const char *Input::skipChar() { // This function should only be called when there is a character to skip. - assert(mReadLoc.cIndex < mLength[mReadLoc.sIndex]); + ASSERT(mReadLoc.cIndex < mLength[mReadLoc.sIndex]); ++mReadLoc.cIndex; if (mReadLoc.cIndex == mLength[mReadLoc.sIndex]) { @@ -61,6 +65,11 @@ size_t Input::read(char *buf, size_t maxSize, int *lineNo) { // Line continuation of backslash + newline. skipChar(); + // Fake an EOF if the line number would overflow. + if (*lineNo == INT_MAX) + { + return 0; + } ++(*lineNo); } else if (c != nullptr && (*c) == '\r') @@ -71,6 +80,11 @@ size_t Input::read(char *buf, size_t maxSize, int *lineNo) { skipChar(); } + // Fake an EOF if the line number would overflow. + if (*lineNo == INT_MAX) + { + return 0; + } ++(*lineNo); } else @@ -86,7 +100,7 @@ size_t Input::read(char *buf, size_t maxSize, int *lineNo) while ((nRead < maxRead) && (mReadLoc.sIndex < mCount)) { size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex; - size = std::min(size, maxSize); + size = std::min(size, maxSize); for (size_t i = 0; i < size; ++i) { // Stop if a possible line continuation is encountered. @@ -94,7 +108,7 @@ size_t Input::read(char *buf, size_t maxSize, int *lineNo) // and increments line number if necessary. if (*(mString[mReadLoc.sIndex] + mReadLoc.cIndex + i) == '\\') { - size = i; + size = i; maxRead = nRead + size; // Stop reading right before the backslash. } } @@ -113,4 +127,3 @@ size_t Input::read(char *buf, size_t maxSize, int *lineNo) } } // namespace pp - |