diff --git a/bin_Windows_32/glslc.exe b/bin_Windows_32/glslc.exe index 964e228..4b8b5be 100644 Binary files a/bin_Windows_32/glslc.exe and b/bin_Windows_32/glslc.exe differ diff --git a/bin_Windows_64/glslc.exe b/bin_Windows_64/glslc.exe index 249fd2a..bb09ea4 100644 Binary files a/bin_Windows_64/glslc.exe and b/bin_Windows_64/glslc.exe differ diff --git a/src/glslc.cpp b/src/glslc.cpp index 3ae6972..9d9d9ff 100644 --- a/src/glslc.cpp +++ b/src/glslc.cpp @@ -28,7 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define GLSLC_VERSION 10 +#define GLSLC_VERSION 11 #include #include @@ -36,6 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #define WIN32_LEAN_AND_MEAN 1 @@ -412,27 +413,26 @@ bool createContext() #endif -std::string readFile(const char* filename){ - std::string content; - - size_t filesize; - FILE* infile = fopen(filename,"rt"); +std::string readFile( const char* filename) +{ + std::string result; - if (!infile){ + std::ifstream stream(filename, std::ios::in); + if(!stream.is_open()){ fprintf(stderr,"error: could not open input file \"%s\"\n",filename); exit(1); + return result; } - fseek (infile, 0, SEEK_END); // non-portable - filesize=ftell (infile); - fseek (infile, 0, SEEK_SET); + stream.seekg(0, std::ios::end); + result.reserve(stream.tellg()); + stream.seekg(0, std::ios::beg); - content.resize(filesize); - fread(&content[0],filesize,1,infile); - //content[filesize] = 0; + result.assign( + (std::istreambuf_iterator(stream)), + std::istreambuf_iterator()); - fclose (infile); - return content; + return result; } void printHelp() @@ -574,7 +574,7 @@ std::string manualInclude ( std::string const & filename, if(!includeSource.empty()) { // strip null terminator from content - Text += std::string(includeSource.c_str()); + Text += includeSource; Text += eol + std::string("#line ") + SSTR(lineCount + 1) + std::string(" ") + includeMarker(filename) + eol; }