Increase portability. (Submission from Nikita Kindt, as were some recent related submissions.)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@28444 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
@@ -868,7 +868,7 @@ void usage()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#if !defined _MSC_VER && !defined MINGW_HAS_SECURE_API
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@@ -903,12 +903,7 @@ int fopen_s(
|
|||||||
char** ReadFileData(const char* fileName)
|
char** ReadFileData(const char* fileName)
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
#if defined(_WIN32) && defined(__GNUC__)
|
int errorCode = fopen_s(&in, fileName, "r");
|
||||||
in = fopen(fileName, "r");
|
|
||||||
int errorCode = in ? 0 : 1;
|
|
||||||
#else
|
|
||||||
int errorCode = fopen_s(&in, fileName, "r");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *fdata;
|
char *fdata;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#ifndef _COMMON_INCLUDED_
|
#ifndef _COMMON_INCLUDED_
|
||||||
#define _COMMON_INCLUDED_
|
#define _COMMON_INCLUDED_
|
||||||
|
|
||||||
#if defined _WIN32 && !defined __GNUC__
|
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
|
||||||
#include <basetsd.h>
|
#include <basetsd.h>
|
||||||
#define snprintf sprintf_s
|
#define snprintf sprintf_s
|
||||||
#define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
|
#define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args))
|
||||||
@@ -166,11 +166,11 @@ inline const TString String(const int i, const int base = 10)
|
|||||||
{
|
{
|
||||||
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
char text[16]; // 32 bit ints are at most 10 digits in base 10
|
||||||
|
|
||||||
#if defined _WIN32 && !defined __GNUC__
|
#if defined _MSC_VER || defined MINGW_HAS_SECURE_API
|
||||||
_itoa_s(i, text, base);
|
_itoa_s(i, text, sizeof(text), base);
|
||||||
#else
|
#else
|
||||||
// we assume base 10 for all cases
|
// we assume base 10 for all cases
|
||||||
sprintf(text, "%d", i);
|
snprintf(text, sizeof(text), "%d", i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
Reference in New Issue
Block a user