From 142785f324009289f8187868ab4843761693d7a9 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 19 Sep 2016 14:56:55 -0600 Subject: [PATCH] HLSL: Change the final syntax-error printf to go to the infoLog. Fixes issue #510. --- glslang/Include/revision.h | 2 +- glslang/MachineIndependent/InfoSink.cpp | 20 ++++++++++++-------- hlsl/hlslParseHelper.cpp | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 0a9710c..1fc0ca7 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.1494" +#define GLSLANG_REVISION "Overload400-PrecQual.1495" #define GLSLANG_DATE "19-Sep-2016" diff --git a/glslang/MachineIndependent/InfoSink.cpp b/glslang/MachineIndependent/InfoSink.cpp index aa0fe89..79acba8 100644 --- a/glslang/MachineIndependent/InfoSink.cpp +++ b/glslang/MachineIndependent/InfoSink.cpp @@ -38,11 +38,15 @@ namespace glslang { -void TInfoSinkBase::append(const char* s) +void TInfoSinkBase::append(const char* s) { if (outputStream & EString) { - checkMem(strlen(s)); - sink.append(s); + if (s == nullptr) + sink.append("(null)"); + else { + checkMem(strlen(s)); + sink.append(s); + } } //#ifdef _WIN32 @@ -54,10 +58,10 @@ void TInfoSinkBase::append(const char* s) fprintf(stdout, "%s", s); } -void TInfoSinkBase::append(int count, char c) +void TInfoSinkBase::append(int count, char c) { if (outputStream & EString) { - checkMem(count); + checkMem(count); sink.append(count, c); } @@ -74,10 +78,10 @@ void TInfoSinkBase::append(int count, char c) fprintf(stdout, "%c", c); } -void TInfoSinkBase::append(const TPersistString& t) +void TInfoSinkBase::append(const TPersistString& t) { if (outputStream & EString) { - checkMem(t.size()); + checkMem(t.size()); sink.append(t); } @@ -93,7 +97,7 @@ void TInfoSinkBase::append(const TPersistString& t) void TInfoSinkBase::append(const TString& t) { if (outputStream & EString) { - checkMem(t.size()); + checkMem(t.size()); sink.append(t.c_str()); } diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 6f60a59..5504d1f 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -124,8 +124,8 @@ bool HlslParseContext::parseShaderStrings(TPpContext& ppContext, TInputScanner& // Print a message formated such that if you click on the message it will take you right to // the line through most UIs. const glslang::TSourceLoc& sourceLoc = input.getSourceLoc(); - printf("\n%s(%i): error at column %i, HLSL translation failed.\n", sourceLoc.name, sourceLoc.line, - sourceLoc.column); + infoSink.info << sourceLoc.name << "(" << sourceLoc.line << "): error at column " << sourceLoc.column << ", HLSL parsing failed.\n"; + ++numErrors; return false; } -- 2.7.4