Remove Windows \r line endings in glslang parser.

This commit is contained in:
Themaister 2018-10-19 19:18:54 +02:00
parent 723741fc60
commit 3f344660c0
2 changed files with 10 additions and 0 deletions

View File

@ -55,6 +55,15 @@ bool glslang_read_shader_file(const char *path, vector<string> *output, bool roo
return false;
}
/* Remove Windows \r chars if we encounter them.
* filestream_read_file() allocates one extra for 0 terminator. */
auto itr = remove_if(buf, buf + len + 1, [](char c) {
return c == '\r';
});
if (itr < buf + len)
*itr = '\0';
/* Cannot use string_split since it removes blank lines (strtok). */
ptr = buf;

View File

@ -7,6 +7,7 @@
#include <compat/strl.h>
#include <string>
#include <stdint.h>
#include <algorithm>
#include "glslang_util.h"
#include "slang_preprocess.h"