Fix the few non-portable uses of "char" (where a -1 might be relevant): All uses of char are now either "int", "unsigned char" or char arrays for storing strings. Also, went to consistent "char* foo" coding convention. (There were only a few ambiguous uses.)

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@25400 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2014-02-18 23:37:57 +00:00
parent 52c351442c
commit 51cdd90fa8
15 changed files with 72 additions and 72 deletions

View File

@ -93,7 +93,7 @@ ShBinding FixedAttributeBindings[] = {
ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
EShLanguage FindLanguage(const std::string& name);
void CompileFile(const char *fileName, ShHandle);
void CompileFile(const char* fileName, ShHandle);
void usage();
void FreeFileData(char** data);
char** ReadFileData(const char* fileName);
@ -212,7 +212,7 @@ const char* DefaultConfig =
void ProcessConfigFile()
{
char** configStrings = 0;
char *config = 0;
char* config = 0;
if (ConfigFile.size() > 0) {
configStrings = ReadFileData(ConfigFile.c_str());
if (configStrings)
@ -746,7 +746,7 @@ EShLanguage FindLanguage(const std::string& name)
// Read a file's data into a string, and compile it using the old interface ShCompile,
// for non-linkable results.
//
void CompileFile(const char *fileName, ShHandle compiler)
void CompileFile(const char* fileName, ShHandle compiler)
{
int ret;
char** shaderStrings = ReadFileData(fileName);
@ -832,8 +832,8 @@ void usage()
int fopen_s(
FILE** pFile,
const char *filename,
const char *mode
const char* filename,
const char* mode
)
{
if (!pFile || !filename || !mode) {
@ -858,11 +858,11 @@ int fopen_s(
//
// Malloc a string of sufficient size and read a string into it.
//
char** ReadFileData(const char *fileName)
char** ReadFileData(const char* fileName)
{
FILE *in;
int errorCode = fopen_s(&in, fileName, "r");
char *fdata;
char* fdata;
int count = 0;
const int maxSourceStrings = 5;
char** return_data = (char**)malloc(maxSourceStrings+1);
@ -879,7 +879,7 @@ char** ReadFileData(const char *fileName)
fseek(in, 0, SEEK_SET);
if (!(fdata = (char *)malloc(count+2))) {
if (!(fdata = (char*)malloc(count+2))) {
printf("Error allocating memory\n");
return 0;
}
@ -917,7 +917,7 @@ char** ReadFileData(const char *fileName)
return return_data;
}
void FreeFileData(char **data)
void FreeFileData(char** data)
{
for(int i=0;i<NumShaderStrings;i++)
free(data[i]);

View File

@ -120,7 +120,7 @@ public:
}
protected:
void append(const char *s);
void append(const char* s);
void append(int count, char c);
void append(const TPersistString& t);

View File

@ -900,8 +900,8 @@ public:
{
const int maxSize = GlslangMaxTypeLength;
char buf[maxSize];
char *p = &buf[0];
char *end = &buf[maxSize];
char* p = &buf[0];
char* end = &buf[maxSize];
if (qualifier.hasLayout()) {
// To reduce noise, skip this if the only layout is an xfb_buffer

View File

@ -9,5 +9,5 @@
// source have to figure out how to create revision.h just to get a build
// going. However, if it is not updated, it can be a version behind.
#define GLSLANG_REVISION "25351"
#define GLSLANG_DATE "2014/02/13 12:14:33"
#define GLSLANG_REVISION "25392"
#define GLSLANG_DATE "2014/02/18 14:55:42"

View File

@ -38,7 +38,7 @@
namespace glslang {
void TInfoSinkBase::append(const char *s)
void TInfoSinkBase::append(const char* s)
{
if (outputStream & EString) {
checkMem(strlen(s));

View File

@ -150,7 +150,7 @@ bool TParseContext::parseShaderStrings(TPpContext& ppContext, TInputScanner& inp
}
// This is called from bison when it has a parse (syntax) error
void TParseContext::parserError(const char *s)
void TParseContext::parserError(const char* s)
{
if (afterEOF) {
if (tokensBeforeEOF == 1)
@ -324,8 +324,8 @@ bool TParseContext::parseVectorFields(TSourceLoc loc, const TString& compString,
//
// Used to output syntax, parsing, and semantic errors.
//
void C_DECL TParseContext::error(TSourceLoc loc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...)
void C_DECL TParseContext::error(TSourceLoc loc, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...)
{
const int maxSize = GlslangMaxTokenLength + 200;
char szExtraInfo[maxSize];
@ -344,8 +344,8 @@ void C_DECL TParseContext::error(TSourceLoc loc, const char *szReason, const cha
++numErrors;
}
void C_DECL TParseContext::warn(TSourceLoc loc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...)
void C_DECL TParseContext::warn(TSourceLoc loc, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...)
{
if (messages & EShMsgSuppressWarnings)
return;

View File

@ -67,13 +67,13 @@ public:
void setLimits(const TBuiltInResource&);
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
void parserError(const char *s); // for bison's yyerror
void parserError(const char* s); // for bison's yyerror
const char* getPreamble();
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);
void C_DECL warn(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);
void C_DECL error(TSourceLoc, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void C_DECL warn(TSourceLoc, const char* szReason, const char* szToken,
const char* szExtraInfoFormat, ...);
void reservedErrorCheck(TSourceLoc, const TString&);
void reservedPpErrorCheck(TSourceLoc, const char* name, const char* op);
bool lineContinuationCheck(TSourceLoc, bool endOfComment);
@ -188,14 +188,14 @@ public:
// The following are implemented in Versions.cpp to localize version/profile/stage/extensions control
void initializeExtensionBehavior();
void requireProfile(TSourceLoc, int queryProfiles, const char *featureDesc);
void profileRequires(TSourceLoc, int queryProfiles, int minVersion, int numExtensions, const char* const extensions[], const char *featureDesc);
void profileRequires(TSourceLoc, int queryProfiles, int minVersion, const char* const extension, const char *featureDesc);
void requireStage(TSourceLoc, EShLanguageMask, const char *featureDesc);
void requireStage(TSourceLoc, EShLanguage, const char *featureDesc);
void checkDeprecated(TSourceLoc, int queryProfiles, int depVersion, const char *featureDesc);
void requireNotRemoved(TSourceLoc, int queryProfiles, int removedVersion, const char *featureDesc);
void requireExtensions(TSourceLoc, int numExtensions, const char* const extensions[], const char *featureDesc);
void requireProfile(TSourceLoc, int queryProfiles, const char* featureDesc);
void profileRequires(TSourceLoc, int queryProfiles, int minVersion, int numExtensions, const char* const extensions[], const char* featureDesc);
void profileRequires(TSourceLoc, int queryProfiles, int minVersion, const char* const extension, const char* featureDesc);
void requireStage(TSourceLoc, EShLanguageMask, const char* featureDesc);
void requireStage(TSourceLoc, EShLanguage, const char* featureDesc);
void checkDeprecated(TSourceLoc, int queryProfiles, int depVersion, const char* featureDesc);
void requireNotRemoved(TSourceLoc, int queryProfiles, int removedVersion, const char* featureDesc);
void requireExtensions(TSourceLoc, int numExtensions, const char* const extensions[], const char* featureDesc);
TExtensionBehavior getExtensionBehavior(const char*);
bool extensionsTurnedOn(int numExtensions, const char* const extensions[]);
void updateExtensionBehavior(const char* const extension, const char* behavior);

View File

@ -276,7 +276,7 @@ void* TPoolAllocator::allocate(size_t numBytes)
//
// Safe to allocate from currentPageOffset.
//
unsigned char* memory = reinterpret_cast<unsigned char *>(inUseList) + currentPageOffset;
unsigned char* memory = reinterpret_cast<unsigned char*>(inUseList) + currentPageOffset;
currentPageOffset += allocationSize;
currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask;
@ -320,7 +320,7 @@ void* TPoolAllocator::allocate(size_t numBytes)
new(memory) tHeader(inUseList, 1);
inUseList = memory;
unsigned char* ret = reinterpret_cast<unsigned char *>(inUseList) + headerSkip;
unsigned char* ret = reinterpret_cast<unsigned char*>(inUseList) + headerSkip;
currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;
return initializeAllocation(inUseList, ret, numBytes);

View File

@ -56,7 +56,7 @@ namespace glslang {
// read past any white space
void TInputScanner::consumeWhiteSpace(bool& foundNonSpaceTab)
{
char c = peek(); // don't accidentally consume anything other than whitespace
int c = peek(); // don't accidentally consume anything other than whitespace
while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
if (c == '\r' || c == '\n')
foundNonSpaceTab = true;
@ -72,7 +72,7 @@ bool TInputScanner::consumeComment()
return false;
get(); // consume the '/'
char c = peek();
int c = peek();
if (c == '/') {
// a '//' style comment
@ -139,7 +139,7 @@ void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab)
consumeWhiteSpace(foundNonSpaceTab);
// if not starting a comment now, then done
char c = peek();
int c = peek();
if (c != '/' || c < 0)
return;
@ -176,7 +176,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile)
return true;
// whitespace
char c;
int c;
do {
c = get();
} while (c == ' ' || c == '\t');

View File

@ -62,12 +62,12 @@ public:
// anything else is the next character
// retrieve the next character and advance one character
char get()
int get()
{
if (currentSource >= numSources)
return -1;
char ret = sources[currentSource][currentChar];
int ret = sources[currentSource][currentChar];
if (ret == '\n')
++loc[currentSource].line;
advance();
@ -76,7 +76,7 @@ public:
}
// retrieve the next character, no advance
char peek()
int peek()
{
if (currentSource >= numSources)
return -1;

View File

@ -226,7 +226,7 @@ const char* ProfileName(EProfile profile)
// Operation: If the current profile is not one of the profileMask,
// give an error message.
//
void TParseContext::requireProfile(TSourceLoc loc, int profileMask, const char *featureDesc)
void TParseContext::requireProfile(TSourceLoc loc, int profileMask, const char* featureDesc)
{
if (! (profile & profileMask))
error(loc, "not supported with this profile:", featureDesc, ProfileName(profile));
@ -265,7 +265,7 @@ const char* StageName(EShLanguage stage)
//
// entry point that takes multiple extensions
void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVersion, int numExtensions, const char* const extensions[], const char *featureDesc)
void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVersion, int numExtensions, const char* const extensions[], const char* featureDesc)
{
if (profile & profileMask) {
bool okay = false;
@ -290,7 +290,7 @@ void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVers
}
// entry point for the above that takes a single extension
void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVersion, const char* extension, const char *featureDesc)
void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVersion, const char* extension, const char* featureDesc)
{
profileRequires(loc, profileMask, minVersion, extension ? 1 : 0, &extension, featureDesc);
}
@ -302,7 +302,7 @@ void TParseContext::profileRequires(TSourceLoc loc, int profileMask, int minVers
//
// Operation: If the current stage is not present, give an error message.
//
void TParseContext::requireStage(TSourceLoc loc, EShLanguageMask languageMask, const char *featureDesc)
void TParseContext::requireStage(TSourceLoc loc, EShLanguageMask languageMask, const char* featureDesc)
{
if (((1 << language) & languageMask) == 0)
error(loc, "not supported in this stage:", featureDesc, StageName(language));
@ -310,7 +310,7 @@ void TParseContext::requireStage(TSourceLoc loc, EShLanguageMask languageMask, c
// If only one stage supports a feature, this can be called. But, all supporting stages
// must be specified with one call.
void TParseContext::requireStage(TSourceLoc loc, EShLanguage stage, const char *featureDesc)
void TParseContext::requireStage(TSourceLoc loc, EShLanguage stage, const char* featureDesc)
{
requireStage(loc, static_cast<EShLanguageMask>(1 << stage), featureDesc);
}
@ -319,7 +319,7 @@ void TParseContext::requireStage(TSourceLoc loc, EShLanguage stage, const char *
// Within a set of profiles, see if a feature is deprecated and give an error or warning based on whether
// a future compatibility context is being use.
//
void TParseContext::checkDeprecated(TSourceLoc loc, int profileMask, int depVersion, const char *featureDesc)
void TParseContext::checkDeprecated(TSourceLoc loc, int profileMask, int depVersion, const char* featureDesc)
{
if (profile & profileMask) {
if (version >= depVersion) {
@ -336,7 +336,7 @@ void TParseContext::checkDeprecated(TSourceLoc loc, int profileMask, int depVers
// Within a set of profiles, see if a feature has now been removed and if so, give an error.
// The version argument is the first version no longer having the feature.
//
void TParseContext::requireNotRemoved(TSourceLoc loc, int profileMask, int removedVersion, const char *featureDesc)
void TParseContext::requireNotRemoved(TSourceLoc loc, int profileMask, int removedVersion, const char* featureDesc)
{
if (profile & profileMask) {
if (version >= removedVersion) {
@ -352,7 +352,7 @@ void TParseContext::requireNotRemoved(TSourceLoc loc, int profileMask, int remov
// Use when there are no profile/version to check, it's just an error if one of the
// extensions is not present.
//
void TParseContext::requireExtensions(TSourceLoc loc, int numExtensions, const char* const extensions[], const char *featureDesc)
void TParseContext::requireExtensions(TSourceLoc loc, int numExtensions, const char* const extensions[], const char* featureDesc)
{
// First, see if any of the extensions are enabled
for (int i = 0; i < numExtensions; ++i) {

View File

@ -96,7 +96,7 @@ using namespace glslang;
const struct {
int val;
const char *str;
const char* str;
} tokens[] = {
{ CPP_AND_OP, "&&" },
{ CPP_AND_ASSIGN, "&=" },
@ -128,7 +128,7 @@ namespace glslang {
//
// Map a new or existing string to an atom, inventing a new atom if necessary.
//
int TPpContext::LookUpAddString(const char *s)
int TPpContext::LookUpAddString(const char* s)
{
TAtomMap::const_iterator it = atomMap.find(s);
if (it == atomMap.end())
@ -140,7 +140,7 @@ int TPpContext::LookUpAddString(const char *s)
//
// Map an already created atom to its string.
//
const char *TPpContext::GetAtomString(int atom)
const char* TPpContext::GetAtomString(int atom)
{
if (atom == 0)
return "<null atom>";
@ -159,7 +159,7 @@ const char *TPpContext::GetAtomString(int atom)
//
// Add forced mapping of string to atom.
//
int TPpContext::AddAtomFixed(const char *s, int atom)
int TPpContext::AddAtomFixed(const char* s, int atom)
{
TAtomMap::const_iterator it = atomMap.insert(std::pair<TString, int>(s, atom)).first;
if (stringMap.size() < (size_t)atom + 1)
@ -175,7 +175,7 @@ int TPpContext::AddAtomFixed(const char *s, int atom)
void TPpContext::InitAtomTable()
{
// Add single character tokens to the atom table:
const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";
const char* s = "~!%^&*()-+=|,.<>/?;:[]{}#";
char t[2];
t[1] = '\0';

View File

@ -232,7 +232,7 @@ protected:
int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth
int elsetracker; // #if-#else and #endif constructs...Counter.
const char *ErrMsg;
const char* ErrMsg;
class tMacroInput : public tInput {
public:
@ -371,17 +371,17 @@ protected:
class tStringInput : public tInput {
public:
tStringInput(TPpContext* pp, TInputScanner& i) : tInput(pp), input(&i) { }
virtual int scan(TPpToken *);
virtual int scan(TPpToken*);
virtual int getch();
virtual void ungetch();
protected:
TInputScanner* input;
};
int InitScanner(TPpContext *cpp);
int ScanFromString(char *s);
int InitScanner(TPpContext* cpp);
int ScanFromString(char* s);
void missingEndifCheck();
int lFloatConst(char *str, int len, int ch, TPpToken * ppToken);
int lFloatConst(char* str, int len, int ch, TPpToken* ppToken);
bool inComment;
@ -394,17 +394,17 @@ protected:
TStringMap stringMap;
int nextAtom;
void InitAtomTable();
int AddAtomFixed(const char *s, int atom);
int LookUpAddString(const char *s);
const char *GetAtomString(int atom);
int AddAtomFixed(const char* s, int atom);
int LookUpAddString(const char* s);
const char* GetAtomString(int atom);
//
// From PpMemory.cpp
//
MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
void mem_FreePool(MemoryPool *);
void *mem_Alloc(MemoryPool *p, size_t size);
int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
void mem_FreePool(MemoryPool*);
void *mem_Alloc(MemoryPool* p, size_t size);
int mem_AddCleanup(MemoryPool* p, void (*fn)(void *, void*), void* arg1, void* arg2);
};
} // end namespace glslang

View File

@ -98,15 +98,15 @@ namespace glslang {
*/
TPpContext::Symbol* TPpContext::NewSymbol(int atom)
{
Symbol *lSymb;
char *pch;
Symbol* lSymb;
char* pch;
int ii;
lSymb = (Symbol *) mem_Alloc(pool, sizeof(Symbol));
lSymb->atom = atom;
// Clear macro
pch = (char *) &lSymb->mac;
pch = (char*) &lSymb->mac;
for (ii = 0; ii < sizeof(lSymb->mac); ii++)
*pch++ = 0;

View File

@ -117,8 +117,8 @@ int TPpContext::lReadByte(TokenStream *pTok)
*/
void TPpContext::RecordToken(TokenStream *pTok, int token, TPpToken* ppToken)
{
const char *s;
char *str = NULL;
const char* s;
char* str = NULL;
if (token > 256)
lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
@ -164,7 +164,7 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
{
char tokenText[TPpToken::maxTokenLength + 1];
int ltoken, len;
char ch;
int ch;
ltoken = lReadByte(pTok);
ppToken->loc = parseContext.getCurrentLoc();