A patch submitted for MinGW building.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@27757 e7fa87d3-cd2b-0410-9028-fcbf551c1848
diff --git a/BIL/BilBuilder.cpp b/BIL/BilBuilder.cpp
index 96257a8..d0eb21a 100644
--- a/BIL/BilBuilder.cpp
+++ b/BIL/BilBuilder.cpp
@@ -33,6 +33,7 @@
//POSSIBILITY OF SUCH DAMAGE.
#include <assert.h>
+#include <stdio.h>
#include "BilBuilder.h"
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index 52bc4a6..dd1d434 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -53,10 +53,10 @@
// Command-line options
enum TOptions {
- EOptionNone = 0x000,
- EOptionIntermediate = 0x001,
- EOptionSuppressInfolog = 0x002,
- EOptionMemoryLeakMode = 0x004,
+ EOptionNone = 0x000,
+ EOptionIntermediate = 0x001,
+ EOptionSuppressInfolog = 0x002,
+ EOptionMemoryLeakMode = 0x004,
EOptionRelaxedErrors = 0x008,
EOptionGiveWarnings = 0x010,
EOptionsLinkProgram = 0x020,
@@ -887,13 +887,19 @@
char** ReadFileData(const char* fileName)
{
FILE *in;
- int errorCode = fopen_s(&in, fileName, "r");
+ #if defined(_WIN32) && defined(__GNUC__)
+ in = fopen(fileName, "r");
+ int errorCode = in ? 0 : 1;
+ #else
+ int errorCode = fopen_s(&in, fileName, "r");
+ #endif
+
char *fdata;
int count = 0;
const int maxSourceStrings = 5;
char** return_data = (char**)malloc(sizeof(char *) * (maxSourceStrings+1));
- if (errorCode) {
+ if (errorCode) {
printf("Error: unable to open input file: %s\n", fileName);
return 0;
}
@@ -901,13 +907,13 @@
while (fgetc(in) != EOF)
count++;
- fseek(in, 0, SEEK_SET);
-
- if (!(fdata = (char*)malloc(count+2))) {
+ fseek(in, 0, SEEK_SET);
+
+ if (!(fdata = (char*)malloc(count+2))) {
printf("Error allocating memory\n");
return 0;
}
- if (fread(fdata,1,count, in)!=count) {
+ if (fread(fdata,1,count, in)!=count) {
printf("Error reading input file: %s\n", fileName);
return 0;
}
@@ -921,23 +927,23 @@
} else
NumShaderStrings = 1;
- int len = (int)(ceil)((float)count/(float)NumShaderStrings);
+ int len = (int)(ceil)((float)count/(float)NumShaderStrings);
int ptr_len=0,i=0;
- while(count>0){
- return_data[i]=(char*)malloc(len+2);
- memcpy(return_data[i],fdata+ptr_len,len);
- return_data[i][len]='\0';
- count-=(len);
- ptr_len+=(len);
- if(count<len){
+ while(count>0){
+ return_data[i]=(char*)malloc(len+2);
+ memcpy(return_data[i],fdata+ptr_len,len);
+ return_data[i][len]='\0';
+ count-=(len);
+ ptr_len+=(len);
+ if(count<len){
if(count==0){
NumShaderStrings=(i+1);
break;
}
len = count;
- }
- ++i;
- }
+ }
+ ++i;
+ }
return return_data;
}
diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h
index 305b534..07ee9fb 100644
--- a/glslang/Include/Common.h
+++ b/glslang/Include/Common.h
@@ -37,7 +37,7 @@
#ifndef _COMMON_INCLUDED_
#define _COMMON_INCLUDED_
-#ifdef _WIN32
+#if defined _WIN32 && !defined __GNUC__
#include <basetsd.h>
#define snprintf sprintf_s
#define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
@@ -166,7 +166,7 @@
{
char text[16]; // 32 bit ints are at most 10 digits in base 10
- #ifdef _WIN32
+ #if defined _WIN32 && !defined __GNUC__
_itoa_s(i, text, base);
#else
// we assume base 10 for all cases