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
This commit is contained in:
John Kessenich 2012-12-12 21:21:23 +00:00
parent a0af473a8b
commit 200b2734d7
15 changed files with 96 additions and 77 deletions

View File

@ -1,28 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 7.00 Microsoft Visual Studio Solution File, Format Version 11.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests - StandAlone", "StandAlone.vcproj", "{660D0A05-69A9-4F09-9664-02FBEB08FAE2}" # Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StandAlone", "StandAlone.vcxproj", "{660D0A05-69A9-4F09-9664-02FBEB08FAE2}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
ConfigName.0 = UserM_Debug Debug|Win32 = Debug|Win32
ConfigName.1 = UserM_Release Release|Win32 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{660D0A05-69A9-4F09-9664-02FBEB08FAE2}.0 = {3B146CC5-B2B8-4573-9D46-6139E2EDFEA3} {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 EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(SolutionProperties) = preSolution
{660D0A05-69A9-4F09-9664-02FBEB08FAE2}.UserM_Debug.ActiveCfg = UserM_Debug|Win32 HideSolutionNode = FALSE
{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
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -284,13 +284,14 @@ void usage()
# define MAX_SOURCE_STRINGS 5 # define MAX_SOURCE_STRINGS 5
char** ReadFileData(char *fileName) char** ReadFileData(char *fileName)
{ {
FILE *in = fopen(fileName, "r"); FILE *in;
int errorCode = fopen_s(&in, fileName, "r");
char *fdata; char *fdata;
int count = 0; int count = 0;
char**return_data=(char**)malloc(MAX_SOURCE_STRINGS+1); char**return_data=(char**)malloc(MAX_SOURCE_STRINGS+1);
//return_data[MAX_SOURCE_STRINGS]=NULL; //return_data[MAX_SOURCE_STRINGS]=NULL;
if (!in) { if (errorCode) {
printf("Error: unable to open input file: %s\n", fileName); printf("Error: unable to open input file: %s\n", fileName);
return 0; return 0;
} }

View File

@ -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 char text[16]; // 32 bit ints are at most 10 digits in base 10
#ifdef _WIN32 #ifdef _WIN32
itoa(i, text, base); _itoa_s(i, text, base);
#else #else
// we assume base 10 for all cases // we assume base 10 for all cases
sprintf(text, "%d", i); sprintf(text, "%d", i);
@ -172,15 +172,16 @@ const unsigned int SourceLocStringShift = 16;
__inline TPersistString FormatSourceLoc(const TSourceLoc loc) __inline TPersistString FormatSourceLoc(const TSourceLoc loc)
{ {
char locText[64]; const int maxSize = 64;
char locText[maxSize];
int string = loc >> SourceLocStringShift; int string = loc >> SourceLocStringShift;
int line = loc & SourceLocLineMask; int line = loc & SourceLocLineMask;
if (line) if (line)
sprintf(locText, "%d:%d", string, line); sprintf_s(locText, maxSize, "%d:%d", string, line);
else else
sprintf(locText, "%d:? ", string); sprintf_s(locText, maxSize, "%d:? ", string);
return TPersistString(locText); return TPersistString(locText);
} }

View File

@ -72,8 +72,8 @@ public:
TInfoSinkBase& operator<<(const char* s) { append(s); return *this; } TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }
TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; } TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
TInfoSinkBase& operator<<(const unsigned 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]; TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size];
sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? sprintf_s(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
"%f" : "%g", n); "%f" : "%g", n);
append(buf); append(buf);
return *this; } return *this; }

View File

@ -728,41 +728,42 @@ void TBuiltIns::initialize(const TBuiltInResource &resources)
// Implementation dependent constants. The example values below // Implementation dependent constants. The example values below
// are the minimum values allowed for these maximums. // are the minimum values allowed for these maximums.
// //
char builtInConstant[80]; const int maxSize = 80;
sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0 char builtInConstant[maxSize];
sprintf_s(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
s.append(TString(builtInConstant)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); s.append(TString(builtInConstant));
// //

View File

@ -203,12 +203,13 @@ void TParseContext::recover()
void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken, void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...) const char *szExtraInfoFormat, ...)
{ {
char szExtraInfo[400]; const int maxSize = 400;
char szExtraInfo[maxSize];
va_list marker; va_list marker;
va_start(marker, szExtraInfoFormat); 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 */ /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
infoSink.info.prefix(EPrefixError); infoSink.info.prefix(EPrefixError);
@ -1126,8 +1127,8 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
newNode = constructBuiltIn(type, op, *p, node->getLine(), true); newNode = constructBuiltIn(type, op, *p, node->getLine(), true);
if (newNode) { if (newNode) {
sequenceVector.erase(p); p = sequenceVector.erase(p);
sequenceVector.insert(p, newNode); p = sequenceVector.insert(p, newNode);
} }
} }

View File

@ -193,10 +193,11 @@ void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, ch
{ {
for (int x = 0; x < guardBlockSize; x++) { for (int x = 0; x < guardBlockSize; x++) {
if (blockMem[x] != val) { if (blockMem[x] != val) {
const int maxSize = 80;
char assertMsg[80]; char assertMsg[80];
// We don't print the assert message. It's here just to be helpful. // 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", sprintf_s(assertMsg, maxSize, "PoolAlloc: Damage %s %lu byte allocation at 0x%p\n",
locText, size, data()); locText, size, data());
assert(0 && "PoolAlloc: Damage in guard block"); assert(0 && "PoolAlloc: Damage in guard block");
} }

View File

@ -81,8 +81,9 @@ void TType::buildMangledName(TString& mangledName)
mangledName += static_cast<char>('0' + getNominalSize()); mangledName += static_cast<char>('0' + getNominalSize());
if (isArray()) { if (isArray()) {
char buf[10]; const int maxSize = 10;
sprintf(buf, "%d", arraySize); char buf[maxSize];
sprintf_s(buf, maxSize, "%d", arraySize);
mangledName += '['; mangledName += '[';
mangledName += buf; mangledName += buf;
mangledName += ']'; mangledName += ']';

View File

@ -59,7 +59,7 @@ O [0-7]
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "ParseHelper.h" #include "ParseHelper.h"
#include "glslang_tab.h" #include "glslang_tab.cpp.h"
/* windows only pragma */ /* windows only pragma */
#ifdef _MSC_VER #ifdef _MSC_VER
@ -84,7 +84,7 @@ TSourceLoc yylineno;
%option noyywrap %option noyywrap
%option never-interactive %option never-interactive
%option outfile="Gen_glslang.cpp" %option outfile="gen_glslang.cpp"
%x FIELDS %x FIELDS

View File

@ -55,19 +55,21 @@ public:
TString TType::getCompleteString() const TString TType::getCompleteString() const
{ {
char buf[100]; const int maxSize = 100;
char buf[maxSize];
char *p = &buf[0]; char *p = &buf[0];
char *end = &buf[maxSize];
if (qualifier != EvqTemporary && qualifier != EvqGlobal) if (qualifier != EvqTemporary && qualifier != EvqGlobal)
p += sprintf(p, "%s ", getQualifierString()); p += sprintf_s(p, end - p, "%s ", getQualifierString());
if (array) if (array)
p += sprintf(p, "array of "); p += sprintf_s(p, end - p, "array of ");
if (matrix) 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) 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); return TString(buf);
} }
@ -101,8 +103,9 @@ void OutputSymbol(TIntermSymbol* node, TIntermTraverser* it)
OutputTreeText(oit->infoSink, node, oit->depth); OutputTreeText(oit->infoSink, node, oit->depth);
char buf[100]; const int maxSize = 100;
sprintf(buf, "'%s' (%s)\n", char buf[maxSize];
sprintf_s(buf, maxSize, "'%s' (%s)\n",
node->getSymbol().c_str(), node->getSymbol().c_str(),
node->getCompleteString().c_str()); node->getCompleteString().c_str());
@ -380,16 +383,18 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
break; break;
case EbtFloat: case EbtFloat:
{ {
char buf[300]; const int maxSize = 300;
sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float"); char buf[maxSize];
sprintf_s(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
out.debug << buf << "\n"; out.debug << buf << "\n";
} }
break; break;
case EbtInt: case EbtInt:
{ {
char buf[300]; const int maxSize = 300;
sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int"); char buf[maxSize];
sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
out.debug << buf << "\n"; out.debug << buf << "\n";
break; break;

View File

@ -80,8 +80,9 @@ bool ParseBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)
TQualifier qualifier = node->getType().getQualifier(); TQualifier qualifier = node->getType().getQualifier();
if (qualifier != EvqConst) { if (qualifier != EvqConst) {
char buf[200]; const int maxSize = 200;
sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str()); 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->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true; oit->error = true;
return false; return false;
@ -96,8 +97,9 @@ bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
{ {
TConstTraverser* oit = static_cast<TConstTraverser*>(it); TConstTraverser* oit = static_cast<TConstTraverser*>(it);
char buf[200]; const int maxSize = 200;
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); 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->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true; oit->error = true;
return false; return false;
@ -108,8 +110,9 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse
TConstTraverser* oit = static_cast<TConstTraverser*>(it); TConstTraverser* oit = static_cast<TConstTraverser*>(it);
if (!node->isConstructor() && node->getOp() != EOpComma) { if (!node->isConstructor() && node->getOp() != EOpComma) {
char buf[200]; const int maxSize = 200;
sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str()); 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->infoSink.info.message(EPrefixError, buf, node->getLine());
oit->error = true; oit->error = true;
return false; return false;

View File

@ -79,6 +79,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// atom.c // atom.c
// //
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View File

@ -78,6 +78,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// cpp.c // cpp.c
// //
#define _CRT_SECURE_NO_WARNINGS
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -78,6 +78,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// scanner.c // scanner.c
// //
#define _CRT_SECURE_NO_WARNINGS
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -77,6 +77,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// tokens.c // tokens.c
// //
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@ -437,6 +438,7 @@ void UngetToken(int token, yystypepp * yylvalpp) {
void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) { void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
int token; int token;
const int maxSize = 100;
char str[100]; char str[100];
if (fp == 0) fp = stdout; if (fp == 0) fp = stdout;
@ -445,10 +447,10 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
switch (token) { switch (token) {
case CPP_IDENTIFIER: case CPP_IDENTIFIER:
case CPP_TYPEIDENTIFIER: case CPP_TYPEIDENTIFIER:
sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident)); sprintf_s(str, maxSize, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
break; break;
case CPP_STRCONSTANT: case CPP_STRCONSTANT:
sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident)); sprintf_s(str, maxSize, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
break; break;
case CPP_FLOATCONSTANT: case CPP_FLOATCONSTANT:
//printf("%g9.6 ", yylvalpp->sc_fval); //printf("%g9.6 ", yylvalpp->sc_fval);
@ -458,9 +460,9 @@ void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
break; break;
default: default:
if (token >= 127) if (token >= 127)
sprintf(str, "%s ", GetAtomString(atable, token)); sprintf_s(str, maxSize, "%s ", GetAtomString(atable, token));
else else
sprintf(str, "%c", token); sprintf_s(str, maxSize, "%c", token);
break; break;
} }
CPPDebugLogMsg(str); CPPDebugLogMsg(str);