From 5002c26b5e6b68d6b6394567e94a817ae8099682 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 11 Sep 2017 20:35:49 -0600 Subject: [PATCH] Fix #1043: set all scan string-locations to have bias, not just the first one. --- glslang/Include/Common.h | 1 + glslang/MachineIndependent/Scan.h | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h index 0820154..a2bdaa1 100644 --- a/glslang/Include/Common.h +++ b/glslang/Include/Common.h @@ -222,6 +222,7 @@ inline const TString String(const int i, const int /*base*/ = 10) struct TSourceLoc { void init() { name = nullptr; string = 0; line = 0; column = 0; } + void init(int stringNum) { init(); string = stringNum; } // Returns the name if it exists. Otherwise, returns the string number. std::string getStringNameOrNum(bool quoteStringName = true) const { diff --git a/glslang/MachineIndependent/Scan.h b/glslang/MachineIndependent/Scan.h index 9b8f2d4..2c26c2e 100644 --- a/glslang/MachineIndependent/Scan.h +++ b/glslang/MachineIndependent/Scan.h @@ -51,25 +51,24 @@ const int EndOfInput = -1; // class TInputScanner { public: - TInputScanner(int n, const char* const s[], size_t L[], const char* const* names = nullptr, int b = 0, int f = 0, bool single = false) : + TInputScanner(int n, const char* const s[], size_t L[], const char* const* names = nullptr, + int b = 0, int f = 0, bool single = false) : numSources(n), - sources(reinterpret_cast(s)), // up to this point, common usage is "char*", but now we need positive 8-bit characters - lengths(L), currentSource(0), currentChar(0), stringBias(b), finale(f), singleLogical(single), endOfFileReached(false) + // up to this point, common usage is "char*", but now we need positive 8-bit characters + sources(reinterpret_cast(s)), + lengths(L), currentSource(0), currentChar(0), stringBias(b), finale(f), singleLogical(single), + endOfFileReached(false) { loc = new TSourceLoc[numSources]; for (int i = 0; i < numSources; ++i) { - loc[i].init(); + loc[i].init(i - stringBias); } if (names != nullptr) { for (int i = 0; i < numSources; ++i) loc[i].name = names[i]; } - loc[currentSource].string = -stringBias; loc[currentSource].line = 1; - loc[currentSource].column = 0; - logicalSourceLoc.string = 0; - logicalSourceLoc.line = 1; - logicalSourceLoc.column = 0; + logicalSourceLoc.init(1); logicalSourceLoc.name = loc[0].name; } -- 2.7.4