Commit 9e1bf10b by Geoff Lang Committed by Commit Bot

Strip null characters from the shader source when building translated source.

Some shaders had trailing null characters that caused the resulting translated source string to not output correctly. BUG=angleproject:1144 Change-Id: I7cd725ee54c9e934fd3cc511de9c2a3c34ac3eec Reviewed-on: https://chromium-review.googlesource.com/461272Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 8f77e5d3
...@@ -296,15 +296,14 @@ void Shader::compile(const Context *context) ...@@ -296,15 +296,14 @@ void Shader::compile(const Context *context)
shaderStream << "// GLSL\n"; shaderStream << "// GLSL\n";
shaderStream << "//\n"; shaderStream << "//\n";
size_t curPos = 0; std::istringstream inputSourceStream(mState.mSource);
while (curPos != std::string::npos) std::string line;
while (std::getline(inputSourceStream, line))
{ {
size_t nextLine = mState.mSource.find("\n", curPos); // Remove null characters from the source line
size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1); line.erase(std::remove(line.begin(), line.end(), '\0'), line.end());
shaderStream << "// " << mState.mSource.substr(curPos, len); shaderStream << "// " << line;
curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
} }
shaderStream << "\n\n"; shaderStream << "\n\n";
shaderStream << mState.mTranslatedSource; shaderStream << mState.mTranslatedSource;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment