From: John Kessenich Date: Wed, 12 Dec 2012 21:21:23 +0000 (+0000) Subject: Bring up to date with VS 10 express. X-Git-Tag: upstream/0.1~1092 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=200b2734d7639ea66ff2404f94b35a882868fd4d;p=platform%2Fupstream%2Fglslang.git Bring up to date with VS 10 express. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@19945 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- diff --git a/StandAlone.sln b/StandAlone.sln index b2f325a..e96655e 100644 --- a/StandAlone.sln +++ b/StandAlone.sln @@ -1,28 +1,25 @@ -Microsoft Visual Studio Solution File, Format Version 7.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests - StandAlone", "StandAlone.vcproj", "{660D0A05-69A9-4F09-9664-02FBEB08FAE2}" +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StandAlone", "StandAlone.vcxproj", "{660D0A05-69A9-4F09-9664-02FBEB08FAE2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Targets - glslang (generic)", "glslang.vcproj", "{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glslang", "glslang.vcxproj", "{3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}" EndProject Global - GlobalSection(SolutionConfiguration) = preSolution - ConfigName.0 = UserM_Debug - ConfigName.1 = UserM_Release + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 EndGlobalSection - GlobalSection(ProjectDependencies) = postSolution - {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.0 = {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3} + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.Debug|Win32.ActiveCfg = Debug|Win32 + {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.Debug|Win32.Build.0 = Debug|Win32 + {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.Release|Win32.ActiveCfg = Release|Win32 + {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.Release|Win32.Build.0 = Release|Win32 + {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Win32.ActiveCfg = Debug|Win32 + {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Debug|Win32.Build.0 = Debug|Win32 + {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Win32.ActiveCfg = Release|Win32 + {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.UserM_Debug.ActiveCfg = UserM_Debug|Win32 - {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.UserM_Debug.Build.0 = UserM_Debug|Win32 - {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.UserM_Release.ActiveCfg = UserM_Release|Win32 - {660D0A05-69A9-4F09-9664-02FBEB08FAE2}.UserM_Release.Build.0 = UserM_Release|Win32 - {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.UserM_Debug.ActiveCfg = UserM_Debug|Win32 - {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.UserM_Debug.Build.0 = UserM_Debug|Win32 - {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.UserM_Release.ActiveCfg = UserM_Release|Win32 - {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3}.UserM_Release.Build.0 = UserM_Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp index e970185..1fc0872 100644 --- a/StandAlone/StandAlone.cpp +++ b/StandAlone/StandAlone.cpp @@ -284,13 +284,14 @@ void usage() # define MAX_SOURCE_STRINGS 5 char** ReadFileData(char *fileName) { - FILE *in = fopen(fileName, "r"); + FILE *in; + int errorCode = fopen_s(&in, fileName, "r"); char *fdata; int count = 0; char**return_data=(char**)malloc(MAX_SOURCE_STRINGS+1); //return_data[MAX_SOURCE_STRINGS]=NULL; - if (!in) { + if (errorCode) { printf("Error: unable to open input file: %s\n", fileName); return 0; } diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h index 9f20ed2..7f48e0b 100644 --- a/glslang/Include/Common.h +++ b/glslang/Include/Common.h @@ -158,7 +158,7 @@ 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 #ifdef _WIN32 - itoa(i, text, base); + _itoa_s(i, text, base); #else // we assume base 10 for all cases sprintf(text, "%d", i); @@ -172,15 +172,16 @@ const unsigned int SourceLocStringShift = 16; __inline TPersistString FormatSourceLoc(const TSourceLoc loc) { - char locText[64]; + const int maxSize = 64; + char locText[maxSize]; int string = loc >> SourceLocStringShift; int line = loc & SourceLocLineMask; if (line) - sprintf(locText, "%d:%d", string, line); + sprintf_s(locText, maxSize, "%d:%d", string, line); else - sprintf(locText, "%d:? ", string); + sprintf_s(locText, maxSize, "%d:? ", string); return TPersistString(locText); } diff --git a/glslang/Include/InfoSink.h b/glslang/Include/InfoSink.h index debe9bb..f05b46a 100644 --- a/glslang/Include/InfoSink.h +++ b/glslang/Include/InfoSink.h @@ -72,11 +72,11 @@ public: TInfoSinkBase& operator<<(const char* s) { append(s); return *this; } TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; } TInfoSinkBase& operator<<(const unsigned int n) { append(String(n)); return *this; } - TInfoSinkBase& operator<<(float n) { char buf[40]; - sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? - "%f" : "%g", n); - append(buf); - return *this; } + TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size]; + sprintf_s(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? + "%f" : "%g", n); + append(buf); + return *this; } TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; } TInfoSinkBase& operator+(const TString& t) { append(t); return *this; } TInfoSinkBase& operator<<(const TString& t) { append(t); return *this; } diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 3bb8a0c..b978af8 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -728,41 +728,42 @@ void TBuiltIns::initialize(const TBuiltInResource &resources) // Implementation dependent constants. The example values below // are the minimum values allowed for these maximums. // - char builtInConstant[80]; - sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0 + const int maxSize = 80; + char builtInConstant[maxSize]; + sprintf_s(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0 s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0 + sprintf_s(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0 s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2 + sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2 s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program + sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader + sprintf_s(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader s.append(TString(builtInConstant)); - sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers + sprintf_s(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers s.append(TString(builtInConstant)); // diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 6088bdf..ee95d71 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -203,12 +203,13 @@ void TParseContext::recover() void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, const char *szExtraInfoFormat, ...) { - char szExtraInfo[400]; + const int maxSize = 400; + char szExtraInfo[maxSize]; va_list marker; va_start(marker, szExtraInfoFormat); - _vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker); + _vsnprintf_s(szExtraInfo, maxSize, sizeof(szExtraInfo), szExtraInfoFormat, marker); /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ infoSink.info.prefix(EPrefixError); @@ -1126,8 +1127,8 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type newNode = constructBuiltIn(type, op, *p, node->getLine(), true); if (newNode) { - sequenceVector.erase(p); - sequenceVector.insert(p, newNode); + p = sequenceVector.erase(p); + p = sequenceVector.insert(p, newNode); } } diff --git a/glslang/MachineIndependent/PoolAlloc.cpp b/glslang/MachineIndependent/PoolAlloc.cpp index 9034bb3..afbd651 100644 --- a/glslang/MachineIndependent/PoolAlloc.cpp +++ b/glslang/MachineIndependent/PoolAlloc.cpp @@ -193,11 +193,12 @@ void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, ch { for (int x = 0; x < guardBlockSize; x++) { if (blockMem[x] != val) { + const int maxSize = 80; char assertMsg[80]; // We don't print the assert message. It's here just to be helpful. - sprintf(assertMsg, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n", - locText, size, data()); + sprintf_s(assertMsg, maxSize, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n", + locText, size, data()); assert(0 && "PoolAlloc: Damage in guard block"); } } diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index ea89950..aabb5be 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -81,8 +81,9 @@ void TType::buildMangledName(TString& mangledName) mangledName += static_cast('0' + getNominalSize()); if (isArray()) { - char buf[10]; - sprintf(buf, "%d", arraySize); + const int maxSize = 10; + char buf[maxSize]; + sprintf_s(buf, maxSize, "%d", arraySize); mangledName += '['; mangledName += buf; mangledName += ']'; diff --git a/glslang/MachineIndependent/glslang.l b/glslang/MachineIndependent/glslang.l index 094933e..190ee6a 100644 --- a/glslang/MachineIndependent/glslang.l +++ b/glslang/MachineIndependent/glslang.l @@ -59,7 +59,7 @@ O [0-7] #include #include #include "ParseHelper.h" -#include "glslang_tab.h" +#include "glslang_tab.cpp.h" /* windows only pragma */ #ifdef _MSC_VER @@ -84,7 +84,7 @@ TSourceLoc yylineno; %option noyywrap %option never-interactive -%option outfile="Gen_glslang.cpp" +%option outfile="gen_glslang.cpp" %x FIELDS diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index a01899a..78dc850 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -55,19 +55,21 @@ public: TString TType::getCompleteString() const { - char buf[100]; + const int maxSize = 100; + char buf[maxSize]; char *p = &buf[0]; + char *end = &buf[maxSize]; if (qualifier != EvqTemporary && qualifier != EvqGlobal) - p += sprintf(p, "%s ", getQualifierString()); + p += sprintf_s(p, end - p, "%s ", getQualifierString()); if (array) - p += sprintf(p, "array of "); + p += sprintf_s(p, end - p, "array of "); if (matrix) - p += sprintf(p, "%dX%d matrix of ", size, size); + p += sprintf_s(p, end - p, "%dX%d matrix of ", size, size); else if (size > 1) - p += sprintf(p, "%d-component vector of ", size); + p += sprintf_s(p, end - p, "%d-component vector of ", size); - sprintf(p, "%s", getBasicString()); + sprintf_s(p, end - p, "%s", getBasicString()); return TString(buf); } @@ -101,8 +103,9 @@ void OutputSymbol(TIntermSymbol* node, TIntermTraverser* it) OutputTreeText(oit->infoSink, node, oit->depth); - char buf[100]; - sprintf(buf, "'%s' (%s)\n", + const int maxSize = 100; + char buf[maxSize]; + sprintf_s(buf, maxSize, "'%s' (%s)\n", node->getSymbol().c_str(), node->getCompleteString().c_str()); @@ -380,16 +383,18 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) break; case EbtFloat: { - char buf[300]; - sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float"); + const int maxSize = 300; + char buf[maxSize]; + sprintf_s(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float"); out.debug << buf << "\n"; } break; case EbtInt: { - char buf[300]; - sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int"); + const int maxSize = 300; + char buf[maxSize]; + sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int"); out.debug << buf << "\n"; break; diff --git a/glslang/MachineIndependent/parseConst.cpp b/glslang/MachineIndependent/parseConst.cpp index ae07319..3497d8c 100644 --- a/glslang/MachineIndependent/parseConst.cpp +++ b/glslang/MachineIndependent/parseConst.cpp @@ -80,8 +80,9 @@ bool ParseBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it) TQualifier qualifier = node->getType().getQualifier(); if (qualifier != EvqConst) { - char buf[200]; - sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str()); + const int maxSize = 200; + char buf[maxSize]; + sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str()); oit->infoSink.info.message(EPrefixError, buf, node->getLine()); oit->error = true; return false; @@ -96,8 +97,9 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it) { TConstTraverser* oit = static_cast(it); - char buf[200]; - sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); + const int maxSize = 200; + char buf[maxSize]; + sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); oit->infoSink.info.message(EPrefixError, buf, node->getLine()); oit->error = true; return false; @@ -108,8 +110,9 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse TConstTraverser* oit = static_cast(it); if (!node->isConstructor() && node->getOp() != EOpComma) { - char buf[200]; - sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); + const int maxSize = 200; + char buf[maxSize]; + sprintf_s(buf, maxSize, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); oit->infoSink.info.message(EPrefixError, buf, node->getLine()); oit->error = true; return false; diff --git a/glslang/MachineIndependent/preprocessor/atom.c b/glslang/MachineIndependent/preprocessor/atom.c index 39af441..9482478 100644 --- a/glslang/MachineIndependent/preprocessor/atom.c +++ b/glslang/MachineIndependent/preprocessor/atom.c @@ -79,6 +79,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // atom.c // +#define _CRT_SECURE_NO_WARNINGS + #include #include #include diff --git a/glslang/MachineIndependent/preprocessor/cpp.c b/glslang/MachineIndependent/preprocessor/cpp.c index 221f1a8..1281edd 100644 --- a/glslang/MachineIndependent/preprocessor/cpp.c +++ b/glslang/MachineIndependent/preprocessor/cpp.c @@ -78,6 +78,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cpp.c // +#define _CRT_SECURE_NO_WARNINGS + #include #include #include diff --git a/glslang/MachineIndependent/preprocessor/scanner.c b/glslang/MachineIndependent/preprocessor/scanner.c index 6d562a4..90ebcf0 100644 --- a/glslang/MachineIndependent/preprocessor/scanner.c +++ b/glslang/MachineIndependent/preprocessor/scanner.c @@ -78,6 +78,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // scanner.c // +#define _CRT_SECURE_NO_WARNINGS + #include #include #include diff --git a/glslang/MachineIndependent/preprocessor/tokens.c b/glslang/MachineIndependent/preprocessor/tokens.c index c2f7911..d124578 100644 --- a/glslang/MachineIndependent/preprocessor/tokens.c +++ b/glslang/MachineIndependent/preprocessor/tokens.c @@ -77,6 +77,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // tokens.c // +#define _CRT_SECURE_NO_WARNINGS #include #include @@ -437,6 +438,7 @@ void UngetToken(int token, yystypepp * yylvalpp) { void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { int token; + const int maxSize = 100; char str[100]; if (fp == 0) fp = stdout; @@ -445,10 +447,10 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { switch (token) { case CPP_IDENTIFIER: case CPP_TYPEIDENTIFIER: - sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident)); + sprintf_s(str, maxSize, "%s ", GetAtomString(atable, yylvalpp->sc_ident)); break; case CPP_STRCONSTANT: - sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident)); + sprintf_s(str, maxSize, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident)); break; case CPP_FLOATCONSTANT: //printf("%g9.6 ", yylvalpp->sc_fval); @@ -458,9 +460,9 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { break; default: if (token >= 127) - sprintf(str, "%s ", GetAtomString(atable, token)); + sprintf_s(str, maxSize, "%s ", GetAtomString(atable, token)); else - sprintf(str, "%c", token); + sprintf_s(str, maxSize, "%c", token); break; } CPPDebugLogMsg(str);