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
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

View File

@ -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;
}

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
#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);
}

View File

@ -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; }

View File

@ -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));
//

View File

@ -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);
}
}

View File

@ -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");
}
}

View File

@ -81,8 +81,9 @@ void TType::buildMangledName(TString& mangledName)
mangledName += static_cast<char>('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 += ']';

View File

@ -59,7 +59,7 @@ O [0-7]
#include <stdio.h>
#include <stdlib.h>
#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

View File

@ -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;

View File

@ -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<TConstTraverser*>(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<TConstTraverser*>(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;

View File

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

View File

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

View File

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

View File

@ -77,6 +77,7 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// tokens.c
//
#define _CRT_SECURE_NO_WARNINGS
#include <assert.h>
#include <stdlib.h>
@ -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);