Fix #1043: set all scan string-locations to have bias, not just the first one.
authorJohn Kessenich <cepheus@frii.com>
Tue, 12 Sep 2017 02:35:49 +0000 (20:35 -0600)
committerJohn Kessenich <cepheus@frii.com>
Tue, 12 Sep 2017 02:35:49 +0000 (20:35 -0600)
glslang/Include/Common.h
glslang/MachineIndependent/Scan.h

index 0820154..a2bdaa1 100644 (file)
@@ -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
     {
index 9b8f2d4..2c26c2e 100644 (file)
@@ -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<const unsigned char* const *>(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<const unsigned char* const *>(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;
     }