fix // comments
authorMichal Krol <mjkrol@gmail.org>
Tue, 18 Jan 2005 13:58:56 +0000 (13:58 +0000)
committerMichal Krol <mjkrol@gmail.org>
Tue, 18 Jan 2005 13:58:56 +0000 (13:58 +0000)
17 files changed:
src/mesa/shader/slang/MachineIndependent/preprocessor/atom.c
src/mesa/shader/slang/MachineIndependent/preprocessor/atom.h
src/mesa/shader/slang/MachineIndependent/preprocessor/compile.h
src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.c
src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.h
src/mesa/shader/slang/MachineIndependent/preprocessor/cppstruct.c
src/mesa/shader/slang/MachineIndependent/preprocessor/memory.c
src/mesa/shader/slang/MachineIndependent/preprocessor/memory.h
src/mesa/shader/slang/MachineIndependent/preprocessor/parser.h
src/mesa/shader/slang/MachineIndependent/preprocessor/preprocess.h
src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.c
src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.h
src/mesa/shader/slang/MachineIndependent/preprocessor/slglobals.h
src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.c
src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.h
src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.c
src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.h

index 386ad99..d3c3555 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-//\r
-// atom.c\r
-//\r
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include "slglobals.h"\r
-\r
-#undef malloc\r
-#undef realloc\r
-#undef free\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////// String table: //////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-static const struct {\r
-    int val;\r
-    const char *str;\r
-} tokens[] = {\r
-    { CPP_AND_OP,         "&&" },\r
-    { CPP_AND_ASSIGN,     "&=" },\r
-    { CPP_SUB_ASSIGN,     "-=" },\r
-    { CPP_MOD_ASSIGN,     "%=" },\r
-    { CPP_ADD_ASSIGN,     "+=" },\r
-    { CPP_DIV_ASSIGN,     "/=" },\r
-    { CPP_MUL_ASSIGN,     "*=" },\r
-    { CPP_RIGHT_BRACKET,  ":>" },\r
-    { CPP_EQ_OP,          "==" },\r
-    { CPP_XOR_OP,         "^^" }, \r
-    { CPP_XOR_ASSIGN,     "^=" }, \r
-    { CPP_FLOATCONSTANT,  "<float-const>" },\r
-    { CPP_GE_OP,          ">=" },\r
-    { CPP_RIGHT_OP,       ">>" },\r
-    { CPP_RIGHT_ASSIGN,   ">>=" }, \r
-    { CPP_IDENTIFIER,     "<ident>" },\r
-    { CPP_INTCONSTANT,    "<int-const>" },\r
-    { CPP_LE_OP,          "<=" },\r
-    { CPP_LEFT_OP,        "<<" },\r
-    { CPP_LEFT_ASSIGN,    "<<=" },\r
-    { CPP_LEFT_BRACKET,   "<:" },\r
-    { CPP_LEFT_BRACE,     "<%" }, \r
-    { CPP_DEC_OP,         "--" },\r
-    { CPP_RIGHT_BRACE,    "%>" }, \r
-    { CPP_NE_OP,          "!=" },\r
-    { CPP_OR_OP,          "||" },\r
-    { CPP_OR_ASSIGN,      "|=" }, \r
-    { CPP_INC_OP,         "++" },\r
-    { CPP_STRCONSTANT,    "<string-const>" },\r
-    { CPP_TYPEIDENTIFIER, "<type-ident>" },\r
-};\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////////// String table: //////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-#define INIT_STRING_TABLE_SIZE 16384\r
-\r
-typedef struct StringTable_Rec {\r
-    char *strings;\r
-    int nextFree;\r
-    int size;\r
-} StringTable;\r
-\r
-/*\r
- * InitStringTable() - Initialize the string table.\r
- *\r
- */\r
-\r
-static int InitStringTable(StringTable *stable)\r
-{\r
-    stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);\r
-    if (!stable->strings)\r
-        return 0;\r
-    // Zero-th offset means "empty" so don't use it.\r
-    stable->nextFree = 1;\r
-    stable->size = INIT_STRING_TABLE_SIZE;\r
-    return 1;\r
-} // InitStringTable\r
-\r
-/*\r
- * FreeStringTable() - Free the string table.\r
- *\r
- */\r
-\r
-static void FreeStringTable(StringTable *stable)\r
-{\r
-    if (stable->strings)\r
-        free(stable->strings);\r
-    stable->strings = NULL;\r
-    stable->nextFree = 0;\r
-    stable->size = 0;\r
-} // FreeStringTable\r
-\r
-/*\r
- * HashString() - Hash a string with the base hash function.\r
- *\r
- */\r
-\r
-static int HashString(const char *s)\r
-{\r
-    int hval = 0;\r
-\r
-    while (*s) {\r
-        hval = (hval*13507 + *s*197) ^ (hval >> 2);\r
-        s++;\r
-    }\r
-    return hval & 0x7fffffff;\r
-} // HashString\r
-\r
-/*\r
- * HashString2() - Hash a string with the incrimenting hash function.\r
- *\r
- */\r
-\r
-static int HashString2(const char *s)\r
-{\r
-    int hval = 0;\r
-\r
-    while (*s) {\r
-        hval = (hval*729 + *s*37) ^ (hval >> 1);\r
-        s++;\r
-    }\r
-    return hval;\r
-} // HashString2\r
-\r
-/*\r
- * AddString() - Add a string to a string table.  Return it's offset.\r
- *\r
- */\r
-\r
-static int AddString(StringTable *stable, const char *s)\r
-{\r
-    int len, loc;\r
-    char *str;\r
-\r
-    len = (int) strlen(s);\r
-    if (stable->nextFree + len + 1 >= stable->size) {\r
-        assert(stable->size < 1000000);\r
-        str = (char *) malloc(stable->size*2);\r
-        memcpy(str, stable->strings, stable->size);\r
-        free(stable->strings);\r
-        stable->strings = str;\r
-    }\r
-    loc = stable->nextFree;\r
-    strcpy(&stable->strings[loc], s);\r
-    stable->nextFree += len + 1;\r
-    return loc;\r
-} // AddString\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////////////// Hash table: ///////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-#define INIT_HASH_TABLE_SIZE 2047\r
-#define HASH_TABLE_MAX_COLLISIONS 3\r
-\r
-typedef struct HashEntry_Rec {\r
-    int index;      // String table offset of string representation\r
-    int value;      // Atom (symbol) value\r
-} HashEntry;\r
-\r
-typedef struct HashTable_Rec {\r
-    HashEntry *entry;\r
-    int size;\r
-    int entries;\r
-    int counts[HASH_TABLE_MAX_COLLISIONS + 1];\r
-} HashTable;\r
-\r
-/*\r
- * InitHashTable() - Initialize the hash table.\r
- *\r
- */\r
-\r
-static int InitHashTable(HashTable *htable, int fsize)\r
-{\r
-    int ii;\r
-\r
-    htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize);\r
-    if (!htable->entry)\r
-        return 0;\r
-    htable->size = fsize;\r
-    for (ii = 0; ii < fsize; ii++) {\r
-        htable->entry[ii].index = 0;\r
-        htable->entry[ii].value = 0;\r
-    }\r
-    htable->entries = 0;\r
-    for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++)\r
-        htable->counts[ii] = 0;\r
-    return 1;\r
-} // InitHashTable\r
-\r
-/*\r
- * FreeHashTable() - Free the hash table.\r
- *\r
- */\r
-\r
-static void FreeHashTable(HashTable *htable)\r
-{\r
-    if (htable->entry)\r
-        free(htable->entry);\r
-    htable->entry = NULL;\r
-    htable->size = 0;\r
-    htable->entries = 0;\r
-} // FreeHashTable\r
-\r
-/*\r
- * Empty() - See if a hash table entry is empty.\r
- *\r
- */\r
-\r
-static int Empty(HashTable *htable, int hashloc)\r
-{\r
-    assert(hashloc >= 0 && hashloc < htable->size);\r
-    if (htable->entry[hashloc].index == 0) {\r
-        return 1;\r
-    } else {\r
-        return 0;\r
-    }\r
-} // Empty\r
-\r
-/*\r
- * Match() - See if a hash table entry is matches a string.\r
- *\r
- */\r
-\r
-static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc)\r
-{\r
-    int strloc;\r
-\r
-    strloc = htable->entry[hashloc].index;\r
-    if (!strcmp(s, &stable->strings[strloc])) {\r
-        return 1;\r
-    } else {\r
-        return 0;\r
-    }\r
-} // Match\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////////////// Atom table: ///////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-#define INIT_ATOM_TABLE_SIZE 1024\r
-\r
-\r
-struct AtomTable_Rec {\r
-    StringTable stable; // String table.\r
-    HashTable htable;   // Hashes string to atom number and token value.  Multiple strings can\r
-                        // have the same token value but each unique string is a unique atom.\r
-    int *amap;          // Maps atom value to offset in string table.  Atoms all map to unique\r
-                        // strings except for some undefined values in the lower, fixed part\r
-                        // of the atom table that map to "<undefined>".  The lowest 256 atoms\r
-                        // correspond to single character ASCII values except for alphanumeric\r
-                        // characters and '_', which can be other tokens.  Next come the\r
-                        // language tokens with their atom values equal to the token value.\r
-                        // Then come predefined atoms, followed by user specified identifiers.\r
-    int *arev;          // Reversed atom for symbol table use.\r
-    int nextFree;\r
-    int size;\r
-};\r
-\r
-static AtomTable latable = { { 0 } };\r
-AtomTable *atable = &latable;\r
-\r
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom);\r
-\r
-/*\r
- * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.\r
- *\r
- */\r
-\r
-static int GrowAtomTable(AtomTable *atable, int size)\r
-{\r
-    int *newmap, *newrev;\r
-\r
-    if (atable->size < size) {\r
-        if (atable->amap) {\r
-            newmap = realloc(atable->amap, sizeof(int)*size);\r
-            newrev = realloc(atable->arev, sizeof(int)*size);\r
-        } else {\r
-            newmap = malloc(sizeof(int)*size);\r
-            newrev = malloc(sizeof(int)*size);\r
-            atable->size = 0;\r
-        }\r
-        if (!newmap || !newrev) {\r
-            /* failed to grow -- error */\r
-            if (newmap)\r
-                atable->amap = newmap;\r
-            if (newrev)\r
-                atable->amap = newrev;\r
-            return -1;\r
-        }\r
-        memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));\r
-        memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));\r
-        atable->amap = newmap;\r
-        atable->arev = newrev;\r
-        atable->size = size;\r
-    }\r
-    return 0;\r
-} // GrowAtomTable\r
-\r
-/*\r
- * lReverse() - Reverse the bottom 20 bits of a 32 bit int.\r
- *\r
- */\r
-\r
-static int lReverse(int fval)\r
-{\r
-    unsigned int in = fval;\r
-    int result = 0, cnt = 0;\r
-\r
-    while(in) {\r
-        result <<= 1;\r
-        result |= in&1;\r
-        in >>= 1;\r
-        cnt++;\r
-    }\r
-\r
-    // Don't use all 31 bits.  One million atoms is plenty and sometimes the\r
-    // upper bits are used for other things.\r
-\r
-    if (cnt < 20)\r
-        result <<= 20 - cnt;\r
-    return result;\r
-} // lReverse\r
-\r
-/*\r
- * AllocateAtom() - Allocate a new atom.  Associated with the "undefined" value of -1.\r
- *\r
- */\r
-\r
-static int AllocateAtom(AtomTable *atable)\r
-{\r
-    if (atable->nextFree >= atable->size)\r
-        GrowAtomTable(atable, atable->nextFree*2);\r
-    atable->amap[atable->nextFree] = -1;\r
-    atable->arev[atable->nextFree] = lReverse(atable->nextFree);\r
-    atable->nextFree++;\r
-    return atable->nextFree - 1;\r
-} // AllocateAtom\r
-\r
-/*\r
- * SetAtomValue() - Allocate a new atom associated with "hashindex".\r
- *\r
- */\r
-\r
-static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex)\r
-{\r
-    atable->amap[atomnumber] = atable->htable.entry[hashindex].index;\r
-    atable->htable.entry[hashindex].value = atomnumber;\r
-} // SetAtomValue\r
-\r
-/*\r
- * FindHashLoc() - Find the hash location for this string.  Return -1 it hash table is full.\r
- *\r
- */\r
-\r
-static int FindHashLoc(AtomTable *atable, const char *s)\r
-{\r
-    int hashloc, hashdelta, count;\r
-    int FoundEmptySlot = 0;\r
-    int collision[HASH_TABLE_MAX_COLLISIONS + 1];\r
-\r
-    hashloc = HashString(s) % atable->htable.size;\r
-    if (!Empty(&atable->htable, hashloc)) {\r
-        if (Match(&atable->htable, &atable->stable, s, hashloc))\r
-            return hashloc;\r
-        collision[0] = hashloc;\r
-        hashdelta = HashString2(s);\r
-        count = 0;\r
-        while (count < HASH_TABLE_MAX_COLLISIONS) {\r
-            hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size;\r
-            if (!Empty(&atable->htable, hashloc)) {\r
-                if (Match(&atable->htable, &atable->stable, s, hashloc)) {\r
-                    return hashloc;\r
-                }\r
-            } else {\r
-                FoundEmptySlot = 1;\r
-                break;\r
-            }\r
-            count++;\r
-            collision[count] = hashloc;\r
-        }\r
-\r
-        if (!FoundEmptySlot) {\r
-            if (cpp->options.DumpAtomTable) {\r
-                int ii;\r
-                char str[200];\r
-                sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",\r
-                       HASH_TABLE_MAX_COLLISIONS);\r
-                CPPShInfoLogMsg(str);\r
-\r
-                sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);\r
-                CPPShInfoLogMsg(str);\r
-                for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {\r
-                    sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",\r
-                           ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));\r
-                    CPPShInfoLogMsg(str);\r
-                }\r
-            }\r
-            return -1;\r
-        } else {\r
-            atable->htable.counts[count]++;\r
-        }\r
-    }\r
-    return hashloc;\r
-} // FindHashLoc\r
-\r
-/*\r
- * IncreaseHashTableSize()\r
- *\r
- */\r
-\r
-static int IncreaseHashTableSize(AtomTable *atable)\r
-{\r
-    int ii, strloc, oldhashloc, value, size;\r
-    AtomTable oldtable;\r
-    char *s;\r
-\r
-    // Save the old atom table and create a new one:\r
-\r
-    oldtable = *atable;\r
-    size = oldtable.htable.size*2 + 1;\r
-    if (!InitAtomTable(atable, size))\r
-        return 0;\r
-\r
-    // Add all the existing values to the new atom table preserving their atom values:\r
-\r
-    for (ii = atable->nextFree; ii < oldtable.nextFree; ii++) {\r
-        strloc = oldtable.amap[ii];\r
-        s = &oldtable.stable.strings[strloc];\r
-        oldhashloc = FindHashLoc(&oldtable, s);\r
-        assert(oldhashloc >= 0);\r
-        value = oldtable.htable.entry[oldhashloc].value;\r
-        AddAtomFixed(atable, s, value);\r
-    }\r
-    FreeAtomTable(&oldtable);\r
-    return 1;\r
-} // IncreaseHashTableSize\r
-\r
-/*\r
- * LookUpAddStringHash() - Lookup a string in the hash table.  If it's not there, add it and\r
- *        initialize the atom value in the hash table to 0.  Return the hash table index.\r
- */\r
-\r
-static int LookUpAddStringHash(AtomTable *atable, const char *s)\r
-{\r
-    int hashloc, strloc;\r
-\r
-    while(1) {\r
-        hashloc = FindHashLoc(atable, s);\r
-        if (hashloc >= 0)\r
-            break;\r
-        IncreaseHashTableSize(atable);\r
-    }\r
-\r
-    if (Empty(&atable->htable, hashloc)) {\r
-        atable->htable.entries++;\r
-        strloc = AddString(&atable->stable, s);\r
-        atable->htable.entry[hashloc].index = strloc;\r
-        atable->htable.entry[hashloc].value = 0;\r
-    }\r
-    return hashloc;\r
-} // LookUpAddStringHash\r
-\r
-/*\r
- * LookUpAddString() - Lookup a string in the hash table.  If it's not there, add it and\r
- *        initialize the atom value in the hash table to the next atom number.\r
- *        Return the atom value of string.\r
- */\r
-\r
-int LookUpAddString(AtomTable *atable, const char *s)\r
-{\r
-    int hashindex, atom;\r
-\r
-    hashindex = LookUpAddStringHash(atable, s);\r
-    atom = atable->htable.entry[hashindex].value;\r
-    if (atom == 0) {\r
-        atom = AllocateAtom(atable);\r
-        SetAtomValue(atable, atom, hashindex);\r
-    }\r
-    return atom;\r
-} // LookUpAddString\r
-\r
-/*\r
- * GetAtomString()\r
- *\r
- */\r
-\r
-const  char *GetAtomString(AtomTable *atable, int atom)\r
-{\r
-    int soffset;\r
-\r
-    if (atom > 0 && atom < atable->nextFree) {\r
-        soffset = atable->amap[atom];\r
-        if (soffset > 0 && soffset < atable->stable.nextFree) {\r
-            return &atable->stable.strings[soffset];\r
-        } else {\r
-            return "<internal error: bad soffset>";\r
-        }\r
-    } else {\r
-        if (atom == 0) {\r
-            return "<null atom>";\r
-        } else {\r
-            if (atom == EOF) {\r
-                return "<EOF>";\r
-            } else {\r
-                return "<invalid atom>";\r
-            }\r
-        }\r
-    }\r
-} // GetAtomString\r
-\r
-/*\r
- * GetReversedAtom()\r
- *\r
- */\r
-\r
-int GetReversedAtom(AtomTable *atable, int atom)\r
-{\r
-    if (atom > 0 && atom < atable->nextFree) {\r
-        return atable->arev[atom];\r
-    } else {\r
-        return 0;\r
-    }\r
-} // GetReversedAtom\r
-\r
-/*\r
- * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.\r
- *         Return it's atom index.\r
- */\r
-\r
-int AddAtom(AtomTable *atable, const char *s)\r
-{\r
-    int atom;\r
-\r
-    atom = LookUpAddString(atable, s);\r
-    return atom;\r
-} // AddAtom\r
-\r
-/*\r
- * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.\r
- *         Assign it the atom value of "atom".\r
- */\r
-\r
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom)\r
-{\r
-    int hashindex, lsize;\r
-\r
-    hashindex = LookUpAddStringHash(atable, s);\r
-    if (atable->nextFree >= atable->size || atom >= atable->size) {\r
-        lsize = atable->size*2;\r
-        if (lsize <= atom)\r
-            lsize = atom + 1;\r
-        GrowAtomTable(atable, lsize);\r
-    }\r
-    atable->amap[atom] = atable->htable.entry[hashindex].index;\r
-    atable->htable.entry[hashindex].value = atom;\r
-    //if (atom >= atable->nextFree)\r
-    //    atable->nextFree = atom + 1;\r
-    while (atom >= atable->nextFree) {\r
-        atable->arev[atable->nextFree] = lReverse(atable->nextFree);\r
-        atable->nextFree++;\r
-    }\r
-    return atom;\r
-} // AddAtomFixed\r
-\r
-/*\r
- * InitAtomTable() - Initialize the atom table.\r
- *\r
- */\r
-\r
-int InitAtomTable(AtomTable *atable, int htsize)\r
-{\r
-    int ii;\r
-\r
-    htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize;\r
-    if (!InitStringTable(&atable->stable))\r
-        return 0;\r
-    if (!InitHashTable(&atable->htable, htsize))\r
-        return 0;\r
-\r
-    atable->nextFree = 0;\r
-    atable->amap = NULL;\r
-    atable->size = 0;\r
-    GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE);\r
-    if (!atable->amap)\r
-        return 0;\r
-\r
-    // Initialize lower part of atom table to "<undefined>" atom:\r
-\r
-    AddAtomFixed(atable, "<undefined>", 0);\r
-    for (ii = 0; ii < FIRST_USER_TOKEN_SY; ii++)\r
-        atable->amap[ii] = atable->amap[0];\r
-\r
-    // Add single character tokens to the atom table:\r
-\r
-    {\r
-               const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";\r
-        char t[2];\r
-\r
-        t[1] = '\0';\r
-        while (*s) {\r
-            t[0] = *s;\r
-            AddAtomFixed(atable, t, s[0]);\r
-            s++;\r
-        }\r
-    }\r
-\r
-    // Add multiple character scanner tokens :\r
-\r
-    for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++)\r
-        AddAtomFixed(atable, tokens[ii].str, tokens[ii].val);\r
-\r
-    // Add error symbol if running in error mode:\r
-\r
-    if (cpp->options.ErrorMode)\r
-        AddAtomFixed(atable, "error", ERROR_SY);\r
-\r
-    AddAtom(atable, "<*** end fixed atoms ***>");\r
-\r
-    return 1;\r
-} // InitAtomTable\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////// Debug Printing Functions: //////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-/*\r
- * PrintAtomTable()\r
- *\r
- */\r
-\r
-void PrintAtomTable(AtomTable *atable)\r
-{\r
-    int ii;\r
-    char str[200];\r
-\r
-    for (ii = 0; ii < atable->nextFree; ii++) {\r
-        sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);\r
-        CPPDebugLogMsg(str);\r
-    }\r
-    sprintf(str, "Hash table: size=%d, entries=%d, collisions=",\r
-           atable->htable.size, atable->htable.entries);\r
-    CPPDebugLogMsg(str);\r
-    for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {\r
-        sprintf(str, " %d", atable->htable.counts[ii]);\r
-        CPPDebugLogMsg(str);\r
-    }\r
-\r
-} // PrintAtomTable\r
-\r
-\r
-/*\r
- * GetStringOfAtom()\r
- *\r
- */\r
-\r
-char* GetStringOfAtom(AtomTable *atable, int atom)\r
-{\r
-        char* chr_str;\r
-        chr_str=&atable->stable.strings[atable->amap[atom]];\r
-        return chr_str;\r
-} // GetStringOfAtom\r
-\r
-/*\r
- * FreeAtomTable() - Free the atom table and associated memory\r
- *\r
- */\r
-\r
-void FreeAtomTable(AtomTable *atable)\r
-{\r
-    FreeStringTable(&atable->stable);\r
-    FreeHashTable(&atable->htable);\r
-    if (atable->amap)\r
-        free(atable->amap);\r
-    if (atable->arev)\r
-        free(atable->arev);\r
-    atable->amap = NULL;\r
-    atable->arev = NULL;\r
-    atable->nextFree = 0;\r
-    atable->size = 0;\r
-} // FreeAtomTable\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-///////////////////////////////////////// End of atom.c ///////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+/*
+// atom.c
+*/
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "slglobals.h"
+
+#undef malloc
+#undef realloc
+#undef free
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////// String table: //////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+static const struct {
+    int val;
+    const char *str;
+} tokens[] = {
+    { CPP_AND_OP,         "&&" },
+    { CPP_AND_ASSIGN,     "&=" },
+    { CPP_SUB_ASSIGN,     "-=" },
+    { CPP_MOD_ASSIGN,     "%=" },
+    { CPP_ADD_ASSIGN,     "+=" },
+    { CPP_DIV_ASSIGN,     "/=" },
+    { CPP_MUL_ASSIGN,     "*=" },
+    { CPP_RIGHT_BRACKET,  ":>" },
+    { CPP_EQ_OP,          "==" },
+    { CPP_XOR_OP,         "^^" }, 
+    { CPP_XOR_ASSIGN,     "^=" }, 
+    { CPP_FLOATCONSTANT,  "<float-const>" },
+    { CPP_GE_OP,          ">=" },
+    { CPP_RIGHT_OP,       ">>" },
+    { CPP_RIGHT_ASSIGN,   ">>=" }, 
+    { CPP_IDENTIFIER,     "<ident>" },
+    { CPP_INTCONSTANT,    "<int-const>" },
+    { CPP_LE_OP,          "<=" },
+    { CPP_LEFT_OP,        "<<" },
+    { CPP_LEFT_ASSIGN,    "<<=" },
+    { CPP_LEFT_BRACKET,   "<:" },
+    { CPP_LEFT_BRACE,     "<%" }, 
+    { CPP_DEC_OP,         "--" },
+    { CPP_RIGHT_BRACE,    "%>" }, 
+    { CPP_NE_OP,          "!=" },
+    { CPP_OR_OP,          "||" },
+    { CPP_OR_ASSIGN,      "|=" }, 
+    { CPP_INC_OP,         "++" },
+    { CPP_STRCONSTANT,    "<string-const>" },
+    { CPP_TYPEIDENTIFIER, "<type-ident>" },
+};
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////// String table: //////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+#define INIT_STRING_TABLE_SIZE 16384
+
+typedef struct StringTable_Rec {
+    char *strings;
+    int nextFree;
+    int size;
+} StringTable;
+
+/*
+ * InitStringTable() - Initialize the string table.
+ *
+ */
+
+static int InitStringTable(StringTable *stable)
+{
+    stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
+    if (!stable->strings)
+        return 0;
+    /* Zero-th offset means "empty" so don't use it. */
+    stable->nextFree = 1;
+    stable->size = INIT_STRING_TABLE_SIZE;
+    return 1;
+} /* InitStringTable */
+
+/*
+ * FreeStringTable() - Free the string table.
+ *
+ */
+
+static void FreeStringTable(StringTable *stable)
+{
+    if (stable->strings)
+        free(stable->strings);
+    stable->strings = NULL;
+    stable->nextFree = 0;
+    stable->size = 0;
+} /* FreeStringTable */
+
+/*
+ * HashString() - Hash a string with the base hash function.
+ *
+ */
+
+static int HashString(const char *s)
+{
+    int hval = 0;
+
+    while (*s) {
+        hval = (hval*13507 + *s*197) ^ (hval >> 2);
+        s++;
+    }
+    return hval & 0x7fffffff;
+} /* HashString */
+
+/*
+ * HashString2() - Hash a string with the incrimenting hash function.
+ *
+ */
+
+static int HashString2(const char *s)
+{
+    int hval = 0;
+
+    while (*s) {
+        hval = (hval*729 + *s*37) ^ (hval >> 1);
+        s++;
+    }
+    return hval;
+} /* HashString2 */
+
+/*
+ * AddString() - Add a string to a string table.  Return it's offset.
+ *
+ */
+
+static int AddString(StringTable *stable, const char *s)
+{
+    int len, loc;
+    char *str;
+
+    len = (int) strlen(s);
+    if (stable->nextFree + len + 1 >= stable->size) {
+        assert(stable->size < 1000000);
+        str = (char *) malloc(stable->size*2);
+        memcpy(str, stable->strings, stable->size);
+        free(stable->strings);
+        stable->strings = str;
+    }
+    loc = stable->nextFree;
+    strcpy(&stable->strings[loc], s);
+    stable->nextFree += len + 1;
+    return loc;
+} /* AddString */
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////// Hash table: ///////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+#define INIT_HASH_TABLE_SIZE 2047
+#define HASH_TABLE_MAX_COLLISIONS 3
+
+typedef struct HashEntry_Rec {
+    int index;      /* String table offset of string representation */
+    int value;      /* Atom (symbol) value */
+} HashEntry;
+
+typedef struct HashTable_Rec {
+    HashEntry *entry;
+    int size;
+    int entries;
+    int counts[HASH_TABLE_MAX_COLLISIONS + 1];
+} HashTable;
+
+/*
+ * InitHashTable() - Initialize the hash table.
+ *
+ */
+
+static int InitHashTable(HashTable *htable, int fsize)
+{
+    int ii;
+
+    htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize);
+    if (!htable->entry)
+        return 0;
+    htable->size = fsize;
+    for (ii = 0; ii < fsize; ii++) {
+        htable->entry[ii].index = 0;
+        htable->entry[ii].value = 0;
+    }
+    htable->entries = 0;
+    for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++)
+        htable->counts[ii] = 0;
+    return 1;
+} /* InitHashTable */
+
+/*
+ * FreeHashTable() - Free the hash table.
+ *
+ */
+
+static void FreeHashTable(HashTable *htable)
+{
+    if (htable->entry)
+        free(htable->entry);
+    htable->entry = NULL;
+    htable->size = 0;
+    htable->entries = 0;
+} /* FreeHashTable */
+
+/*
+ * Empty() - See if a hash table entry is empty.
+ *
+ */
+
+static int Empty(HashTable *htable, int hashloc)
+{
+    assert(hashloc >= 0 && hashloc < htable->size);
+    if (htable->entry[hashloc].index == 0) {
+        return 1;
+    } else {
+        return 0;
+    }
+} /* Empty */
+
+/*
+ * Match() - See if a hash table entry is matches a string.
+ *
+ */
+
+static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc)
+{
+    int strloc;
+
+    strloc = htable->entry[hashloc].index;
+    if (!strcmp(s, &stable->strings[strloc])) {
+        return 1;
+    } else {
+        return 0;
+    }
+} /* Match */
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////// Atom table: ///////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+#define INIT_ATOM_TABLE_SIZE 1024
+
+
+struct AtomTable_Rec {
+    StringTable stable; /* String table. */
+    HashTable htable;   /* Hashes string to atom number and token value.  Multiple strings can
+                        // have the same token value but each unique string is a unique atom. */
+    int *amap;          /* Maps atom value to offset in string table.  Atoms all map to unique
+                        // strings except for some undefined values in the lower, fixed part
+                        // of the atom table that map to "<undefined>".  The lowest 256 atoms
+                        // correspond to single character ASCII values except for alphanumeric
+                        // characters and '_', which can be other tokens.  Next come the
+                        // language tokens with their atom values equal to the token value.
+                        // Then come predefined atoms, followed by user specified identifiers. */
+    int *arev;          /* Reversed atom for symbol table use. */
+    int nextFree;
+    int size;
+};
+
+static AtomTable latable = { { 0 } };
+AtomTable *atable = &latable;
+
+static int AddAtomFixed(AtomTable *atable, const char *s, int atom);
+
+/*
+ * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
+ *
+ */
+
+static int GrowAtomTable(AtomTable *atable, int size)
+{
+    int *newmap, *newrev;
+
+    if (atable->size < size) {
+        if (atable->amap) {
+            newmap = realloc(atable->amap, sizeof(int)*size);
+            newrev = realloc(atable->arev, sizeof(int)*size);
+        } else {
+            newmap = malloc(sizeof(int)*size);
+            newrev = malloc(sizeof(int)*size);
+            atable->size = 0;
+        }
+        if (!newmap || !newrev) {
+            /* failed to grow -- error */
+            if (newmap)
+                atable->amap = newmap;
+            if (newrev)
+                atable->amap = newrev;
+            return -1;
+        }
+        memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));
+        memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));
+        atable->amap = newmap;
+        atable->arev = newrev;
+        atable->size = size;
+    }
+    return 0;
+} /* GrowAtomTable */
+
+/*
+ * lReverse() - Reverse the bottom 20 bits of a 32 bit int.
+ *
+ */
+
+static int lReverse(int fval)
+{
+    unsigned int in = fval;
+    int result = 0, cnt = 0;
+
+    while(in) {
+        result <<= 1;
+        result |= in&1;
+        in >>= 1;
+        cnt++;
+    }
+
+    /* Don't use all 31 bits.  One million atoms is plenty and sometimes the
+    // upper bits are used for other things. */
+
+    if (cnt < 20)
+        result <<= 20 - cnt;
+    return result;
+} /* lReverse */
+
+/*
+ * AllocateAtom() - Allocate a new atom.  Associated with the "undefined" value of -1.
+ *
+ */
+
+static int AllocateAtom(AtomTable *atable)
+{
+    if (atable->nextFree >= atable->size)
+        GrowAtomTable(atable, atable->nextFree*2);
+    atable->amap[atable->nextFree] = -1;
+    atable->arev[atable->nextFree] = lReverse(atable->nextFree);
+    atable->nextFree++;
+    return atable->nextFree - 1;
+} /* AllocateAtom */
+
+/*
+ * SetAtomValue() - Allocate a new atom associated with "hashindex".
+ *
+ */
+
+static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex)
+{
+    atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
+    atable->htable.entry[hashindex].value = atomnumber;
+} /* SetAtomValue */
+
+/*
+ * FindHashLoc() - Find the hash location for this string.  Return -1 it hash table is full.
+ *
+ */
+
+static int FindHashLoc(AtomTable *atable, const char *s)
+{
+    int hashloc, hashdelta, count;
+    int FoundEmptySlot = 0;
+    int collision[HASH_TABLE_MAX_COLLISIONS + 1];
+
+    hashloc = HashString(s) % atable->htable.size;
+    if (!Empty(&atable->htable, hashloc)) {
+        if (Match(&atable->htable, &atable->stable, s, hashloc))
+            return hashloc;
+        collision[0] = hashloc;
+        hashdelta = HashString2(s);
+        count = 0;
+        while (count < HASH_TABLE_MAX_COLLISIONS) {
+            hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size;
+            if (!Empty(&atable->htable, hashloc)) {
+                if (Match(&atable->htable, &atable->stable, s, hashloc)) {
+                    return hashloc;
+                }
+            } else {
+                FoundEmptySlot = 1;
+                break;
+            }
+            count++;
+            collision[count] = hashloc;
+        }
+
+        if (!FoundEmptySlot) {
+            if (cpp->options.DumpAtomTable) {
+                int ii;
+                char str[200];
+                sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
+                       HASH_TABLE_MAX_COLLISIONS);
+                CPPShInfoLogMsg(str);
+
+                sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
+                CPPShInfoLogMsg(str);
+                for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {
+                    sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
+                           ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
+                    CPPShInfoLogMsg(str);
+                }
+            }
+            return -1;
+        } else {
+            atable->htable.counts[count]++;
+        }
+    }
+    return hashloc;
+} /* FindHashLoc */
+
+/*
+ * IncreaseHashTableSize()
+ *
+ */
+
+static int IncreaseHashTableSize(AtomTable *atable)
+{
+    int ii, strloc, oldhashloc, value, size;
+    AtomTable oldtable;
+    char *s;
+
+    /* Save the old atom table and create a new one: */
+
+    oldtable = *atable;
+    size = oldtable.htable.size*2 + 1;
+    if (!InitAtomTable(atable, size))
+        return 0;
+
+    /* Add all the existing values to the new atom table preserving their atom values: */
+
+    for (ii = atable->nextFree; ii < oldtable.nextFree; ii++) {
+        strloc = oldtable.amap[ii];
+        s = &oldtable.stable.strings[strloc];
+        oldhashloc = FindHashLoc(&oldtable, s);
+        assert(oldhashloc >= 0);
+        value = oldtable.htable.entry[oldhashloc].value;
+        AddAtomFixed(atable, s, value);
+    }
+    FreeAtomTable(&oldtable);
+    return 1;
+} /* IncreaseHashTableSize */
+
+/*
+ * LookUpAddStringHash() - Lookup a string in the hash table.  If it's not there, add it and
+ *        initialize the atom value in the hash table to 0.  Return the hash table index.
+ */
+
+static int LookUpAddStringHash(AtomTable *atable, const char *s)
+{
+    int hashloc, strloc;
+
+    while(1) {
+        hashloc = FindHashLoc(atable, s);
+        if (hashloc >= 0)
+            break;
+        IncreaseHashTableSize(atable);
+    }
+
+    if (Empty(&atable->htable, hashloc)) {
+        atable->htable.entries++;
+        strloc = AddString(&atable->stable, s);
+        atable->htable.entry[hashloc].index = strloc;
+        atable->htable.entry[hashloc].value = 0;
+    }
+    return hashloc;
+} /* LookUpAddStringHash */
+
+/*
+ * LookUpAddString() - Lookup a string in the hash table.  If it's not there, add it and
+ *        initialize the atom value in the hash table to the next atom number.
+ *        Return the atom value of string.
+ */
+
+int LookUpAddString(AtomTable *atable, const char *s)
+{
+    int hashindex, atom;
+
+    hashindex = LookUpAddStringHash(atable, s);
+    atom = atable->htable.entry[hashindex].value;
+    if (atom == 0) {
+        atom = AllocateAtom(atable);
+        SetAtomValue(atable, atom, hashindex);
+    }
+    return atom;
+} /* LookUpAddString */
+
+/*
+ * GetAtomString()
+ *
+ */
+
+const  char *GetAtomString(AtomTable *atable, int atom)
+{
+    int soffset;
+
+    if (atom > 0 && atom < atable->nextFree) {
+        soffset = atable->amap[atom];
+        if (soffset > 0 && soffset < atable->stable.nextFree) {
+            return &atable->stable.strings[soffset];
+        } else {
+            return "<internal error: bad soffset>";
+        }
+    } else {
+        if (atom == 0) {
+            return "<null atom>";
+        } else {
+            if (atom == EOF) {
+                return "<EOF>";
+            } else {
+                return "<invalid atom>";
+            }
+        }
+    }
+} /* GetAtomString */
+
+/*
+ * GetReversedAtom()
+ *
+ */
+
+int GetReversedAtom(AtomTable *atable, int atom)
+{
+    if (atom > 0 && atom < atable->nextFree) {
+        return atable->arev[atom];
+    } else {
+        return 0;
+    }
+} /* GetReversedAtom */
+
+/*
+ * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.
+ *         Return it's atom index.
+ */
+
+int AddAtom(AtomTable *atable, const char *s)
+{
+    int atom;
+
+    atom = LookUpAddString(atable, s);
+    return atom;
+} /* AddAtom */
+
+/*
+ * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.
+ *         Assign it the atom value of "atom".
+ */
+
+static int AddAtomFixed(AtomTable *atable, const char *s, int atom)
+{
+    int hashindex, lsize;
+
+    hashindex = LookUpAddStringHash(atable, s);
+    if (atable->nextFree >= atable->size || atom >= atable->size) {
+        lsize = atable->size*2;
+        if (lsize <= atom)
+            lsize = atom + 1;
+        GrowAtomTable(atable, lsize);
+    }
+    atable->amap[atom] = atable->htable.entry[hashindex].index;
+    atable->htable.entry[hashindex].value = atom;
+    /*if (atom >= atable->nextFree)
+    //    atable->nextFree = atom + 1; */
+    while (atom >= atable->nextFree) {
+        atable->arev[atable->nextFree] = lReverse(atable->nextFree);
+        atable->nextFree++;
+    }
+    return atom;
+} /* AddAtomFixed */
+
+/*
+ * InitAtomTable() - Initialize the atom table.
+ *
+ */
+
+int InitAtomTable(AtomTable *atable, int htsize)
+{
+    int ii;
+
+    htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize;
+    if (!InitStringTable(&atable->stable))
+        return 0;
+    if (!InitHashTable(&atable->htable, htsize))
+        return 0;
+
+    atable->nextFree = 0;
+    atable->amap = NULL;
+    atable->size = 0;
+    GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE);
+    if (!atable->amap)
+        return 0;
+
+    /* Initialize lower part of atom table to "<undefined>" atom: */
+
+    AddAtomFixed(atable, "<undefined>", 0);
+    for (ii = 0; ii < FIRST_USER_TOKEN_SY; ii++)
+        atable->amap[ii] = atable->amap[0];
+
+    /* Add single character tokens to the atom table: */
+
+    {
+               const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";
+        char t[2];
+
+        t[1] = '\0';
+        while (*s) {
+            t[0] = *s;
+            AddAtomFixed(atable, t, s[0]);
+            s++;
+        }
+    }
+
+    /* Add multiple character scanner tokens : */
+
+    for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++)
+        AddAtomFixed(atable, tokens[ii].str, tokens[ii].val);
+
+    /* Add error symbol if running in error mode: */
+
+    if (cpp->options.ErrorMode)
+        AddAtomFixed(atable, "error", ERROR_SY);
+
+    AddAtom(atable, "<*** end fixed atoms ***>");
+
+    return 1;
+} /* InitAtomTable */
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////// Debug Printing Functions: //////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+/*
+ * PrintAtomTable()
+ *
+ */
+
+void PrintAtomTable(AtomTable *atable)
+{
+    int ii;
+    char str[200];
+
+    for (ii = 0; ii < atable->nextFree; ii++) {
+        sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
+        CPPDebugLogMsg(str);
+    }
+    sprintf(str, "Hash table: size=%d, entries=%d, collisions=",
+           atable->htable.size, atable->htable.entries);
+    CPPDebugLogMsg(str);
+    for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {
+        sprintf(str, " %d", atable->htable.counts[ii]);
+        CPPDebugLogMsg(str);
+    }
+
+} /* PrintAtomTable */
+
+
+/*
+ * GetStringOfAtom()
+ *
+ */
+
+char* GetStringOfAtom(AtomTable *atable, int atom)
+{
+        char* chr_str;
+        chr_str=&atable->stable.strings[atable->amap[atom]];
+        return chr_str;
+} /* GetStringOfAtom */
+
+/*
+ * FreeAtomTable() - Free the atom table and associated memory
+ *
+ */
+
+void FreeAtomTable(AtomTable *atable)
+{
+    FreeStringTable(&atable->stable);
+    FreeHashTable(&atable->htable);
+    if (atable->amap)
+        free(atable->amap);
+    if (atable->arev)
+        free(atable->arev);
+    atable->amap = NULL;
+    atable->arev = NULL;
+    atable->nextFree = 0;
+    atable->size = 0;
+} /* FreeAtomTable */
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////// End of atom.c ///////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
index 3834eeb..175ce4c 100755 (executable)
@@ -1,96 +1,96 @@
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// atom.h\r
-//\r
-\r
-#if !defined(__ATOM_H)\r
-#define __ATOM_H 1\r
-\r
-typedef struct AtomTable_Rec AtomTable;\r
-\r
-extern AtomTable *atable;\r
-\r
-int InitAtomTable(AtomTable *atable, int htsize);\r
-void FreeAtomTable(AtomTable *atable);\r
-int AddAtom(AtomTable *atable, const char *s);\r
-void PrintAtomTable(AtomTable *atable);\r
-int LookUpAddString(AtomTable *atable, const char *s);\r
-const char *GetAtomString(AtomTable *atable, int atom);\r
-int GetReversedAtom(AtomTable *atable, int atom);\r
-char* GetStringOfAtom(AtomTable *atable, int atom);\r
-#endif // !defined(__ATOM_H)\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// atom.h
+*/
+
+#if !defined(__ATOM_H)
+#define __ATOM_H 1
+
+typedef struct AtomTable_Rec AtomTable;
+
+extern AtomTable *atable;
+
+int InitAtomTable(AtomTable *atable, int htsize);
+void FreeAtomTable(AtomTable *atable);
+int AddAtom(AtomTable *atable, const char *s);
+void PrintAtomTable(AtomTable *atable);
+int LookUpAddString(AtomTable *atable, const char *s);
+const char *GetAtomString(AtomTable *atable, int atom);
+int GetReversedAtom(AtomTable *atable, int atom);
+char* GetStringOfAtom(AtomTable *atable, int atom);
+#endif /* !defined(__ATOM_H) */
index 9883994..90f82d5 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// compile.h\r
-//\r
-\r
-#if !defined(__COMPILE_H)\r
-#define __COMPILE_H 1\r
-\r
-int InitCPPStruct(void);\r
-\r
-typedef struct Options_Rec{\r
-    const char *profileString;\r
-    int ErrorMode;\r
-    int Quiet;\r
-       \r
-    // Debug The Compiler options:\r
-    int DumpAtomTable;\r
-} Options;\r
-\r
-struct CPPStruct_Rec {\r
-    // Public members\r
-    SourceLoc *pLastSourceLoc;  // Set at the start of each statement by the tree walkers\r
-    Options options;            // Compile options and parameters\r
-\r
-    // Private members\r
-    SourceLoc lastSourceLoc;\r
-\r
-    // Scanner data:\r
-\r
-    SourceLoc *tokenLoc;        // Source location of most recent token seen by the scanner\r
-    int mostRecentToken;        // Most recent token seen by the scanner\r
-    InputSrc *currentInput;\r
-    int previous_token;\r
-    int notAVersionToken;      // used to make sure that #version is the first token seen in the file, if present\r
-    \r
-       void *pC;                   // storing the parseContext of the compile object in cpp.  \r
-     \r
-    // Private members:\r
-    SourceLoc ltokenLoc;\r
-       int ifdepth;                //current #if-#else-#endif nesting in the cpp.c file (pre-processor)    \r
-    int elsedepth[64];          //Keep a track of #if depth..Max allowed is 64.   \r
-    int elsetracker;            //#if-#else and #endif constructs...Counter.\r
-    const char *ErrMsg;\r
-    int CompileError;           //Indicate compile error when #error, #else,#elif mismatch.\r
-\r
-    //\r
-    // Globals used to communicate between PaParseStrings() and yy_input()and \r
-    // also across the files.(gen_glslang.cpp and scanner.c)\r
-    //\r
-    int    PaWhichStr;            // which string we're parsing\r
-    int*   PaStrLen;              // array of lengths of the PaArgv strings\r
-    int    PaArgc;                // count of strings in the array\r
-    char** PaArgv;                // our array of strings to parse    \r
-};\r
-\r
-#endif // !defined(__COMPILE_H)\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// compile.h
+*/
+
+#if !defined(__COMPILE_H)
+#define __COMPILE_H 1
+
+int InitCPPStruct(void);
+
+typedef struct Options_Rec{
+    const char *profileString;
+    int ErrorMode;
+    int Quiet;
+       
+    /* Debug The Compiler options: */
+    int DumpAtomTable;
+} Options;
+
+struct CPPStruct_Rec {
+    /* Public members */
+    SourceLoc *pLastSourceLoc;  /* Set at the start of each statement by the tree walkers */
+    Options options;            /* Compile options and parameters */
+
+    /* Private members */
+    SourceLoc lastSourceLoc;
+
+    /* Scanner data: */
+
+    SourceLoc *tokenLoc;        /* Source location of most recent token seen by the scanner */
+    int mostRecentToken;        /* Most recent token seen by the scanner */
+    InputSrc *currentInput;
+    int previous_token;
+    int notAVersionToken;      /* used to make sure that #version is the first token seen in the file, if present */
+    
+       void *pC;                   /* storing the parseContext of the compile object in cpp. */
+     
+    /* Private members: */
+    SourceLoc ltokenLoc;
+       int ifdepth;                /* current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
+    int elsedepth[64];          /* Keep a track of #if depth..Max allowed is 64. */
+    int elsetracker;            /* #if-#else and #endif constructs...Counter. */
+    const char *ErrMsg;
+    int CompileError;           /* Indicate compile error when #error, #else,#elif mismatch. */
+
+    /*
+    // Globals used to communicate between PaParseStrings() and yy_input()and 
+    // also across the files.(gen_glslang.cpp and scanner.c)
+    */
+    int    PaWhichStr;            /* which string we're parsing */
+    int*   PaStrLen;              /* array of lengths of the PaArgv strings */
+    int    PaArgc;                /* count of strings in the array */
+    char** PaArgv;                /* our array of strings to parse */ 
+};
+
+#endif /* !defined(__COMPILE_H) */
index 3787f5a..ade86c6 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// cpp.c\r
-//\r
-\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-\r
-#include "slglobals.h"\r
-\r
-#include "slang_mesa.h"\r
-\r
-static int CPPif(yystypepp * yylvalpp);\r
-\r
-/* Don't use memory.c's replacements, as we clean up properly here */\r
-#undef malloc\r
-#undef free\r
-\r
-static int bindAtom = 0;\r
-static int constAtom = 0;\r
-static int defaultAtom = 0;\r
-static int defineAtom = 0;\r
-static int definedAtom = 0;\r
-static int elseAtom = 0;\r
-static int elifAtom = 0;\r
-static int endifAtom = 0;\r
-static int ifAtom = 0;\r
-static int ifdefAtom = 0;\r
-static int ifndefAtom = 0;\r
-static int includeAtom = 0;\r
-static int lineAtom = 0;\r
-static int pragmaAtom = 0;\r
-static int texunitAtom = 0;\r
-static int undefAtom = 0;\r
-static int errorAtom = 0;\r
-static int __LINE__Atom = 0;\r
-static int __FILE__Atom = 0;\r
-static int __VERSION__Atom = 0;\r
-static int versionAtom = 0;\r
-static int extensionAtom = 0;\r
-\r
-static Scope *macros = 0;\r
-#define MAX_MACRO_ARGS  64\r
-#define MAX_IF_NESTING  64\r
-\r
-static SourceLoc ifloc; /* outermost #if */\r
-\r
-int InitCPP(void)\r
-{\r
-    char        buffer[64], *t;\r
-    const char  *f;\r
-    // Add various atoms needed by the CPP line scanner:\r
-    bindAtom = LookUpAddString(atable, "bind");\r
-    constAtom = LookUpAddString(atable, "const");\r
-    defaultAtom = LookUpAddString(atable, "default");\r
-    defineAtom = LookUpAddString(atable, "define");\r
-    definedAtom = LookUpAddString(atable, "defined");\r
-    elifAtom = LookUpAddString(atable, "elif");\r
-    elseAtom = LookUpAddString(atable, "else");\r
-    endifAtom = LookUpAddString(atable, "endif");\r
-    ifAtom = LookUpAddString(atable, "if");\r
-    ifdefAtom = LookUpAddString(atable, "ifdef");\r
-    ifndefAtom = LookUpAddString(atable, "ifndef");\r
-    includeAtom = LookUpAddString(atable, "include");\r
-    lineAtom = LookUpAddString(atable, "line");\r
-    pragmaAtom = LookUpAddString(atable, "pragma");\r
-    texunitAtom = LookUpAddString(atable, "texunit");\r
-    undefAtom = LookUpAddString(atable, "undef");\r
-       errorAtom = LookUpAddString(atable, "error");\r
-    __LINE__Atom = LookUpAddString(atable, "__LINE__");\r
-    __FILE__Atom = LookUpAddString(atable, "__FILE__");\r
-       __VERSION__Atom = LookUpAddString(atable, "__VERSION__");\r
-    versionAtom = LookUpAddString(atable, "version");\r
-    extensionAtom = LookUpAddString(atable, "extension");\r
-    macros = NewScopeInPool(mem_CreatePool(0, 0));\r
-    strcpy(buffer, "PROFILE_");\r
-    t = buffer + strlen(buffer);\r
-    f = cpp->options.profileString;\r
-    while ((_mesa_isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)\r
-        *t++ = toupper(*f++);\r
-    *t = 0;\r
-       return 1;\r
-} // InitCPP\r
-\r
-int FreeCPP(void)\r
-{\r
-    if (macros)\r
-    {\r
-        mem_FreePool(macros->pool);\r
-        macros = 0;\r
-    }\r
-\r
-    return 1;\r
-}\r
-\r
-int FinalCPP(void)\r
-{\r
-       if (cpp->ifdepth)\r
-               CPPErrorToInfoLog("#if mismatch");\r
-    return 1;\r
-}\r
-\r
-static int CPPdefine(yystypepp * yylvalpp)\r
-{\r
-    int token, name, args[MAX_MACRO_ARGS], argc;\r
-    const char *message;\r
-    MacroSymbol mac;\r
-    Symbol *symb;\r
-    SourceLoc dummyLoc;\r
-    memset(&mac, 0, sizeof(mac));\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token != CPP_IDENTIFIER) {\r
-        CPPErrorToInfoLog("#define");\r
-        return token;\r
-    }\r
-    name = yylvalpp->sc_ident;\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token == '(' && !yylvalpp->sc_int) {\r
-        // gather arguments\r
-        argc = 0;\r
-        do {\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            if (argc == 0 && token == ')') break;\r
-            if (token != CPP_IDENTIFIER) {\r
-                               CPPErrorToInfoLog("#define");\r
-                return token;\r
-            }\r
-            if (argc < MAX_MACRO_ARGS)\r
-                args[argc++] = yylvalpp->sc_ident;\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        } while (token == ',');\r
-        if (token != ')') {\r
-            CPPErrorToInfoLog("#define");\r
-            return token;\r
-        }\r
-        mac.argc = argc;\r
-        mac.args = mem_Alloc(macros->pool, argc * sizeof(int));\r
-        memcpy(mac.args, args, argc * sizeof(int));\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       }\r
-    mac.body = NewTokenStream(GetAtomString(atable, name));\r
-    while (token != '\n') {\r
-        while (token == '\\') {\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            if (token == '\n')\r
-                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            else\r
-                RecordToken(mac.body, '\\', yylvalpp);\r
-        }\r
-        RecordToken(mac.body, token, yylvalpp);\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    };\r
-\r
-    symb = LookUpSymbol(macros, name);\r
-    if (symb) {\r
-        if (!symb->details.mac.undef) {\r
-            // already defined -- need to make sure they are identical\r
-            if (symb->details.mac.argc != mac.argc) goto error;\r
-            for (argc=0; argc < mac.argc; argc++)\r
-                if (symb->details.mac.args[argc] != mac.args[argc])\r
-                    goto error;\r
-            RewindTokenStream(symb->details.mac.body);\r
-            RewindTokenStream(mac.body);\r
-            do {\r
-                int old_lval, old_token;\r
-                old_token = ReadToken(symb->details.mac.body, yylvalpp);\r
-                old_lval = yylvalpp->sc_int;\r
-                token = ReadToken(mac.body, yylvalpp);\r
-                if (token != old_token || yylvalpp->sc_int != old_lval) { \r
-                error:\r
-                    StoreStr("Macro Redefined");\r
-                    StoreStr(GetStringOfAtom(atable,name));\r
-                    message=GetStrfromTStr();\r
-                    DecLineNumber();\r
-                    CPPShInfoLogMsg(message);\r
-                    IncLineNumber();\r
-                    ResetTString();\r
-                    break; }\r
-            } while (token > 0);\r
-        }\r
-        FreeMacro(&symb->details.mac);\r
-    } else {\r
-        dummyLoc.file = 0;\r
-        dummyLoc.line = 0;\r
-        symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);\r
-    }\r
-    symb->details.mac = mac;\r
-    return '\n';\r
-} // CPPdefine\r
-\r
-static int CPPundef(yystypepp * yylvalpp)\r
-{\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    Symbol *symb;\r
-       if(token == '\n'){\r
-               CPPErrorToInfoLog("#undef");\r
-           return token;\r
-    }\r
-    if (token != CPP_IDENTIFIER)\r
-          goto error;\r
-    symb = LookUpSymbol(macros, yylvalpp->sc_ident);\r
-    if (symb) {\r
-        symb->details.mac.undef = 1;\r
-    }\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token != '\n') {\r
-    error:\r
-        CPPErrorToInfoLog("#undef");\r
-    }\r
-    return token;\r
-} // CPPundef\r
-\r
-/* CPPelse -- skip forward to appropriate spot.  This is actually used\r
-** to skip to and #endif after seeing an #else, AND to skip to a #else,\r
-** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false\r
-*/\r
-\r
-static int CPPelse(int matchelse, yystypepp * yylvalpp)\r
-{\r
-    int atom,depth=0;\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       \r
-       while (token > 0) {\r
-               while (token != '\n')\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-               if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != '#')\r
-                       continue;\r
-               if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)\r
-                       continue;\r
-        atom = yylvalpp->sc_ident;\r
-        if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){\r
-            depth++; cpp->ifdepth++; cpp->elsetracker++;\r
-               }\r
-               else if (atom == endifAtom) {\r
-            if(--depth<=0){\r
-                       cpp->elsedepth[cpp->elsetracker]=0;\r
-                           --cpp->elsetracker;\r
-                if (cpp->ifdepth) \r
-                    --cpp->ifdepth;\r
-                break;\r
-            }             \r
-                --cpp->elsetracker;\r
-                --cpp->ifdepth;\r
-            }\r
-        else if (((int)(matchelse) != 0)&& depth==0) {\r
-                       if (atom == elseAtom ){\r
-                               break;\r
-                       } \r
-                       else if (atom == elifAtom) {\r
-                /* we decrement cpp->ifdepth here, because CPPif will increment\r
-                 * it and we really want to leave it alone */\r
-                               if (cpp->ifdepth){\r
-                                       --cpp->ifdepth;\r
-                                   --cpp->elsetracker;\r
-                               }\r
-                return CPPif(yylvalpp);\r
-            }\r
-               }\r
-        else if((atom==elseAtom) && (!ChkCorrectElseNesting())){\r
-            CPPErrorToInfoLog("#else after a #else");\r
-            cpp->CompileError=1;\r
-        }\r
-       };\r
-    return token;\r
-}\r
-\r
-enum eval_prec {\r
-    MIN_PREC,\r
-    COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,\r
-    MAX_PREC\r
-};\r
-\r
-static int op_logor(int a, int b) { return a || b; }\r
-static int op_logand(int a, int b) { return a && b; }\r
-static int op_or(int a, int b) { return a | b; }\r
-static int op_xor(int a, int b) { return a ^ b; }\r
-static int op_and(int a, int b) { return a & b; }\r
-static int op_eq(int a, int b) { return a == b; }\r
-static int op_ne(int a, int b) { return a != b; }\r
-static int op_ge(int a, int b) { return a >= b; }\r
-static int op_le(int a, int b) { return a <= b; }\r
-static int op_gt(int a, int b) { return a > b; }\r
-static int op_lt(int a, int b) { return a < b; }\r
-static int op_shl(int a, int b) { return a << b; }\r
-static int op_shr(int a, int b) { return a >> b; }\r
-static int op_add(int a, int b) { return a + b; }\r
-static int op_sub(int a, int b) { return a - b; }\r
-static int op_mul(int a, int b) { return a * b; }\r
-static int op_div(int a, int b) { return a / b; }\r
-static int op_mod(int a, int b) { return a % b; }\r
-static int op_pos(int a) { return a; }\r
-static int op_neg(int a) { return -a; }\r
-static int op_cmpl(int a) { return ~a; }\r
-static int op_not(int a) { return !a; }\r
-\r
-struct {\r
-    int token, prec, (*op)(int, int);\r
-} binop[] = {\r
-    { CPP_OR_OP, LOGOR, op_logor },\r
-    { CPP_AND_OP, LOGAND, op_logand },\r
-    { '|', OR, op_or },\r
-    { '^', XOR, op_xor },\r
-    { '&', AND, op_and },\r
-    { CPP_EQ_OP, EQUAL, op_eq },\r
-    { CPP_NE_OP, EQUAL, op_ne },\r
-    { '>', RELATION, op_gt },\r
-    { CPP_GE_OP, RELATION, op_ge },\r
-    { '<', RELATION, op_lt },\r
-    { CPP_LE_OP, RELATION, op_le },\r
-    { CPP_LEFT_OP, SHIFT, op_shl },\r
-    { CPP_RIGHT_OP, SHIFT, op_shr },\r
-    { '+', ADD, op_add },\r
-    { '-', ADD, op_sub },\r
-    { '*', MUL, op_mul },\r
-    { '/', MUL, op_div },\r
-    { '%', MUL, op_mod },\r
-};\r
-\r
-struct {\r
-    int token, (*op)(int);\r
-} unop[] = {\r
-    { '+', op_pos },\r
-    { '-', op_neg },\r
-    { '~', op_cmpl },\r
-    { '!', op_not },\r
-};\r
-\r
-#define ALEN(A) (sizeof(A)/sizeof(A[0]))\r
-\r
-static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)\r
-{\r
-    int         i, val;\r
-    Symbol      *s;\r
-    if (token == CPP_IDENTIFIER) {\r
-        if (yylvalpp->sc_ident == definedAtom) {\r
-            int needclose = 0;\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            if (token == '(') {\r
-                needclose = 1;\r
-                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            }\r
-            if (token != CPP_IDENTIFIER)\r
-                goto error;\r
-            *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))\r
-                        ? !s->details.mac.undef : 0;\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            if (needclose) {\r
-                if (token != ')')\r
-                    goto error;\r
-                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            }\r
-               } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) {\r
-                       token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            return eval(token, prec, res, err, yylvalpp);\r
-        } else {\r
-            goto error;\r
-        }\r
-       } else if (token == CPP_INTCONSTANT) {\r
-        *res = yylvalpp->sc_int;\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    } else if (token == '(') {\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        token = eval(token, MIN_PREC, res, err, yylvalpp);\r
-        if (!*err) {\r
-            if (token != ')')\r
-                goto error;\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        }\r
-    } else {\r
-        for (i = ALEN(unop) - 1; i >= 0; i--) {\r
-            if (unop[i].token == token)\r
-                break;\r
-        }\r
-        if (i >= 0) {\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-            token = eval(token, UNARY, res, err, yylvalpp);\r
-            *res = unop[i].op(*res);\r
-        } else {\r
-            goto error;\r
-        }\r
-    }\r
-    while (!*err) {\r
-        if (token == ')' || token == '\n') break;\r
-        for (i = ALEN(binop) - 1; i >= 0; i--) {\r
-            if (binop[i].token == token)\r
-                break;\r
-        }\r
-        if (i < 0 || binop[i].prec <= prec)\r
-            break;\r
-        val = *res;\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        token = eval(token, binop[i].prec, res, err, yylvalpp);\r
-        *res = binop[i].op(val, *res);\r
-    }\r
-    return token;\r
-error:\r
-    CPPErrorToInfoLog("#if");;\r
-    *err = 1;\r
-    *res = 0;\r
-    return token;\r
-} // eval\r
-\r
-static int CPPif(yystypepp * yylvalpp) {\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    int res = 0, err = 0;\r
-       cpp->elsetracker++;\r
-    if (!cpp->ifdepth++)\r
-        ifloc = *cpp->tokenLoc;\r
-       if(cpp->ifdepth >MAX_IF_NESTING){\r
-        CPPErrorToInfoLog("max #if nesting depth exceeded");\r
-               return 0;\r
-       }\r
-       token = eval(token, MIN_PREC, &res, &err, yylvalpp);\r
-    if (token != '\n') {\r
-        CPPErrorToInfoLog("#if");\r
-    } else if (!res && !err) {\r
-        token = CPPelse(1, yylvalpp);\r
-    }\r
-    return token;\r
-} // CPPif\r
-\r
-static int CPPifdef(int defined, yystypepp * yylvalpp)\r
-{\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    int name = yylvalpp->sc_ident;\r
-       if(++cpp->ifdepth >MAX_IF_NESTING){\r
-           CPPErrorToInfoLog("max #if nesting depth exceeded");\r
-               return 0;\r
-       }\r
-       cpp->elsetracker++;\r
-    if (token != CPP_IDENTIFIER) {\r
-            defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");\r
-    } else {\r
-        Symbol *s = LookUpSymbol(macros, name);\r
-        if (((s && !s->details.mac.undef) ? 1 : 0) != defined)\r
-            token = CPPelse(1, yylvalpp);\r
-    }\r
-    return token;\r
-} // CPPifdef\r
-\r
-static int CPPline(yystypepp * yylvalpp) \r
-{\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       if(token=='\n'){\r
-               DecLineNumber();\r
-        CPPErrorToInfoLog("#line");\r
-        IncLineNumber();\r
-               return token;\r
-       }\r
-       else if (token == CPP_INTCONSTANT) {\r
-               yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
-               SetLineNumber(yylvalpp->sc_int);\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        \r
-               if (token == CPP_INTCONSTANT) {\r
-            yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
-                       SetStringNumber(yylvalpp->sc_int);\r
-            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-                       if(token!='\n')\r
-                               CPPErrorToInfoLog("#line");\r
-        }\r
-               else if (token == '\n'){\r
-                       return token;\r
-               }\r
-               else{\r
-            CPPErrorToInfoLog("#line");\r
-               }\r
-       }\r
-       else{\r
-          CPPErrorToInfoLog("#line");\r
-       }\r
-    return token;\r
-}\r
-\r
-static int CPPerror(yystypepp * yylvalpp) {\r
-\r
-       int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    const char *message;\r
-       \r
-    while (token != '\n') {\r
-               if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){\r
-            StoreStr(yylvalpp->symbol_name);\r
-               }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){\r
-                       StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));\r
-               }else {\r
-                   StoreStr(GetStringOfAtom(atable,token));\r
-               }\r
-               token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       }\r
-       DecLineNumber();\r
-       //store this msg into the shader's information log..set the Compile Error flag!!!!\r
-       message=GetStrfromTStr();\r
-    CPPShInfoLogMsg(message);\r
-    ResetTString();\r
-    cpp->CompileError=1;\r
-    IncLineNumber();\r
-    return '\n';\r
-}//CPPerror\r
-\r
-static int CPPpragma(yystypepp * yylvalpp)\r
-{\r
-    const char *SrcStr;\r
-       const char *DestStr;\r
-       int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       \r
-       if(token=='\n'){\r
-               DecLineNumber();\r
-        CPPErrorToInfoLog("#pragma");\r
-        IncLineNumber();\r
-           return token;\r
-       }\r
-       if (token != CPP_IDENTIFIER)goto error;\r
-    SrcStr = GetAtomString(atable, yylvalpp->sc_ident);\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token == '(') {\r
-          token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-          if (token != CPP_IDENTIFIER) goto error;\r
-                 DestStr = GetAtomString(atable, yylvalpp->sc_ident);\r
-          token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-             if (token != ')') goto error;\r
-                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-                 if(token!='\n')goto error;\r
-             //make a call to CPP function MapStrings with SrcStr and DestStr.\r
-                 MapStrings(SrcStr,DestStr);\r
-       }else{\r
-error:\r
-               CPPErrorToInfoLog("#pragma");\r
-               return token;\r
-       }\r
-\r
-       return token;\r
-} // CPPpragma\r
-\r
-#define GL2_VERSION_NUMBER 110\r
-\r
-static int CPPversion(yystypepp * yylvalpp)\r
-{\r
-\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-\r
-    if (cpp->notAVersionToken == 1)\r
-        CPPShInfoLogMsg("#version must occur before any other statement in the program");\r
-\r
-    if(token=='\n'){\r
-               DecLineNumber();\r
-        CPPErrorToInfoLog("#version");\r
-        IncLineNumber();\r
-               return token;\r
-       }\r
-    if (token != CPP_INTCONSTANT)\r
-        CPPErrorToInfoLog("#version");\r
-       \r
-    yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
-       //SetVersionNumber(yylvalpp->sc_int);\r
-    \r
-    if (yylvalpp->sc_int != GL2_VERSION_NUMBER)\r
-        CPPShInfoLogMsg("Version number not supported by GL2");\r
-\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    \r
-       if (token == '\n'){\r
-               return token;\r
-       }\r
-       else{\r
-        CPPErrorToInfoLog("#version");\r
-       }\r
-    return token;\r
-} // CPPversion\r
-\r
-static int CPPextension(yystypepp * yylvalpp)\r
-{\r
-\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    char extensionName[80];\r
-\r
-    if(token=='\n'){\r
-               DecLineNumber();\r
-        CPPShInfoLogMsg("extension name not specified");\r
-        IncLineNumber();\r
-               return token;\r
-       }\r
-\r
-    if (token != CPP_IDENTIFIER)\r
-        CPPErrorToInfoLog("#extension");\r
-    \r
-    strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));\r
-           \r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token != ':') {\r
-        CPPShInfoLogMsg("':' missing after extension name");\r
-        return token;\r
-    }\r
-    \r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    if (token != CPP_IDENTIFIER) {\r
-        CPPShInfoLogMsg("behavior for extension not specified");\r
-        return token;\r
-    }\r
-\r
-    updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident));\r
-\r
-    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       if (token == '\n'){\r
-               return token;\r
-       }\r
-       else{\r
-        CPPErrorToInfoLog("#extension");\r
-       }\r
-    return token;\r
-} // CPPextension\r
-\r
-int readCPPline(yystypepp * yylvalpp)\r
-{\r
-    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-    const char *message;\r
-    int isVersion = 0;\r
-\r
-    if (token == CPP_IDENTIFIER) {\r
-        if (yylvalpp->sc_ident == defineAtom) {\r
-             token = CPPdefine(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == elseAtom) {\r
-                        if(ChkCorrectElseNesting()){\r
-                 if (!cpp->ifdepth ){\r
-                     CPPErrorToInfoLog("#else mismatch");\r
-                     cpp->CompileError=1;\r
-                 }\r
-                            token = CPPelse(0, yylvalpp);\r
-             }else{\r
-                 CPPErrorToInfoLog("#else after a #else");\r
-                 cpp->ifdepth=0;\r
-                 cpp->notAVersionToken = 1;\r
-                 return 0;\r
-             }\r
-               } else if (yylvalpp->sc_ident == elifAtom) {\r
-            if (!cpp->ifdepth){\r
-                 CPPErrorToInfoLog("#elif mismatch");\r
-                 cpp->CompileError=1;\r
-            } \r
-                        token = CPPelse(0, yylvalpp);\r
-        } else if (yylvalpp->sc_ident == endifAtom) {\r
-                        cpp->elsedepth[cpp->elsetracker]=0;\r
-                    --cpp->elsetracker;\r
-             if (!cpp->ifdepth){\r
-                 CPPErrorToInfoLog("#endif mismatch");\r
-                 cpp->CompileError=1;\r
-             }\r
-             else\r
-                                --cpp->ifdepth;\r
-           } else if (yylvalpp->sc_ident == ifAtom) {\r
-             token = CPPif(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == ifdefAtom) {\r
-             token = CPPifdef(1, yylvalpp);\r
-        } else if (yylvalpp->sc_ident == ifndefAtom) {\r
-             token = CPPifdef(0, yylvalpp);\r
-        } else if (yylvalpp->sc_ident == lineAtom) {\r
-             token = CPPline(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == pragmaAtom) {\r
-             token = CPPpragma(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == undefAtom) {\r
-             token = CPPundef(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == errorAtom) {\r
-             token = CPPerror(yylvalpp);\r
-        } else if (yylvalpp->sc_ident == versionAtom) {\r
-            token = CPPversion(yylvalpp);\r
-            isVersion = 1;\r
-        } else if (yylvalpp->sc_ident == extensionAtom) {\r
-            token = CPPextension(yylvalpp);\r
-        } else {\r
-            StoreStr("Invalid Directive");\r
-            StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));\r
-            message=GetStrfromTStr();\r
-            CPPShInfoLogMsg(message);\r
-            ResetTString();\r
-        }\r
-    }\r
-    while (token != '\n' && token != 0 && token != EOF) {\r
-               token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-       }\r
-        \r
-    cpp->notAVersionToken = !isVersion;\r
-\r
-    return token;\r
-} // readCPPline\r
-\r
-void FreeMacro(MacroSymbol *s) {\r
-    DeleteTokenStream(s->body);\r
-}\r
-\r
-static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; }\r
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { }\r
-\r
-static void PushEofSrc() {\r
-    InputSrc *in = malloc(sizeof(InputSrc));\r
-    memset(in, 0, sizeof(InputSrc));\r
-    in->scan = eof_scan;\r
-    in->getch = eof_scan;\r
-    in->ungetch = noop;\r
-    in->prev = cpp->currentInput;\r
-    cpp->currentInput = in;\r
-}\r
-\r
-static void PopEofSrc() {\r
-    if (cpp->currentInput->scan == eof_scan) {\r
-        InputSrc *in = cpp->currentInput;\r
-        cpp->currentInput = in->prev;\r
-        free(in);\r
-    }\r
-}\r
-\r
-static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) {\r
-    int token;\r
-    TokenStream *n;\r
-    RewindTokenStream(a);\r
-    do {\r
-        token = ReadToken(a, yylvalpp);\r
-        if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))\r
-            break;\r
-    } while (token > 0);\r
-    if (token <= 0) return a;\r
-    n = NewTokenStream("macro arg");\r
-    PushEofSrc();\r
-    ReadFromTokenStream(a, 0, 0);\r
-    while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {\r
-        if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp))\r
-            continue;\r
-        RecordToken(n, token, yylvalpp);\r
-    }\r
-    PopEofSrc();\r
-    DeleteTokenStream(a);\r
-    return n;\r
-} // PrescanMacroArg\r
-\r
-typedef struct MacroInputSrc {\r
-    InputSrc    base;\r
-    MacroSymbol *mac;\r
-    TokenStream **args;\r
-} MacroInputSrc;\r
-\r
-/* macro_scan ---\r
-** return the next token for a macro expanion, handling macro args \r
-*/\r
-static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) {\r
-    int i;\r
-    int token = ReadToken(in->mac->body, yylvalpp);\r
-    if (token == CPP_IDENTIFIER) {\r
-        for (i = in->mac->argc-1; i>=0; i--)\r
-            if (in->mac->args[i] == yylvalpp->sc_ident) break;\r
-        if (i >= 0) {\r
-            ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);\r
-            return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-        }\r
-    }\r
-    if (token > 0) return token;\r
-    in->mac->busy = 0;\r
-    cpp->currentInput = in->base.prev;\r
-    if (in->args) {\r
-        for (i=in->mac->argc-1; i>=0; i--)\r
-            DeleteTokenStream(in->args[i]);\r
-        free(in->args);\r
-    }\r
-    free(in);\r
-    return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-} // macro_scan\r
-\r
-/* MacroExpand\r
-** check an identifier (atom) to see if it a macro that should be expanded.\r
-** If it is, push an InputSrc that will produce the appropriate expansion\r
-** and return TRUE.  If not, return FALSE.\r
-*/\r
-\r
-int MacroExpand(int atom, yystypepp * yylvalpp)\r
-{\r
-    Symbol              *sym = LookUpSymbol(macros, atom);\r
-    MacroInputSrc       *in;\r
-    int i,j, token, depth=0;\r
-    const char *message;\r
-       if (atom == __LINE__Atom) {\r
-        yylvalpp->sc_int = GetLineNumber();\r
-        sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);\r
-        UngetToken(CPP_INTCONSTANT, yylvalpp);\r
-        return 1;\r
-    }\r
-    if (atom == __FILE__Atom) {\r
-        yylvalpp->sc_int = GetStringNumber();\r
-        sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);\r
-        UngetToken(CPP_INTCONSTANT, yylvalpp);\r
-        return 1;\r
-    }\r
-       if (atom == __VERSION__Atom) {\r
-        strcpy(yylvalpp->symbol_name,"100");\r
-        yylvalpp->sc_int = atoi(yylvalpp->symbol_name);\r
-        UngetToken(CPP_INTCONSTANT, yylvalpp);\r
-        return 1;\r
-    }\r
-    if (!sym || sym->details.mac.undef) return 0;\r
-    if (sym->details.mac.busy) return 0;        // no recursive expansions\r
-    in = malloc(sizeof(*in));\r
-    memset(in, 0, sizeof(*in));\r
-    in->base.scan = (void *)macro_scan;\r
-    in->base.line = cpp->currentInput->line;\r
-    in->base.name = cpp->currentInput->name;\r
-    in->mac = &sym->details.mac;\r
-    if (sym->details.mac.args) {\r
-        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-               if (token != '(') {\r
-            UngetToken(token, yylvalpp);\r
-            yylvalpp->sc_ident = atom;\r
-            return 0;\r
-        }\r
-        in->args = malloc(in->mac->argc * sizeof(TokenStream *));\r
-        for (i=0; i<in->mac->argc; i++)\r
-            in->args[i] = NewTokenStream("macro arg");\r
-               i=0;j=0;\r
-        do{\r
-            depth = 0;\r
-                       while(1) {\r
-                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-                if (token <= 0) {\r
-                    StoreStr("EOF in Macro ");\r
-                    StoreStr(GetStringOfAtom(atable,atom));\r
-                    message=GetStrfromTStr();\r
-                    CPPShInfoLogMsg(message);\r
-                    ResetTString();\r
-                    return 1;\r
-                }\r
-                if((in->mac->argc==0) && (token!=')')) break;\r
-                if (depth == 0 && (token == ',' || token == ')')) break;\r
-                if (token == '(') depth++;\r
-                if (token == ')') depth--;\r
-                RecordToken(in->args[i], token, yylvalpp);\r
-                j=1;\r
-                       }\r
-            if (token == ')') {\r
-                if((in->mac->argc==1) &&j==0)\r
-                    break;\r
-                i++;\r
-                break;\r
-            }\r
-            i++;\r
-               }while(i < in->mac->argc);\r
-\r
-        if (i < in->mac->argc) {\r
-            StoreStr("Too few args in Macro ");\r
-            StoreStr(GetStringOfAtom(atable,atom));\r
-            message=GetStrfromTStr();\r
-            CPPShInfoLogMsg(message);\r
-            ResetTString();\r
-        } else if (token != ')') {\r
-            depth=0;\r
-                       while (token >= 0 && (depth > 0 || token != ')')) {\r
-                if (token == ')') depth--;\r
-                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-                if (token == '(') depth++;\r
-            }\r
-                       \r
-            if (token <= 0) {\r
-                StoreStr("EOF in Macro ");\r
-                StoreStr(GetStringOfAtom(atable,atom));\r
-                message=GetStrfromTStr();\r
-                CPPShInfoLogMsg(message);\r
-                ResetTString();\r
-                return 1;\r
-            }\r
-            StoreStr("Too many args in Macro ");\r
-            StoreStr(GetStringOfAtom(atable,atom));\r
-            message=GetStrfromTStr();\r
-            CPPShInfoLogMsg(message);\r
-            ResetTString();\r
-               }\r
-               for (i=0; i<in->mac->argc; i++) {\r
-            in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);\r
-        }\r
-    }\r
-#if 0\r
-    printf("  <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),\r
-           loc.line, GetAtomString(atable, atom));\r
-    for (i=0; i<in->mac->argc; i++) {\r
-        printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));\r
-        DumpTokenStream(stdout, in->args[i]);\r
-        printf("'\n");\r
-    }\r
-#endif\r
-       /*retain the input source*/\r
-    in->base.prev = cpp->currentInput;\r
-    sym->details.mac.busy = 1;\r
-    RewindTokenStream(sym->details.mac.body);\r
-    cpp->currentInput = &in->base;\r
-    return 1;\r
-} // MacroExpand\r
-\r
-int ChkCorrectElseNesting(void)\r
-{\r
-    if(cpp->elsedepth[cpp->elsetracker]==0){\r
-         cpp->elsedepth[cpp->elsetracker]=1;\r
-      return 1;          \r
-    }\r
-    return 0;\r
-}\r
-\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// cpp.c
+*/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "slglobals.h"
+
+#include "slang_mesa.h"
+
+static int CPPif(yystypepp * yylvalpp);
+
+/* Don't use memory.c's replacements, as we clean up properly here */
+#undef malloc
+#undef free
+
+static int bindAtom = 0;
+static int constAtom = 0;
+static int defaultAtom = 0;
+static int defineAtom = 0;
+static int definedAtom = 0;
+static int elseAtom = 0;
+static int elifAtom = 0;
+static int endifAtom = 0;
+static int ifAtom = 0;
+static int ifdefAtom = 0;
+static int ifndefAtom = 0;
+static int includeAtom = 0;
+static int lineAtom = 0;
+static int pragmaAtom = 0;
+static int texunitAtom = 0;
+static int undefAtom = 0;
+static int errorAtom = 0;
+static int __LINE__Atom = 0;
+static int __FILE__Atom = 0;
+static int __VERSION__Atom = 0;
+static int versionAtom = 0;
+static int extensionAtom = 0;
+
+static Scope *macros = 0;
+#define MAX_MACRO_ARGS  64
+#define MAX_IF_NESTING  64
+
+static SourceLoc ifloc; /* outermost #if */
+
+int InitCPP(void)
+{
+    char        buffer[64], *t;
+    const char  *f;
+    /* Add various atoms needed by the CPP line scanner: */
+    bindAtom = LookUpAddString(atable, "bind");
+    constAtom = LookUpAddString(atable, "const");
+    defaultAtom = LookUpAddString(atable, "default");
+    defineAtom = LookUpAddString(atable, "define");
+    definedAtom = LookUpAddString(atable, "defined");
+    elifAtom = LookUpAddString(atable, "elif");
+    elseAtom = LookUpAddString(atable, "else");
+    endifAtom = LookUpAddString(atable, "endif");
+    ifAtom = LookUpAddString(atable, "if");
+    ifdefAtom = LookUpAddString(atable, "ifdef");
+    ifndefAtom = LookUpAddString(atable, "ifndef");
+    includeAtom = LookUpAddString(atable, "include");
+    lineAtom = LookUpAddString(atable, "line");
+    pragmaAtom = LookUpAddString(atable, "pragma");
+    texunitAtom = LookUpAddString(atable, "texunit");
+    undefAtom = LookUpAddString(atable, "undef");
+       errorAtom = LookUpAddString(atable, "error");
+    __LINE__Atom = LookUpAddString(atable, "__LINE__");
+    __FILE__Atom = LookUpAddString(atable, "__FILE__");
+       __VERSION__Atom = LookUpAddString(atable, "__VERSION__");
+    versionAtom = LookUpAddString(atable, "version");
+    extensionAtom = LookUpAddString(atable, "extension");
+    macros = NewScopeInPool(mem_CreatePool(0, 0));
+    strcpy(buffer, "PROFILE_");
+    t = buffer + strlen(buffer);
+    f = cpp->options.profileString;
+    while ((_mesa_isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)
+        *t++ = toupper(*f++);
+    *t = 0;
+       return 1;
+} /* InitCPP */
+
+int FreeCPP(void)
+{
+    if (macros)
+    {
+        mem_FreePool(macros->pool);
+        macros = 0;
+    }
+
+    return 1;
+}
+
+int FinalCPP(void)
+{
+       if (cpp->ifdepth)
+               CPPErrorToInfoLog("#if mismatch");
+    return 1;
+}
+
+static int CPPdefine(yystypepp * yylvalpp)
+{
+    int token, name, args[MAX_MACRO_ARGS], argc;
+    const char *message;
+    MacroSymbol mac;
+    Symbol *symb;
+    SourceLoc dummyLoc;
+    memset(&mac, 0, sizeof(mac));
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token != CPP_IDENTIFIER) {
+        CPPErrorToInfoLog("#define");
+        return token;
+    }
+    name = yylvalpp->sc_ident;
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token == '(' && !yylvalpp->sc_int) {
+        /* gather arguments */
+        argc = 0;
+        do {
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            if (argc == 0 && token == ')') break;
+            if (token != CPP_IDENTIFIER) {
+                               CPPErrorToInfoLog("#define");
+                return token;
+            }
+            if (argc < MAX_MACRO_ARGS)
+                args[argc++] = yylvalpp->sc_ident;
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        } while (token == ',');
+        if (token != ')') {
+            CPPErrorToInfoLog("#define");
+            return token;
+        }
+        mac.argc = argc;
+        mac.args = mem_Alloc(macros->pool, argc * sizeof(int));
+        memcpy(mac.args, args, argc * sizeof(int));
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       }
+    mac.body = NewTokenStream(GetAtomString(atable, name));
+    while (token != '\n') {
+        while (token == '\\') {
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            if (token == '\n')
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            else
+                RecordToken(mac.body, '\\', yylvalpp);
+        }
+        RecordToken(mac.body, token, yylvalpp);
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    };
+
+    symb = LookUpSymbol(macros, name);
+    if (symb) {
+        if (!symb->details.mac.undef) {
+            /* already defined -- need to make sure they are identical */
+            if (symb->details.mac.argc != mac.argc) goto error;
+            for (argc=0; argc < mac.argc; argc++)
+                if (symb->details.mac.args[argc] != mac.args[argc])
+                    goto error;
+            RewindTokenStream(symb->details.mac.body);
+            RewindTokenStream(mac.body);
+            do {
+                int old_lval, old_token;
+                old_token = ReadToken(symb->details.mac.body, yylvalpp);
+                old_lval = yylvalpp->sc_int;
+                token = ReadToken(mac.body, yylvalpp);
+                if (token != old_token || yylvalpp->sc_int != old_lval) { 
+                error:
+                    StoreStr("Macro Redefined");
+                    StoreStr(GetStringOfAtom(atable,name));
+                    message=GetStrfromTStr();
+                    DecLineNumber();
+                    CPPShInfoLogMsg(message);
+                    IncLineNumber();
+                    ResetTString();
+                    break; }
+            } while (token > 0);
+        }
+        FreeMacro(&symb->details.mac);
+    } else {
+        dummyLoc.file = 0;
+        dummyLoc.line = 0;
+        symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);
+    }
+    symb->details.mac = mac;
+    return '\n';
+} /* CPPdefine */
+
+static int CPPundef(yystypepp * yylvalpp)
+{
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    Symbol *symb;
+       if(token == '\n'){
+               CPPErrorToInfoLog("#undef");
+           return token;
+    }
+    if (token != CPP_IDENTIFIER)
+          goto error;
+    symb = LookUpSymbol(macros, yylvalpp->sc_ident);
+    if (symb) {
+        symb->details.mac.undef = 1;
+    }
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token != '\n') {
+    error:
+        CPPErrorToInfoLog("#undef");
+    }
+    return token;
+} /* CPPundef */
+
+/* CPPelse -- skip forward to appropriate spot.  This is actually used
+** to skip to and #endif after seeing an #else, AND to skip to a #else,
+** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false
+*/
+
+static int CPPelse(int matchelse, yystypepp * yylvalpp)
+{
+    int atom,depth=0;
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       
+       while (token > 0) {
+               while (token != '\n')
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+               if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != '#')
+                       continue;
+               if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)
+                       continue;
+        atom = yylvalpp->sc_ident;
+        if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){
+            depth++; cpp->ifdepth++; cpp->elsetracker++;
+               }
+               else if (atom == endifAtom) {
+            if(--depth<=0){
+                       cpp->elsedepth[cpp->elsetracker]=0;
+                           --cpp->elsetracker;
+                if (cpp->ifdepth) 
+                    --cpp->ifdepth;
+                break;
+            }             
+                --cpp->elsetracker;
+                --cpp->ifdepth;
+            }
+        else if (((int)(matchelse) != 0)&& depth==0) {
+                       if (atom == elseAtom ){
+                               break;
+                       } 
+                       else if (atom == elifAtom) {
+                /* we decrement cpp->ifdepth here, because CPPif will increment
+                 * it and we really want to leave it alone */
+                               if (cpp->ifdepth){
+                                       --cpp->ifdepth;
+                                   --cpp->elsetracker;
+                               }
+                return CPPif(yylvalpp);
+            }
+               }
+        else if((atom==elseAtom) && (!ChkCorrectElseNesting())){
+            CPPErrorToInfoLog("#else after a #else");
+            cpp->CompileError=1;
+        }
+       };
+    return token;
+}
+
+enum eval_prec {
+    MIN_PREC,
+    COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,
+    MAX_PREC
+};
+
+static int op_logor(int a, int b) { return a || b; }
+static int op_logand(int a, int b) { return a && b; }
+static int op_or(int a, int b) { return a | b; }
+static int op_xor(int a, int b) { return a ^ b; }
+static int op_and(int a, int b) { return a & b; }
+static int op_eq(int a, int b) { return a == b; }
+static int op_ne(int a, int b) { return a != b; }
+static int op_ge(int a, int b) { return a >= b; }
+static int op_le(int a, int b) { return a <= b; }
+static int op_gt(int a, int b) { return a > b; }
+static int op_lt(int a, int b) { return a < b; }
+static int op_shl(int a, int b) { return a << b; }
+static int op_shr(int a, int b) { return a >> b; }
+static int op_add(int a, int b) { return a + b; }
+static int op_sub(int a, int b) { return a - b; }
+static int op_mul(int a, int b) { return a * b; }
+static int op_div(int a, int b) { return a / b; }
+static int op_mod(int a, int b) { return a % b; }
+static int op_pos(int a) { return a; }
+static int op_neg(int a) { return -a; }
+static int op_cmpl(int a) { return ~a; }
+static int op_not(int a) { return !a; }
+
+struct {
+    int token, prec, (*op)(int, int);
+} binop[] = {
+    { CPP_OR_OP, LOGOR, op_logor },
+    { CPP_AND_OP, LOGAND, op_logand },
+    { '|', OR, op_or },
+    { '^', XOR, op_xor },
+    { '&', AND, op_and },
+    { CPP_EQ_OP, EQUAL, op_eq },
+    { CPP_NE_OP, EQUAL, op_ne },
+    { '>', RELATION, op_gt },
+    { CPP_GE_OP, RELATION, op_ge },
+    { '<', RELATION, op_lt },
+    { CPP_LE_OP, RELATION, op_le },
+    { CPP_LEFT_OP, SHIFT, op_shl },
+    { CPP_RIGHT_OP, SHIFT, op_shr },
+    { '+', ADD, op_add },
+    { '-', ADD, op_sub },
+    { '*', MUL, op_mul },
+    { '/', MUL, op_div },
+    { '%', MUL, op_mod },
+};
+
+struct {
+    int token, (*op)(int);
+} unop[] = {
+    { '+', op_pos },
+    { '-', op_neg },
+    { '~', op_cmpl },
+    { '!', op_not },
+};
+
+#define ALEN(A) (sizeof(A)/sizeof(A[0]))
+
+static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)
+{
+    int         i, val;
+    Symbol      *s;
+    if (token == CPP_IDENTIFIER) {
+        if (yylvalpp->sc_ident == definedAtom) {
+            int needclose = 0;
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            if (token == '(') {
+                needclose = 1;
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            }
+            if (token != CPP_IDENTIFIER)
+                goto error;
+            *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))
+                        ? !s->details.mac.undef : 0;
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            if (needclose) {
+                if (token != ')')
+                    goto error;
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            }
+               } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) {
+                       token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            return eval(token, prec, res, err, yylvalpp);
+        } else {
+            goto error;
+        }
+       } else if (token == CPP_INTCONSTANT) {
+        *res = yylvalpp->sc_int;
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    } else if (token == '(') {
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        token = eval(token, MIN_PREC, res, err, yylvalpp);
+        if (!*err) {
+            if (token != ')')
+                goto error;
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        }
+    } else {
+        for (i = ALEN(unop) - 1; i >= 0; i--) {
+            if (unop[i].token == token)
+                break;
+        }
+        if (i >= 0) {
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+            token = eval(token, UNARY, res, err, yylvalpp);
+            *res = unop[i].op(*res);
+        } else {
+            goto error;
+        }
+    }
+    while (!*err) {
+        if (token == ')' || token == '\n') break;
+        for (i = ALEN(binop) - 1; i >= 0; i--) {
+            if (binop[i].token == token)
+                break;
+        }
+        if (i < 0 || binop[i].prec <= prec)
+            break;
+        val = *res;
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        token = eval(token, binop[i].prec, res, err, yylvalpp);
+        *res = binop[i].op(val, *res);
+    }
+    return token;
+error:
+    CPPErrorToInfoLog("#if");;
+    *err = 1;
+    *res = 0;
+    return token;
+} /* eval */
+
+static int CPPif(yystypepp * yylvalpp) {
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    int res = 0, err = 0;
+       cpp->elsetracker++;
+    if (!cpp->ifdepth++)
+        ifloc = *cpp->tokenLoc;
+       if(cpp->ifdepth >MAX_IF_NESTING){
+        CPPErrorToInfoLog("max #if nesting depth exceeded");
+               return 0;
+       }
+       token = eval(token, MIN_PREC, &res, &err, yylvalpp);
+    if (token != '\n') {
+        CPPErrorToInfoLog("#if");
+    } else if (!res && !err) {
+        token = CPPelse(1, yylvalpp);
+    }
+    return token;
+} /* CPPif */
+
+static int CPPifdef(int defined, yystypepp * yylvalpp)
+{
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    int name = yylvalpp->sc_ident;
+       if(++cpp->ifdepth >MAX_IF_NESTING){
+           CPPErrorToInfoLog("max #if nesting depth exceeded");
+               return 0;
+       }
+       cpp->elsetracker++;
+    if (token != CPP_IDENTIFIER) {
+            defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
+    } else {
+        Symbol *s = LookUpSymbol(macros, name);
+        if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
+            token = CPPelse(1, yylvalpp);
+    }
+    return token;
+} /* CPPifdef */
+
+static int CPPline(yystypepp * yylvalpp) 
+{
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       if(token=='\n'){
+               DecLineNumber();
+        CPPErrorToInfoLog("#line");
+        IncLineNumber();
+               return token;
+       }
+       else if (token == CPP_INTCONSTANT) {
+               yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+               SetLineNumber(yylvalpp->sc_int);
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        
+               if (token == CPP_INTCONSTANT) {
+            yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+                       SetStringNumber(yylvalpp->sc_int);
+            token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                       if(token!='\n')
+                               CPPErrorToInfoLog("#line");
+        }
+               else if (token == '\n'){
+                       return token;
+               }
+               else{
+            CPPErrorToInfoLog("#line");
+               }
+       }
+       else{
+          CPPErrorToInfoLog("#line");
+       }
+    return token;
+}
+
+static int CPPerror(yystypepp * yylvalpp) {
+
+       int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    const char *message;
+       
+    while (token != '\n') {
+               if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){
+            StoreStr(yylvalpp->symbol_name);
+               }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){
+                       StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+               }else {
+                   StoreStr(GetStringOfAtom(atable,token));
+               }
+               token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       }
+       DecLineNumber();
+       /* store this msg into the shader's information log..set the Compile Error flag!!!! */
+       message=GetStrfromTStr();
+    CPPShInfoLogMsg(message);
+    ResetTString();
+    cpp->CompileError=1;
+    IncLineNumber();
+    return '\n';
+}/* CPPerror */
+
+static int CPPpragma(yystypepp * yylvalpp)
+{
+    const char *SrcStr;
+       const char *DestStr;
+       int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       
+       if(token=='\n'){
+               DecLineNumber();
+        CPPErrorToInfoLog("#pragma");
+        IncLineNumber();
+           return token;
+       }
+       if (token != CPP_IDENTIFIER)goto error;
+    SrcStr = GetAtomString(atable, yylvalpp->sc_ident);
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token == '(') {
+          token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+          if (token != CPP_IDENTIFIER) goto error;
+                 DestStr = GetAtomString(atable, yylvalpp->sc_ident);
+          token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+             if (token != ')') goto error;
+                 token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                 if(token!='\n')goto error;
+             /* make a call to CPP function MapStrings with SrcStr and DestStr. */
+                 MapStrings(SrcStr,DestStr);
+       }else{
+error:
+               CPPErrorToInfoLog("#pragma");
+               return token;
+       }
+
+       return token;
+} /* CPPpragma */
+
+#define GL2_VERSION_NUMBER 110
+
+static int CPPversion(yystypepp * yylvalpp)
+{
+
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+    if (cpp->notAVersionToken == 1)
+        CPPShInfoLogMsg("#version must occur before any other statement in the program");
+
+    if(token=='\n'){
+               DecLineNumber();
+        CPPErrorToInfoLog("#version");
+        IncLineNumber();
+               return token;
+       }
+    if (token != CPP_INTCONSTANT)
+        CPPErrorToInfoLog("#version");
+       
+    yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+       /* SetVersionNumber(yylvalpp->sc_int); */
+    
+    if (yylvalpp->sc_int != GL2_VERSION_NUMBER)
+        CPPShInfoLogMsg("Version number not supported by GL2");
+
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    
+       if (token == '\n'){
+               return token;
+       }
+       else{
+        CPPErrorToInfoLog("#version");
+       }
+    return token;
+} /* CPPversion */
+
+static int CPPextension(yystypepp * yylvalpp)
+{
+
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    char extensionName[80];
+
+    if(token=='\n'){
+               DecLineNumber();
+        CPPShInfoLogMsg("extension name not specified");
+        IncLineNumber();
+               return token;
+       }
+
+    if (token != CPP_IDENTIFIER)
+        CPPErrorToInfoLog("#extension");
+    
+    strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
+           
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token != ':') {
+        CPPShInfoLogMsg("':' missing after extension name");
+        return token;
+    }
+    
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    if (token != CPP_IDENTIFIER) {
+        CPPShInfoLogMsg("behavior for extension not specified");
+        return token;
+    }
+
+    updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
+
+    token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       if (token == '\n'){
+               return token;
+       }
+       else{
+        CPPErrorToInfoLog("#extension");
+       }
+    return token;
+} /* CPPextension */
+
+int readCPPline(yystypepp * yylvalpp)
+{
+    int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+    const char *message;
+    int isVersion = 0;
+
+    if (token == CPP_IDENTIFIER) {
+        if (yylvalpp->sc_ident == defineAtom) {
+             token = CPPdefine(yylvalpp);
+        } else if (yylvalpp->sc_ident == elseAtom) {
+                        if(ChkCorrectElseNesting()){
+                 if (!cpp->ifdepth ){
+                     CPPErrorToInfoLog("#else mismatch");
+                     cpp->CompileError=1;
+                 }
+                            token = CPPelse(0, yylvalpp);
+             }else{
+                 CPPErrorToInfoLog("#else after a #else");
+                 cpp->ifdepth=0;
+                 cpp->notAVersionToken = 1;
+                 return 0;
+             }
+               } else if (yylvalpp->sc_ident == elifAtom) {
+            if (!cpp->ifdepth){
+                 CPPErrorToInfoLog("#elif mismatch");
+                 cpp->CompileError=1;
+            } 
+                        token = CPPelse(0, yylvalpp);
+        } else if (yylvalpp->sc_ident == endifAtom) {
+                        cpp->elsedepth[cpp->elsetracker]=0;
+                    --cpp->elsetracker;
+             if (!cpp->ifdepth){
+                 CPPErrorToInfoLog("#endif mismatch");
+                 cpp->CompileError=1;
+             }
+             else
+                                --cpp->ifdepth;
+           } else if (yylvalpp->sc_ident == ifAtom) {
+             token = CPPif(yylvalpp);
+        } else if (yylvalpp->sc_ident == ifdefAtom) {
+             token = CPPifdef(1, yylvalpp);
+        } else if (yylvalpp->sc_ident == ifndefAtom) {
+             token = CPPifdef(0, yylvalpp);
+        } else if (yylvalpp->sc_ident == lineAtom) {
+             token = CPPline(yylvalpp);
+        } else if (yylvalpp->sc_ident == pragmaAtom) {
+             token = CPPpragma(yylvalpp);
+        } else if (yylvalpp->sc_ident == undefAtom) {
+             token = CPPundef(yylvalpp);
+        } else if (yylvalpp->sc_ident == errorAtom) {
+             token = CPPerror(yylvalpp);
+        } else if (yylvalpp->sc_ident == versionAtom) {
+            token = CPPversion(yylvalpp);
+            isVersion = 1;
+        } else if (yylvalpp->sc_ident == extensionAtom) {
+            token = CPPextension(yylvalpp);
+        } else {
+            StoreStr("Invalid Directive");
+            StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+            message=GetStrfromTStr();
+            CPPShInfoLogMsg(message);
+            ResetTString();
+        }
+    }
+    while (token != '\n' && token != 0 && token != EOF) {
+               token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+       }
+        
+    cpp->notAVersionToken = !isVersion;
+
+    return token;
+} /* readCPPline */
+
+void FreeMacro(MacroSymbol *s) {
+    DeleteTokenStream(s->body);
+}
+
+static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; }
+static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { }
+
+static void PushEofSrc() {
+    InputSrc *in = malloc(sizeof(InputSrc));
+    memset(in, 0, sizeof(InputSrc));
+    in->scan = eof_scan;
+    in->getch = eof_scan;
+    in->ungetch = noop;
+    in->prev = cpp->currentInput;
+    cpp->currentInput = in;
+}
+
+static void PopEofSrc() {
+    if (cpp->currentInput->scan == eof_scan) {
+        InputSrc *in = cpp->currentInput;
+        cpp->currentInput = in->prev;
+        free(in);
+    }
+}
+
+static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) {
+    int token;
+    TokenStream *n;
+    RewindTokenStream(a);
+    do {
+        token = ReadToken(a, yylvalpp);
+        if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))
+            break;
+    } while (token > 0);
+    if (token <= 0) return a;
+    n = NewTokenStream("macro arg");
+    PushEofSrc();
+    ReadFromTokenStream(a, 0, 0);
+    while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {
+        if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp))
+            continue;
+        RecordToken(n, token, yylvalpp);
+    }
+    PopEofSrc();
+    DeleteTokenStream(a);
+    return n;
+} /* PrescanMacroArg */
+
+typedef struct MacroInputSrc {
+    InputSrc    base;
+    MacroSymbol *mac;
+    TokenStream **args;
+} MacroInputSrc;
+
+/* macro_scan ---
+** return the next token for a macro expanion, handling macro args 
+*/
+static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) {
+    int i;
+    int token = ReadToken(in->mac->body, yylvalpp);
+    if (token == CPP_IDENTIFIER) {
+        for (i = in->mac->argc-1; i>=0; i--)
+            if (in->mac->args[i] == yylvalpp->sc_ident) break;
+        if (i >= 0) {
+            ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);
+            return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+        }
+    }
+    if (token > 0) return token;
+    in->mac->busy = 0;
+    cpp->currentInput = in->base.prev;
+    if (in->args) {
+        for (i=in->mac->argc-1; i>=0; i--)
+            DeleteTokenStream(in->args[i]);
+        free(in->args);
+    }
+    free(in);
+    return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+} /* macro_scan */
+
+/* MacroExpand
+** check an identifier (atom) to see if it a macro that should be expanded.
+** If it is, push an InputSrc that will produce the appropriate expansion
+** and return TRUE.  If not, return FALSE.
+*/
+
+int MacroExpand(int atom, yystypepp * yylvalpp)
+{
+    Symbol              *sym = LookUpSymbol(macros, atom);
+    MacroInputSrc       *in;
+    int i,j, token, depth=0;
+    const char *message;
+       if (atom == __LINE__Atom) {
+        yylvalpp->sc_int = GetLineNumber();
+        sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+        UngetToken(CPP_INTCONSTANT, yylvalpp);
+        return 1;
+    }
+    if (atom == __FILE__Atom) {
+        yylvalpp->sc_int = GetStringNumber();
+        sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+        UngetToken(CPP_INTCONSTANT, yylvalpp);
+        return 1;
+    }
+       if (atom == __VERSION__Atom) {
+        strcpy(yylvalpp->symbol_name,"100");
+        yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
+        UngetToken(CPP_INTCONSTANT, yylvalpp);
+        return 1;
+    }
+    if (!sym || sym->details.mac.undef) return 0;
+    if (sym->details.mac.busy) return 0;        /* no recursive expansions */
+    in = malloc(sizeof(*in));
+    memset(in, 0, sizeof(*in));
+    in->base.scan = (void *)macro_scan;
+    in->base.line = cpp->currentInput->line;
+    in->base.name = cpp->currentInput->name;
+    in->mac = &sym->details.mac;
+    if (sym->details.mac.args) {
+        token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+               if (token != '(') {
+            UngetToken(token, yylvalpp);
+            yylvalpp->sc_ident = atom;
+            return 0;
+        }
+        in->args = malloc(in->mac->argc * sizeof(TokenStream *));
+        for (i=0; i<in->mac->argc; i++)
+            in->args[i] = NewTokenStream("macro arg");
+               i=0;j=0;
+        do{
+            depth = 0;
+                       while(1) {
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                if (token <= 0) {
+                    StoreStr("EOF in Macro ");
+                    StoreStr(GetStringOfAtom(atable,atom));
+                    message=GetStrfromTStr();
+                    CPPShInfoLogMsg(message);
+                    ResetTString();
+                    return 1;
+                }
+                if((in->mac->argc==0) && (token!=')')) break;
+                if (depth == 0 && (token == ',' || token == ')')) break;
+                if (token == '(') depth++;
+                if (token == ')') depth--;
+                RecordToken(in->args[i], token, yylvalpp);
+                j=1;
+                       }
+            if (token == ')') {
+                if((in->mac->argc==1) &&j==0)
+                    break;
+                i++;
+                break;
+            }
+            i++;
+               }while(i < in->mac->argc);
+
+        if (i < in->mac->argc) {
+            StoreStr("Too few args in Macro ");
+            StoreStr(GetStringOfAtom(atable,atom));
+            message=GetStrfromTStr();
+            CPPShInfoLogMsg(message);
+            ResetTString();
+        } else if (token != ')') {
+            depth=0;
+                       while (token >= 0 && (depth > 0 || token != ')')) {
+                if (token == ')') depth--;
+                token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+                if (token == '(') depth++;
+            }
+                       
+            if (token <= 0) {
+                StoreStr("EOF in Macro ");
+                StoreStr(GetStringOfAtom(atable,atom));
+                message=GetStrfromTStr();
+                CPPShInfoLogMsg(message);
+                ResetTString();
+                return 1;
+            }
+            StoreStr("Too many args in Macro ");
+            StoreStr(GetStringOfAtom(atable,atom));
+            message=GetStrfromTStr();
+            CPPShInfoLogMsg(message);
+            ResetTString();
+               }
+               for (i=0; i<in->mac->argc; i++) {
+            in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
+        }
+    }
+#if 0
+    printf("  <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),
+           loc.line, GetAtomString(atable, atom));
+    for (i=0; i<in->mac->argc; i++) {
+        printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));
+        DumpTokenStream(stdout, in->args[i]);
+        printf("'\n");
+    }
+#endif
+       /*retain the input source*/
+    in->base.prev = cpp->currentInput;
+    sym->details.mac.busy = 1;
+    RewindTokenStream(sym->details.mac.body);
+    cpp->currentInput = &in->base;
+    return 1;
+} /* MacroExpand */
+
+int ChkCorrectElseNesting(void)
+{
+    if(cpp->elsedepth[cpp->elsetracker]==0){
+         cpp->elsedepth[cpp->elsetracker]=1;
+      return 1;          
+    }
+    return 0;
+}
+
+
index 8692d9b..7e493ed 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// cpp.h\r
-//\r
-\r
-#if !defined(__CPP_H)\r
-#define __CPP_H 1\r
-\r
-#include "parser.h"\r
-#include "tokens.h"\r
-\r
-int InitCPP(void);\r
-int FinalCPP(void);\r
-int  readCPPline(yystypepp * yylvalpp);\r
-int MacroExpand(int atom, yystypepp * yylvalpp);\r
-int ChkCorrectElseNesting(void);\r
-\r
-typedef struct MacroSymbol {\r
-    int argc;\r
-    int *args;\r
-    TokenStream *body;\r
-    unsigned busy:1;\r
-    unsigned undef:1;\r
-} MacroSymbol;\r
-\r
-void FreeMacro(MacroSymbol *);\r
-int PredefineMacro(char *);\r
-\r
-void  CPPDebugLogMsg(const char *msg);       // Prints information into debug log\r
-void  CPPShInfoLogMsg(const char*);         // Store cpp Err Msg into Sh.Info.Log\r
-void  MapStrings(const char*,const char*);  // #pragma directive container.\r
-void  ResetTString(void);                   // #error Message as TString.\r
-void  CPPErrorToInfoLog(char*);             // Stick all cpp errors into Sh.Info.log   .\r
-void  StoreStr(char*);                      // Store the TString in Parse Context.\r
-void  SetLineNumber(int);                   // Set line number.  \r
-void  SetStringNumber(int);                 // Set string number.    \r
-int   GetLineNumber(void);                  // Get the current String Number. \r
-int   GetStringNumber(void);                // Get the current String Number. \r
-const char* GetStrfromTStr(void);           // Convert TString to String.  \r
-void  updateExtensionBehavior(const char* extName, const char* behavior);\r
-int   FreeCPP(void);\r
-\r
-#endif // !(defined(__CPP_H)\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// cpp.h
+*/
+
+#if !defined(__CPP_H)
+#define __CPP_H 1
+
+#include "parser.h"
+#include "tokens.h"
+
+int InitCPP(void);
+int FinalCPP(void);
+int  readCPPline(yystypepp * yylvalpp);
+int MacroExpand(int atom, yystypepp * yylvalpp);
+int ChkCorrectElseNesting(void);
+
+typedef struct MacroSymbol {
+    int argc;
+    int *args;
+    TokenStream *body;
+    unsigned busy:1;
+    unsigned undef:1;
+} MacroSymbol;
+
+void FreeMacro(MacroSymbol *);
+int PredefineMacro(char *);
+
+void  CPPDebugLogMsg(const char *msg);       /* Prints information into debug log */
+void  CPPShInfoLogMsg(const char*);         /* Store cpp Err Msg into Sh.Info.Log */
+void  MapStrings(const char*,const char*);  /* #pragma directive container. */
+void  ResetTString(void);                   /* #error Message as TString. */
+void  CPPErrorToInfoLog(char*);             /* Stick all cpp errors into Sh.Info.log */ 
+void  StoreStr(char*);                      /* Store the TString in Parse Context. */
+void  SetLineNumber(int);                   /* Set line number. */
+void  SetStringNumber(int);                 /* Set string number. */
+int   GetLineNumber(void);                  /* Get the current String Number. */
+int   GetStringNumber(void);                /* Get the current String Number. */
+const char* GetStrfromTStr(void);           /* Convert TString to String. */
+void  updateExtensionBehavior(const char* extName, const char* behavior);
+int   FreeCPP(void);
+
+#endif /* !(defined(__CPP_H) */
index 155eba2..d41c456 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// cppstruct.c\r
-//\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include "slglobals.h"\r
-\r
-CPPStruct  *cpp      = NULL;\r
-static int  refCount = 0;\r
-\r
-int InitPreprocessor(void);\r
-int ResetPreprocessor(void);\r
-int FreeCPPStruct(void);\r
-int FinalizePreprocessor(void);\r
-\r
-/*\r
- * InitCPPStruct() - Initilaize the CPP structure.\r
- *\r
- */\r
-\r
-int InitCPPStruct(void)\r
-{\r
-    int len;\r
-    char *p;\r
-\r
-    cpp = (CPPStruct *) malloc(sizeof(CPPStruct));\r
-    if (cpp == NULL)\r
-        return 0;\r
-\r
-    refCount++;\r
-\r
-    // Initialize public members:\r
-    cpp->pLastSourceLoc = &cpp->lastSourceLoc;\r
-    \r
-       p = (char *) &cpp->options;\r
-    len = sizeof(cpp->options);\r
-    while (--len >= 0)\r
-        p[len] = 0;\r
-     \r
-    ResetPreprocessor();\r
-    return 1;\r
-} // InitCPPStruct\r
-\r
-int ResetPreprocessor(void)\r
-{\r
-    // Initialize private members:\r
-\r
-    cpp->lastSourceLoc.file = 0;\r
-    cpp->lastSourceLoc.line = 0;\r
-       cpp->pC=0;\r
-    cpp->CompileError=0; \r
-       cpp->ifdepth=0;\r
-    for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)\r
-               cpp->elsedepth[cpp->elsetracker]=0; \r
-       cpp->elsetracker=0;\r
-    return 1;\r
-}\r
-\r
-//Intializing the Preprocessor.\r
-\r
-int InitPreprocessor(void)\r
-{\r
-   #  define CPP_STUFF true\r
-        #  ifdef CPP_STUFF\r
-            FreeCPPStruct();\r
-            InitCPPStruct();\r
-            cpp->options.Quiet = 1;\r
-            cpp->options.profileString = "generic";\r
-            if (!InitAtomTable(atable, 0))\r
-                return 1;\r
-            if (!InitScanner(cpp))\r
-                   return 1;\r
-       #  endif\r
-  return 0; \r
-}\r
-\r
-//FreeCPPStruct() - Free the CPP structure.\r
-\r
-int FreeCPPStruct(void)\r
-{\r
-    if (refCount)\r
-    {\r
-       free(cpp);\r
-       refCount--;\r
-    }\r
-    \r
-    return 1;\r
-}\r
-\r
-//Finalizing the Preprocessor.\r
-\r
-int FinalizePreprocessor(void)\r
-{\r
-   #  define CPP_STUFF true\r
-        #  ifdef CPP_STUFF\r
-            FreeAtomTable(atable);\r
-            FreeCPPStruct();\r
-            FreeScanner();\r
-       #  endif\r
-  return 0; \r
-}\r
-\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-////////////////////////////////////// End of cppstruct.c //////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// cppstruct.c
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "slglobals.h"
+
+CPPStruct  *cpp      = NULL;
+static int  refCount = 0;
+
+int InitPreprocessor(void);
+int ResetPreprocessor(void);
+int FreeCPPStruct(void);
+int FinalizePreprocessor(void);
+
+/*
+ * InitCPPStruct() - Initilaize the CPP structure.
+ *
+ */
+
+int InitCPPStruct(void)
+{
+    int len;
+    char *p;
+
+    cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
+    if (cpp == NULL)
+        return 0;
+
+    refCount++;
+
+    /* Initialize public members: */
+    cpp->pLastSourceLoc = &cpp->lastSourceLoc;
+    
+       p = (char *) &cpp->options;
+    len = sizeof(cpp->options);
+    while (--len >= 0)
+        p[len] = 0;
+     
+    ResetPreprocessor();
+    return 1;
+} /* InitCPPStruct */
+
+int ResetPreprocessor(void)
+{
+    /* Initialize private members: */
+
+    cpp->lastSourceLoc.file = 0;
+    cpp->lastSourceLoc.line = 0;
+       cpp->pC=0;
+    cpp->CompileError=0; 
+       cpp->ifdepth=0;
+    for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
+               cpp->elsedepth[cpp->elsetracker]=0; 
+       cpp->elsetracker=0;
+    return 1;
+}
+
+/*Intializing the Preprocessor. */
+
+int InitPreprocessor(void)
+{
+   #  define CPP_STUFF true
+        #  ifdef CPP_STUFF
+            FreeCPPStruct();
+            InitCPPStruct();
+            cpp->options.Quiet = 1;
+            cpp->options.profileString = "generic";
+            if (!InitAtomTable(atable, 0))
+                return 1;
+            if (!InitScanner(cpp))
+                   return 1;
+       #  endif
+  return 0; 
+}
+
+/* FreeCPPStruct() - Free the CPP structure. */
+
+int FreeCPPStruct(void)
+{
+    if (refCount)
+    {
+       free(cpp);
+       refCount--;
+    }
+    
+    return 1;
+}
+
+/* Finalizing the Preprocessor. */
+
+int FinalizePreprocessor(void)
+{
+   #  define CPP_STUFF true
+        #  ifdef CPP_STUFF
+            FreeAtomTable(atable);
+            FreeCPPStruct();
+            FreeScanner();
+       #  endif
+  return 0; 
+}
+
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
index ee6b65f..31e6137 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-#include <stddef.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#ifdef __STDC99__\r
-#include <stdint.h>\r
-#elif defined (_WIN64)\r
-typedef unsigned __int64 uintptr_t;\r
-#else \r
-typedef unsigned int uintptr_t;\r
-#endif\r
-\r
-#include "memory.h"\r
-\r
-// default alignment and chunksize, if called with 0 arguments\r
-#define CHUNKSIZE       (64*1024)\r
-#define ALIGN           8\r
-\r
-// we need to call the `real' malloc and free, not our replacements\r
-#undef malloc\r
-#undef free\r
-\r
-struct chunk {\r
-    struct chunk        *next;\r
-};\r
-\r
-struct cleanup {\r
-    struct cleanup      *next;\r
-    void                (*fn)(void *);\r
-    void                *arg;\r
-};\r
-\r
-struct MemoryPool_rec {\r
-    struct chunk        *next;\r
-    uintptr_t           free, end;\r
-    size_t              chunksize;\r
-    uintptr_t           alignmask;\r
-    struct cleanup      *cleanup;\r
-};\r
-\r
-MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)\r
-{\r
-    MemoryPool  *pool;\r
-\r
-    if (align == 0) align = ALIGN;\r
-    if (chunksize == 0) chunksize = CHUNKSIZE;\r
-    if (align & (align-1)) return 0;\r
-    if (chunksize < sizeof(MemoryPool)) return 0;\r
-    if (chunksize & (align-1)) return 0;\r
-    if (!(pool = malloc(chunksize))) return 0;\r
-    pool->next = 0;\r
-    pool->chunksize = chunksize;\r
-    pool->alignmask = (uintptr_t)(align)-1;  \r
-    pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;\r
-    pool->end = (uintptr_t)pool + chunksize;\r
-    pool->cleanup = 0;\r
-    return pool;\r
-}\r
-\r
-void mem_FreePool(MemoryPool *pool)\r
-{\r
-    struct cleanup      *cleanup;\r
-    struct chunk        *p, *next;\r
-\r
-    for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {\r
-        cleanup->fn(cleanup->arg);\r
-    }\r
-    for (p = (struct chunk *)pool; p; p = next) {\r
-        next = p->next;\r
-        free(p);\r
-    }\r
-}\r
-\r
-void *mem_Alloc(MemoryPool *pool, size_t size)\r
-{\r
-    struct chunk *ch;\r
-    void *rv = (void *)pool->free;\r
-    size = (size + pool->alignmask) & ~pool->alignmask;\r
-    if (size <= 0) size = pool->alignmask;\r
-    pool->free += size;\r
-    if (pool->free > pool->end || pool->free < (uintptr_t)rv) {\r
-        size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)\r
-                      & ~pool->alignmask;\r
-        pool->free = (uintptr_t)rv;\r
-        if (minreq >= pool->chunksize) {\r
-            // request size is too big for the chunksize, so allocate it as\r
-            // a single chunk of the right size\r
-            ch = malloc(minreq);\r
-            if (!ch) return 0;\r
-        } else {\r
-            ch = malloc(pool->chunksize);\r
-            if (!ch) return 0;\r
-            pool->free = (uintptr_t)ch + minreq;\r
-            pool->end = (uintptr_t)ch + pool->chunksize;\r
-        }\r
-        ch->next = pool->next;\r
-        pool->next = ch;\r
-        rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);\r
-    }\r
-    return rv;\r
-}\r
-\r
-int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {\r
-    struct cleanup *cleanup;\r
-\r
-    pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);\r
-    cleanup = mem_Alloc(pool, sizeof(struct cleanup));\r
-    if (!cleanup) return -1;\r
-    cleanup->next = pool->cleanup;\r
-    cleanup->fn = fn;\r
-    cleanup->arg = arg;\r
-    pool->cleanup = cleanup;\r
-    return 0;\r
-}\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __STDC99__
+#include <stdint.h>
+#elif defined (_WIN64)
+typedef unsigned __int64 uintptr_t;
+#else 
+typedef unsigned int uintptr_t;
+#endif
+
+#include "memory.h"
+
+/* default alignment and chunksize, if called with 0 arguments */
+#define CHUNKSIZE       (64*1024)
+#define ALIGN           8
+
+/* we need to call the `real' malloc and free, not our replacements */
+#undef malloc
+#undef free
+
+struct chunk {
+    struct chunk        *next;
+};
+
+struct cleanup {
+    struct cleanup      *next;
+    void                (*fn)(void *);
+    void                *arg;
+};
+
+struct MemoryPool_rec {
+    struct chunk        *next;
+    uintptr_t           free, end;
+    size_t              chunksize;
+    uintptr_t           alignmask;
+    struct cleanup      *cleanup;
+};
+
+MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
+{
+    MemoryPool  *pool;
+
+    if (align == 0) align = ALIGN;
+    if (chunksize == 0) chunksize = CHUNKSIZE;
+    if (align & (align-1)) return 0;
+    if (chunksize < sizeof(MemoryPool)) return 0;
+    if (chunksize & (align-1)) return 0;
+    if (!(pool = malloc(chunksize))) return 0;
+    pool->next = 0;
+    pool->chunksize = chunksize;
+    pool->alignmask = (uintptr_t)(align)-1;  
+    pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
+    pool->end = (uintptr_t)pool + chunksize;
+    pool->cleanup = 0;
+    return pool;
+}
+
+void mem_FreePool(MemoryPool *pool)
+{
+    struct cleanup      *cleanup;
+    struct chunk        *p, *next;
+
+    for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
+        cleanup->fn(cleanup->arg);
+    }
+    for (p = (struct chunk *)pool; p; p = next) {
+        next = p->next;
+        free(p);
+    }
+}
+
+void *mem_Alloc(MemoryPool *pool, size_t size)
+{
+    struct chunk *ch;
+    void *rv = (void *)pool->free;
+    size = (size + pool->alignmask) & ~pool->alignmask;
+    if (size <= 0) size = pool->alignmask;
+    pool->free += size;
+    if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
+        size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
+                      & ~pool->alignmask;
+        pool->free = (uintptr_t)rv;
+        if (minreq >= pool->chunksize) {
+            /* request size is too big for the chunksize, so allocate it as
+            // a single chunk of the right size */
+            ch = malloc(minreq);
+            if (!ch) return 0;
+        } else {
+            ch = malloc(pool->chunksize);
+            if (!ch) return 0;
+            pool->free = (uintptr_t)ch + minreq;
+            pool->end = (uintptr_t)ch + pool->chunksize;
+        }
+        ch->next = pool->next;
+        pool->next = ch;
+        rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
+    }
+    return rv;
+}
+
+int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
+    struct cleanup *cleanup;
+
+    pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
+    cleanup = mem_Alloc(pool, sizeof(struct cleanup));
+    if (!cleanup) return -1;
+    cleanup->next = pool->cleanup;
+    cleanup->fn = fn;
+    cleanup->arg = arg;
+    pool->cleanup = cleanup;
+    return 0;
+}
index 544be6f..8481e6a 100755 (executable)
@@ -1,89 +1,89 @@
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-#ifndef __MEMORY_H\r
-#define __MEMORY_H\r
-\r
-typedef struct MemoryPool_rec MemoryPool;\r
-\r
-extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);\r
-extern void mem_FreePool(MemoryPool *);\r
-extern void *mem_Alloc(MemoryPool *p, size_t size);\r
-extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);\r
-extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);\r
-\r
-#endif /* __MEMORY_H */\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+#ifndef __MEMORY_H
+#define __MEMORY_H
+
+typedef struct MemoryPool_rec MemoryPool;
+
+extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
+extern void mem_FreePool(MemoryPool *);
+extern void *mem_Alloc(MemoryPool *p, size_t size);
+extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
+extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
+
+#endif /* __MEMORY_H */
index 6d8a333..017f5d0 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-#ifndef BISON_PARSER_H\r
-# define BISON_PARSER_H\r
-\r
-#ifndef yystypepp\r
-typedef struct {\r
-    int    sc_int;\r
-    float  sc_fval;\r
-    int    sc_ident;\r
-       char   symbol_name[MAX_SYMBOL_NAME_LEN+1];\r
-} yystypepp;\r
-\r
-# define YYSTYPE_IS_TRIVIAL 1\r
-#endif\r
-# define       CPP_AND_OP              257\r
-# define       CPP_SUB_ASSIGN      259\r
-# define       CPP_MOD_ASSIGN      260\r
-# define       CPP_ADD_ASSIGN  261\r
-# define       CPP_DIV_ASSIGN  262\r
-# define       CPP_MUL_ASSIGN  263\r
-# define       CPP_EQ_OP               264\r
-# define    CPP_XOR_OP         265 \r
-# define       ERROR_SY            266\r
-# define       CPP_FLOATCONSTANT       267\r
-# define       CPP_GE_OP               268\r
-# define       CPP_RIGHT_OP        269\r
-# define       CPP_IDENTIFIER      270\r
-# define       CPP_INTCONSTANT     271\r
-# define       CPP_LE_OP               272\r
-# define       CPP_LEFT_OP             273\r
-# define       CPP_DEC_OP      274\r
-# define       CPP_NE_OP               275\r
-# define       CPP_OR_OP               276\r
-# define       CPP_INC_OP          277\r
-# define       CPP_STRCONSTANT     278\r
-# define       CPP_TYPEIDENTIFIER      279\r
-\r
-# define       FIRST_USER_TOKEN_SY     289\r
-\r
-# define       CPP_RIGHT_ASSIGN            280\r
-# define       CPP_LEFT_ASSIGN     281\r
-# define       CPP_AND_ASSIGN  282\r
-# define       CPP_OR_ASSIGN   283\r
-# define       CPP_XOR_ASSIGN  284\r
-# define       CPP_LEFT_BRACKET        285\r
-# define       CPP_RIGHT_BRACKET       286\r
-# define       CPP_LEFT_BRACE  287\r
-# define       CPP_RIGHT_BRACE 288\r
-\r
-#endif /* not BISON_PARSER_H */\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+#ifndef BISON_PARSER_H
+# define BISON_PARSER_H
+
+#ifndef yystypepp
+typedef struct {
+    int    sc_int;
+    float  sc_fval;
+    int    sc_ident;
+       char   symbol_name[MAX_SYMBOL_NAME_LEN+1];
+} yystypepp;
+
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+# define       CPP_AND_OP              257
+# define       CPP_SUB_ASSIGN      259
+# define       CPP_MOD_ASSIGN      260
+# define       CPP_ADD_ASSIGN  261
+# define       CPP_DIV_ASSIGN  262
+# define       CPP_MUL_ASSIGN  263
+# define       CPP_EQ_OP               264
+# define    CPP_XOR_OP         265 
+# define       ERROR_SY            266
+# define       CPP_FLOATCONSTANT       267
+# define       CPP_GE_OP               268
+# define       CPP_RIGHT_OP        269
+# define       CPP_IDENTIFIER      270
+# define       CPP_INTCONSTANT     271
+# define       CPP_LE_OP               272
+# define       CPP_LEFT_OP             273
+# define       CPP_DEC_OP      274
+# define       CPP_NE_OP               275
+# define       CPP_OR_OP               276
+# define       CPP_INC_OP          277
+# define       CPP_STRCONSTANT     278
+# define       CPP_TYPEIDENTIFIER      279
+
+# define       FIRST_USER_TOKEN_SY     289
+
+# define       CPP_RIGHT_ASSIGN            280
+# define       CPP_LEFT_ASSIGN     281
+# define       CPP_AND_ASSIGN  282
+# define       CPP_OR_ASSIGN   283
+# define       CPP_XOR_ASSIGN  284
+# define       CPP_LEFT_BRACKET        285
+# define       CPP_RIGHT_BRACKET       286
+# define       CPP_LEFT_BRACE  287
+# define       CPP_RIGHT_BRACE 288
+
+#endif /* not BISON_PARSER_H */
index a3cd2e9..617c7ec 100755 (executable)
@@ -1,84 +1,84 @@
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-\r
-# include "slglobals.h"\r
-extern CPPStruct *cpp;\r
-int InitCPPStruct(void);\r
-int InitScanner(CPPStruct *cpp);\r
-int InitAtomTable(AtomTable *atable, int htsize);\r
-int ScanFromString(char *s);\r
-char* GetStringOfAtom(AtomTable *atable, int atom);\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+# include "slglobals.h"
+extern CPPStruct *cpp;
+int InitCPPStruct(void);
+int InitScanner(CPPStruct *cpp);
+int InitAtomTable(AtomTable *atable, int htsize);
+int ScanFromString(char *s);
+char* GetStringOfAtom(AtomTable *atable, int atom);
index 74abe03..7316023 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// scanner.c\r
-//\r
-\r
-#include <stdarg.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-\r
-#if 0\r
-    #include <ieeefp.h>\r
-    #else\r
-    #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \\r
-                       ((*(long *)&(x) & 0x007fffffL)==0000000000L))\r
-#endif\r
-\r
-#include "slglobals.h"\r
-\r
-\r
-typedef struct StringInputSrc {\r
-    InputSrc base;\r
-    char *p;\r
-} StringInputSrc;\r
-\r
-static int eof_scan(InputSrc *is, yystypepp * yylvalpp)\r
-{\r
-    return EOF;\r
-} // eof_scan\r
-\r
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}\r
-\r
-static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };\r
-\r
-static int byte_scan(InputSrc *, yystypepp * yylvalpp);\r
-\r
-#define EOL_SY '\n'\r
-\r
-#if defined(_WIN32)\r
-    #define DBG_BREAKPOINT() __asm int 3\r
-    #elif defined(_M_AMD64)\r
-    #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");\r
-    #else\r
-    #define DBG_BREAKPOINT()\r
-    #endif\r
-\r
-    #if defined(_WIN32) && !defined(_M_AMD64)\r
-    __int64 RDTSC ( void ) {\r
-\r
-        __int64 v;\r
-    \r
-        __asm __emit 0x0f\r
-        __asm __emit 0x31\r
-        __asm mov dword ptr v, eax\r
-        __asm mov dword ptr v+4, edx\r
-    \r
-        return v;\r
-    }\r
-#endif\r
-\r
-\r
-int InitScanner(CPPStruct *cpp)\r
-{\r
-    // Add various atoms needed by the CPP line scanner:\r
-    if (!InitCPP())\r
-        return 0;\r
-\r
-    cpp->mostRecentToken = 0;\r
-    cpp->tokenLoc = &cpp->ltokenLoc;\r
-\r
-    cpp->ltokenLoc.file = 0;\r
-    cpp->ltokenLoc.line = 0;\r
-\r
-    cpp->currentInput = &eof_inputsrc;\r
-    cpp->previous_token = '\n';\r
-    cpp->notAVersionToken = 0;\r
-\r
-    return 1;\r
-} // InitScanner\r
-\r
-int FreeScanner(void)\r
-{\r
-    return (FreeCPP());\r
-}\r
-\r
-/*\r
- * str_getch()\r
- * takes care of reading from multiple strings.\r
- * returns the next-char from the input stream.\r
- * returns EOF when the complete shader is parsed.\r
- */\r
-static int str_getch(StringInputSrc *in)\r
-{\r
-       for(;;){\r
-          if (*in->p){\r
-             if (*in->p == '\n') {\r
-             in->base.line++;\r
-             IncLineNumber();\r
-          }\r
-          return *in->p++;\r
-          }\r
-          if(++(cpp->PaWhichStr) < cpp->PaArgc){\r
-                 free(in);\r
-                 SetStringNumber(cpp->PaWhichStr);\r
-         SetLineNumber(1);\r
-                 ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);\r
-                 in=(StringInputSrc*)cpp->currentInput;\r
-             continue;             \r
-          }\r
-          else{\r
-             cpp->currentInput = in->base.prev;\r
-             cpp->PaWhichStr=0;\r
-          free(in);\r
-          return EOF;\r
-       }  \r
-       }\r
-} // str_getch\r
-\r
-static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {\r
-    if (in->p[-1] == ch)in->p--;\r
-       else {\r
-               *(in->p)='\0'; //this would take care of shifting to the previous string.\r
-           cpp->PaWhichStr--;\r
-       }  \r
-       if (ch == '\n') {\r
-        in->base.line--;\r
-        DecLineNumber();\r
-    }\r
-} // str_ungetch\r
-\r
-int ScanFromString(char *s)\r
-{\r
-    \r
-       StringInputSrc *in = malloc(sizeof(StringInputSrc));\r
-    memset(in, 0, sizeof(StringInputSrc));\r
-       in->p = s;\r
-    in->base.line = 1;\r
-    in->base.scan = byte_scan;\r
-    in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;\r
-    in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;\r
-    in->base.prev = cpp->currentInput;\r
-    cpp->currentInput = &in->base;\r
-\r
-    return 1;\r
-} // ScanFromString;\r
-\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////// Floating point constants: /////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/*\r
- * lBuildFloatValue() - Quick and dirty conversion to floating point.  Since all\r
- *         we need is single precision this should be quite precise.\r
- */\r
-\r
-static float lBuildFloatValue(const char *str, int len, int exp)\r
-{\r
-    double val, expval, ten;\r
-    int ii, llen, absexp;\r
-    float rv;\r
-\r
-    val = 0.0;\r
-    llen = len;\r
-    for (ii = 0; ii < len; ii++)\r
-        val = val*10.0 + (str[ii] - '0');\r
-    if (exp != 0) {\r
-        absexp = exp > 0 ? exp : -exp;\r
-        expval = 1.0f;\r
-        ten = 10.0;\r
-        while (absexp) {\r
-            if (absexp & 1)\r
-                expval *= ten;\r
-            ten *= ten;\r
-            absexp >>= 1;\r
-        }\r
-        if (exp >= 0) {\r
-            val *= expval;\r
-        } else {\r
-            val /= expval;\r
-        }\r
-    }\r
-    rv = (float)val;\r
-    if (isinff(rv)) {\r
-               CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");\r
-    }\r
-    return rv;\r
-} // lBuildFloatValue\r
-\r
-\r
-/*\r
- * lFloatConst() - Scan a floating point constant.  Assumes that the scanner\r
- *         has seen at least one digit, followed by either a decimal '.' or the\r
- *         letter 'e'.\r
- */\r
-\r
-static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)\r
-{\r
-    int HasDecimal, declen, exp, ExpSign;\r
-    int str_len;\r
-    float lval;\r
-    \r
-    HasDecimal = 0;\r
-    declen = 0;\r
-    exp = 0;\r
-       \r
-    str_len=len;\r
-    if (ch == '.') {\r
-               str[len++]=ch;\r
-        HasDecimal = 1;\r
-        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-        while (ch >= '0' && ch <= '9') {\r
-            if (len < MAX_SYMBOL_NAME_LEN) {\r
-                declen++;\r
-                if (len > 0 || ch != '0') {\r
-                    str[len] = ch;\r
-                    len++;str_len++;\r
-                }\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            } else {\r
-                CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");\r
-                len = 1,str_len=1;\r
-            }\r
-        }\r
-    }\r
-\r
-    // Exponent:\r
-\r
-    if (ch == 'e' || ch == 'E') {\r
-        ExpSign = 1;\r
-               str[len++]=ch;\r
-        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-        if (ch == '+') {\r
-            str[len++]=ch;  \r
-                       ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-        } else if (ch == '-') {\r
-            ExpSign = -1;\r
-                       str[len++]=ch;\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-        }\r
-        if (ch >= '0' && ch <= '9') {\r
-            while (ch >= '0' && ch <= '9') {\r
-                exp = exp*10 + ch - '0';\r
-                               str[len++]=ch;\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            }\r
-        } else {\r
-            CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");\r
-        }\r
-        exp *= ExpSign;\r
-    }\r
-      \r
-    if (len == 0) {\r
-        lval = 0.0f;\r
-               strcpy(str,"0.0");\r
-    } else {\r
-        str[len]='\0';      \r
-        lval = lBuildFloatValue(str, str_len, exp - declen);\r
-    }\r
-    // Suffix:\r
-    \r
-    yylvalpp->sc_fval = lval;\r
-    strcpy(yylvalpp->symbol_name,str);\r
-    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);            \r
-    return CPP_FLOATCONSTANT;\r
-} // lFloatConst\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-///////////////////////////////////////// Normal Scanner //////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-    \r
-static int byte_scan(InputSrc *in, yystypepp * yylvalpp)\r
-{\r
-    char symbol_name[MAX_SYMBOL_NAME_LEN + 1];\r
-    char string_val[MAX_STRING_LEN + 1];\r
-    int AlreadyComplained;\r
-    int len, ch, ii, ival = 0;\r
-\r
-    for (;;) {\r
-        yylvalpp->sc_int = 0;\r
-        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-               \r
-        while (ch == ' ' || ch == '\t' || ch == '\r') {\r
-            yylvalpp->sc_int = 1;\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-        }\r
-               \r
-        cpp->ltokenLoc.file = cpp->currentInput->name;\r
-        cpp->ltokenLoc.line = cpp->currentInput->line;\r
-        len = 0;\r
-        switch (ch) {\r
-        default:\r
-                       return ch; // Single character token\r
-        case EOF:\r
-            return -1;\r
-               case 'A': case 'B': case 'C': case 'D': case 'E':\r
-        case 'F': case 'G': case 'H': case 'I': case 'J':\r
-        case 'K': case 'L': case 'M': case 'N': case 'O':\r
-        case 'P': case 'Q': case 'R': case 'S': case 'T':\r
-        case 'U': case 'V': case 'W': case 'X': case 'Y':\r
-        case 'Z': case '_':\r
-        case 'a': case 'b': case 'c': case 'd': case 'e':\r
-        case 'f': case 'g': case 'h': case 'i': case 'j':\r
-        case 'k': case 'l': case 'm': case 'n': case 'o':\r
-        case 'p': case 'q': case 'r': case 's': case 't':\r
-        case 'u': case 'v': case 'w': case 'x': case 'y':\r
-        case 'z':            \r
-            do {\r
-                if (len < MAX_SYMBOL_NAME_LEN) {\r
-                    symbol_name[len] = ch;\r
-                    len++;\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                } else {\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                }\r
-            } while ((ch >= 'a' && ch <= 'z') ||\r
-                     (ch >= 'A' && ch <= 'Z') ||\r
-                     (ch >= '0' && ch <= '9') ||\r
-                     ch == '_');\r
-            if (len >= MAX_SYMBOL_NAME_LEN)\r
-                len = MAX_SYMBOL_NAME_LEN - 1;\r
-            symbol_name[len] = '\0';\r
-            cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-            yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);\r
-            return CPP_IDENTIFIER;\r
-            break;\r
-        case '0':\r
-            yylvalpp->symbol_name[len++] = ch;\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == 'x' || ch == 'X') {\r
-                               yylvalpp->symbol_name[len++] = ch;\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                if ((ch >= '0' && ch <= '9') ||\r
-                    (ch >= 'A' && ch <= 'F') ||\r
-                    (ch >= 'a' && ch <= 'f'))\r
-                {\r
-                    AlreadyComplained = 0;\r
-                    ival = 0;\r
-                    do {\r
-                                               yylvalpp->symbol_name[len++] = ch;\r
-                        if (ival <= 0x0fffffff) {\r
-                            if (ch >= '0' && ch <= '9') {\r
-                                ii = ch - '0';\r
-                            } else if (ch >= 'A' && ch <= 'F') {\r
-                                ii = ch - 'A' + 10;\r
-                            } else {\r
-                                ii = ch - 'a' + 10;\r
-                            }\r
-                            ival = (ival << 4) | ii;\r
-                        } else {\r
-                            if (!AlreadyComplained)\r
-                                CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");\r
-                            AlreadyComplained = 1;\r
-                        }\r
-                        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                    } while ((ch >= '0' && ch <= '9') ||\r
-                             (ch >= 'A' && ch <= 'F') ||\r
-                             (ch >= 'a' && ch <= 'f'));\r
-                } else {\r
-                    CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");\r
-                }\r
-                yylvalpp->symbol_name[len] = '\0';\r
-                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                               yylvalpp->sc_int = ival;\r
-                return CPP_INTCONSTANT;\r
-            } else if (ch >= '0' && ch <= '7') { // octal integer constants\r
-                AlreadyComplained = 0;\r
-                ival = 0;\r
-                do {\r
-                    yylvalpp->symbol_name[len++] = ch;\r
-                    if (ival <= 0x1fffffff) {\r
-                        ii = ch - '0';\r
-                        ival = (ival << 3) | ii;\r
-                    } else {\r
-                        if (!AlreadyComplained)\r
-                           CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");\r
-                        AlreadyComplained = 1;\r
-                    }\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                } while (ch >= '0' && ch <= '7');\r
-                if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') \r
-                     return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);\r
-                yylvalpp->symbol_name[len] = '\0';\r
-                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                               yylvalpp->sc_int = ival;\r
-                return CPP_INTCONSTANT;\r
-            } else {\r
-                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                               ch = '0';\r
-            }\r
-            // Fall through...\r
-        case '1': case '2': case '3': case '4':\r
-        case '5': case '6': case '7': case '8': case '9':\r
-            do {\r
-                if (len < MAX_SYMBOL_NAME_LEN) {\r
-                    if (len > 0 || ch != '0') {\r
-                        yylvalpp->symbol_name[len] = ch;\r
-                   len++;\r
-                    }\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                }\r
-            } while (ch >= '0' && ch <= '9');\r
-            if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {\r
-                return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);\r
-            } else {\r
-                yylvalpp->symbol_name[len] = '\0';\r
-                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                ival = 0;\r
-                AlreadyComplained = 0;\r
-                for (ii = 0; ii < len; ii++) {\r
-                    ch = yylvalpp->symbol_name[ii] - '0';\r
-                    if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) {\r
-                        if (!AlreadyComplained)\r
-                           CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");\r
-                        AlreadyComplained = 1;\r
-                    }\r
-                    ival = ival*10 + ch;\r
-                }\r
-                yylvalpp->sc_int = ival;\r
-                if(ival==0)\r
-                   strcpy(yylvalpp->symbol_name,"0");\r
-                return CPP_INTCONSTANT;\r
-            }\r
-            break;\r
-        case '-':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '-') {\r
-                return CPP_DEC_OP;\r
-            } else if (ch == '=') {\r
-                return CPP_SUB_ASSIGN;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '-';\r
-            }\r
-        case '+':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '+') {\r
-                return CPP_INC_OP;\r
-            } else if (ch == '=') {\r
-                return CPP_ADD_ASSIGN;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '+';\r
-            }\r
-        case '*':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '=') {\r
-                return CPP_MUL_ASSIGN;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '*';\r
-            }\r
-        case '%':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '=') {\r
-                return CPP_MOD_ASSIGN;\r
-            } else if (ch == '>'){\r
-                return CPP_RIGHT_BRACE;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '%';\r
-            }\r
-        case ':':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '>') {\r
-                return CPP_RIGHT_BRACKET;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return ':';\r
-            }\r
-        case '^':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '^') {\r
-                return CPP_XOR_OP;\r
-            } else {\r
-                if (ch == '=')\r
-                    return CPP_XOR_ASSIGN;\r
-                else{\r
-                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                  return '^';\r
-                }\r
-            }\r
-        \r
-        case '=':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '=') {\r
-                return CPP_EQ_OP;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '=';\r
-            }\r
-        case '!':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '=') {\r
-                return CPP_NE_OP;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '!';\r
-            }\r
-        case '|':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '|') {\r
-                return CPP_OR_OP;\r
-            } else {\r
-                if (ch == '=')\r
-                    return CPP_OR_ASSIGN;\r
-                else{\r
-                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                  return '|';\r
-                }\r
-            }\r
-        case '&':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '&') {\r
-                return CPP_AND_OP;\r
-            } else {\r
-                if (ch == '=')\r
-                    return CPP_AND_ASSIGN;\r
-                else{\r
-                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                  return '&';\r
-                }\r
-            }\r
-        case '<':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '<') {\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                if(ch == '=')\r
-                    return CPP_LEFT_ASSIGN;\r
-                else{\r
-                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                    return CPP_LEFT_OP;\r
-                }\r
-            } else {\r
-                if (ch == '=') {\r
-                    return CPP_LE_OP;\r
-                } else {\r
-                    if (ch == '%')\r
-                        return CPP_LEFT_BRACE;\r
-                    else if (ch == ':')\r
-                        return CPP_LEFT_BRACKET;\r
-                    else{\r
-                        cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                        return '<';\r
-                    }\r
-                }\r
-            }\r
-        case '>':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '>') {\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                if(ch == '=')\r
-                    return CPP_RIGHT_ASSIGN;\r
-                else{\r
-                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                    return CPP_RIGHT_OP;\r
-                }\r
-            } else {\r
-                if (ch == '=') {\r
-                    return CPP_GE_OP;\r
-                } else {\r
-                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                    return '>';\r
-                }\r
-            }\r
-        case '.':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch >= '0' && ch <= '9') {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);\r
-            } else {\r
-                if (ch == '.') {\r
-                    return -1; // Special EOF hack\r
-                } else {\r
-                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                    return '.';\r
-                }\r
-            }\r
-        case '/':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            if (ch == '/') {\r
-                do {\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                } while (ch != '\n' && ch != EOF);\r
-                if (ch == EOF)\r
-                    return -1;\r
-                return '\n';\r
-            } else if (ch == '*') {\r
-                int nlcount = 0;\r
-                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                do {\r
-                    while (ch != '*') {\r
-                        if (ch == '\n') nlcount++;\r
-                        if (ch == EOF) {\r
-                            CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");\r
-                            return -1;\r
-                        }\r
-                        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                    }\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                    if (ch == EOF) {\r
-                        CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");\r
-                        return -1;\r
-                    }\r
-                } while (ch != '/');\r
-                if (nlcount) {\r
-                    return '\n';\r
-                }\r
-                // Go try it again...\r
-            } else if (ch == '=') {\r
-                return CPP_DIV_ASSIGN;\r
-            } else {\r
-                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);\r
-                return '/';\r
-            }\r
-            break;\r
-        case '"':\r
-            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-            while (ch != '"' && ch != '\n' && ch != EOF) {\r
-                if (ch == '\\') {\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                    if (ch == '\n' || ch == EOF) {\r
-                        break;\r
-                    }\r
-                }\r
-                if (len < MAX_STRING_LEN) {\r
-                    string_val[len] = ch;\r
-                    len++;\r
-                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);\r
-                }\r
-            };\r
-            string_val[len] = '\0';\r
-            if (ch == '"') {\r
-                yylvalpp->sc_ident = LookUpAddString(atable, string_val);\r
-                return CPP_STRCONSTANT;\r
-            } else {\r
-                CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");\r
-                return ERROR_SY;\r
-            }\r
-        }\r
-    }\r
-} // byte_scan\r
-\r
-int yylex_CPP(char* buf, int maxSize)\r
-{    \r
-       yystypepp yylvalpp;\r
-    int token = '\n';\r
-\r
-    for(;;) {\r
-               \r
-        char* tokenString = 0;\r
-        token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);\r
-               if(check_EOF(token))\r
-                  return 0;\r
-               if (token == '#' && (cpp->previous_token == '\n'||cpp->previous_token==0)) {\r
-                       token = readCPPline(&yylvalpp);\r
-            if(check_EOF(token))\r
-                return 0;\r
-                       continue;\r
-               }\r
-        cpp->previous_token = token;\r
-        // expand macros\r
-        if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {\r
-            cpp->notAVersionToken = 1;\r
-            continue;\r
-        }\r
-        \r
-        if (token == '\n')\r
-            continue;\r
-  \r
-        if (token == CPP_IDENTIFIER) {\r
-            cpp->notAVersionToken = 1;\r
-            tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);\r
-        } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){ \r
-            cpp->notAVersionToken = 1;\r
-            tokenString = yylvalpp.symbol_name;\r
-               } else {\r
-            cpp->notAVersionToken = 1;\r
-            tokenString = GetStringOfAtom(atable,token);\r
-           }\r
-                \r
-        if (tokenString) {\r
-            if ((signed)strlen(tokenString) >= maxSize) {\r
-                return maxSize;\r
-            } else  if (strlen(tokenString) > 0) {\r
-                           strcpy(buf, tokenString);\r
-                return (int)strlen(tokenString);\r
-            }\r
-\r
-            return 0;\r
-        }\r
-    }\r
-\r
-    return 0;\r
-} // yylex\r
-\r
-//Checks if the token just read is EOF or not.\r
-int check_EOF(int token)\r
-{\r
-   if(token==-1){\r
-       if(cpp->ifdepth >0){\r
-               CPPErrorToInfoLog("#endif missing!! Compilation stopped");\r
-        cpp->CompileError=1;\r
-       }\r
-      return 1;\r
-   }\r
-   return 0;\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////////// End of scanner.c //////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// scanner.c
+*/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if 0
+    #include <ieeefp.h>
+    #else
+    #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
+                       ((*(long *)&(x) & 0x007fffffL)==0000000000L))
+#endif
+
+#include "slglobals.h"
+
+
+typedef struct StringInputSrc {
+    InputSrc base;
+    char *p;
+} StringInputSrc;
+
+static int eof_scan(InputSrc *is, yystypepp * yylvalpp)
+{
+    return EOF;
+} /* eof_scan */
+
+static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}
+
+static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
+
+static int byte_scan(InputSrc *, yystypepp * yylvalpp);
+
+#define EOL_SY '\n'
+
+#if defined(_WIN32)
+    #define DBG_BREAKPOINT() __asm int 3
+    #elif defined(_M_AMD64)
+    #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");
+    #else
+    #define DBG_BREAKPOINT()
+    #endif
+
+    #if defined(_WIN32) && !defined(_M_AMD64)
+    __int64 RDTSC ( void ) {
+
+        __int64 v;
+    
+        __asm __emit 0x0f
+        __asm __emit 0x31
+        __asm mov dword ptr v, eax
+        __asm mov dword ptr v+4, edx
+    
+        return v;
+    }
+#endif
+
+
+int InitScanner(CPPStruct *cpp)
+{
+    /* Add various atoms needed by the CPP line scanner: */
+    if (!InitCPP())
+        return 0;
+
+    cpp->mostRecentToken = 0;
+    cpp->tokenLoc = &cpp->ltokenLoc;
+
+    cpp->ltokenLoc.file = 0;
+    cpp->ltokenLoc.line = 0;
+
+    cpp->currentInput = &eof_inputsrc;
+    cpp->previous_token = '\n';
+    cpp->notAVersionToken = 0;
+
+    return 1;
+} /* InitScanner */
+
+int FreeScanner(void)
+{
+    return (FreeCPP());
+}
+
+/*
+ * str_getch()
+ * takes care of reading from multiple strings.
+ * returns the next-char from the input stream.
+ * returns EOF when the complete shader is parsed.
+ */
+static int str_getch(StringInputSrc *in)
+{
+       for(;;){
+          if (*in->p){
+             if (*in->p == '\n') {
+             in->base.line++;
+             IncLineNumber();
+          }
+          return *in->p++;
+          }
+          if(++(cpp->PaWhichStr) < cpp->PaArgc){
+                 free(in);
+                 SetStringNumber(cpp->PaWhichStr);
+         SetLineNumber(1);
+                 ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);
+                 in=(StringInputSrc*)cpp->currentInput;
+             continue;             
+          }
+          else{
+             cpp->currentInput = in->base.prev;
+             cpp->PaWhichStr=0;
+          free(in);
+          return EOF;
+       }  
+       }
+} /* str_getch */
+
+static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {
+    if (in->p[-1] == ch)in->p--;
+       else {
+               *(in->p)='\0'; /* this would take care of shifting to the previous string. */
+           cpp->PaWhichStr--;
+       }  
+       if (ch == '\n') {
+        in->base.line--;
+        DecLineNumber();
+    }
+} /* str_ungetch */
+
+int ScanFromString(char *s)
+{
+    
+       StringInputSrc *in = malloc(sizeof(StringInputSrc));
+    memset(in, 0, sizeof(StringInputSrc));
+       in->p = s;
+    in->base.line = 1;
+    in->base.scan = byte_scan;
+    in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;
+    in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;
+    in->base.prev = cpp->currentInput;
+    cpp->currentInput = &in->base;
+
+    return 1;
+} /* ScanFromString; */
+
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////// Floating point constants: /////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+/*
+ * lBuildFloatValue() - Quick and dirty conversion to floating point.  Since all
+ *         we need is single precision this should be quite precise.
+ */
+
+static float lBuildFloatValue(const char *str, int len, int exp)
+{
+    double val, expval, ten;
+    int ii, llen, absexp;
+    float rv;
+
+    val = 0.0;
+    llen = len;
+    for (ii = 0; ii < len; ii++)
+        val = val*10.0 + (str[ii] - '0');
+    if (exp != 0) {
+        absexp = exp > 0 ? exp : -exp;
+        expval = 1.0f;
+        ten = 10.0;
+        while (absexp) {
+            if (absexp & 1)
+                expval *= ten;
+            ten *= ten;
+            absexp >>= 1;
+        }
+        if (exp >= 0) {
+            val *= expval;
+        } else {
+            val /= expval;
+        }
+    }
+    rv = (float)val;
+    if (isinff(rv)) {
+               CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");
+    }
+    return rv;
+} /* lBuildFloatValue */
+
+
+/*
+ * lFloatConst() - Scan a floating point constant.  Assumes that the scanner
+ *         has seen at least one digit, followed by either a decimal '.' or the
+ *         letter 'e'.
+ */
+
+static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
+{
+    int HasDecimal, declen, exp, ExpSign;
+    int str_len;
+    float lval;
+    
+    HasDecimal = 0;
+    declen = 0;
+    exp = 0;
+       
+    str_len=len;
+    if (ch == '.') {
+               str[len++]=ch;
+        HasDecimal = 1;
+        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+        while (ch >= '0' && ch <= '9') {
+            if (len < MAX_SYMBOL_NAME_LEN) {
+                declen++;
+                if (len > 0 || ch != '0') {
+                    str[len] = ch;
+                    len++;str_len++;
+                }
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            } else {
+                CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+                len = 1,str_len=1;
+            }
+        }
+    }
+
+    /* Exponent: */
+
+    if (ch == 'e' || ch == 'E') {
+        ExpSign = 1;
+               str[len++]=ch;
+        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+        if (ch == '+') {
+            str[len++]=ch;  
+                       ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+        } else if (ch == '-') {
+            ExpSign = -1;
+                       str[len++]=ch;
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+        }
+        if (ch >= '0' && ch <= '9') {
+            while (ch >= '0' && ch <= '9') {
+                exp = exp*10 + ch - '0';
+                               str[len++]=ch;
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            }
+        } else {
+            CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");
+        }
+        exp *= ExpSign;
+    }
+      
+    if (len == 0) {
+        lval = 0.0f;
+               strcpy(str,"0.0");
+    } else {
+        str[len]='\0';      
+        lval = lBuildFloatValue(str, str_len, exp - declen);
+    }
+    /* Suffix: */
+    
+    yylvalpp->sc_fval = lval;
+    strcpy(yylvalpp->symbol_name,str);
+    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);            
+    return CPP_FLOATCONSTANT;
+} /* lFloatConst */
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////// Normal Scanner //////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+    
+static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
+{
+    char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
+    char string_val[MAX_STRING_LEN + 1];
+    int AlreadyComplained;
+    int len, ch, ii, ival = 0;
+
+    for (;;) {
+        yylvalpp->sc_int = 0;
+        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+               
+        while (ch == ' ' || ch == '\t' || ch == '\r') {
+            yylvalpp->sc_int = 1;
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+        }
+               
+        cpp->ltokenLoc.file = cpp->currentInput->name;
+        cpp->ltokenLoc.line = cpp->currentInput->line;
+        len = 0;
+        switch (ch) {
+        default:
+                       return ch; /* Single character token */
+        case EOF:
+            return -1;
+               case 'A': case 'B': case 'C': case 'D': case 'E':
+        case 'F': case 'G': case 'H': case 'I': case 'J':
+        case 'K': case 'L': case 'M': case 'N': case 'O':
+        case 'P': case 'Q': case 'R': case 'S': case 'T':
+        case 'U': case 'V': case 'W': case 'X': case 'Y':
+        case 'Z': case '_':
+        case 'a': case 'b': case 'c': case 'd': case 'e':
+        case 'f': case 'g': case 'h': case 'i': case 'j':
+        case 'k': case 'l': case 'm': case 'n': case 'o':
+        case 'p': case 'q': case 'r': case 's': case 't':
+        case 'u': case 'v': case 'w': case 'x': case 'y':
+        case 'z':            
+            do {
+                if (len < MAX_SYMBOL_NAME_LEN) {
+                    symbol_name[len] = ch;
+                    len++;
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                } else {
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                }
+            } while ((ch >= 'a' && ch <= 'z') ||
+                     (ch >= 'A' && ch <= 'Z') ||
+                     (ch >= '0' && ch <= '9') ||
+                     ch == '_');
+            if (len >= MAX_SYMBOL_NAME_LEN)
+                len = MAX_SYMBOL_NAME_LEN - 1;
+            symbol_name[len] = '\0';
+            cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+            yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
+            return CPP_IDENTIFIER;
+            break;
+        case '0':
+            yylvalpp->symbol_name[len++] = ch;
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == 'x' || ch == 'X') {
+                               yylvalpp->symbol_name[len++] = ch;
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                if ((ch >= '0' && ch <= '9') ||
+                    (ch >= 'A' && ch <= 'F') ||
+                    (ch >= 'a' && ch <= 'f'))
+                {
+                    AlreadyComplained = 0;
+                    ival = 0;
+                    do {
+                                               yylvalpp->symbol_name[len++] = ch;
+                        if (ival <= 0x0fffffff) {
+                            if (ch >= '0' && ch <= '9') {
+                                ii = ch - '0';
+                            } else if (ch >= 'A' && ch <= 'F') {
+                                ii = ch - 'A' + 10;
+                            } else {
+                                ii = ch - 'a' + 10;
+                            }
+                            ival = (ival << 4) | ii;
+                        } else {
+                            if (!AlreadyComplained)
+                                CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");
+                            AlreadyComplained = 1;
+                        }
+                        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                    } while ((ch >= '0' && ch <= '9') ||
+                             (ch >= 'A' && ch <= 'F') ||
+                             (ch >= 'a' && ch <= 'f'));
+                } else {
+                    CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");
+                }
+                yylvalpp->symbol_name[len] = '\0';
+                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                               yylvalpp->sc_int = ival;
+                return CPP_INTCONSTANT;
+            } else if (ch >= '0' && ch <= '7') { /* octal integer constants */
+                AlreadyComplained = 0;
+                ival = 0;
+                do {
+                    yylvalpp->symbol_name[len++] = ch;
+                    if (ival <= 0x1fffffff) {
+                        ii = ch - '0';
+                        ival = (ival << 3) | ii;
+                    } else {
+                        if (!AlreadyComplained)
+                           CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");
+                        AlreadyComplained = 1;
+                    }
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                } while (ch >= '0' && ch <= '7');
+                if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') 
+                     return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+                yylvalpp->symbol_name[len] = '\0';
+                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                               yylvalpp->sc_int = ival;
+                return CPP_INTCONSTANT;
+            } else {
+                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                               ch = '0';
+            }
+            /* Fall through... */
+        case '1': case '2': case '3': case '4':
+        case '5': case '6': case '7': case '8': case '9':
+            do {
+                if (len < MAX_SYMBOL_NAME_LEN) {
+                    if (len > 0 || ch != '0') {
+                        yylvalpp->symbol_name[len] = ch;
+                   len++;
+                    }
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                }
+            } while (ch >= '0' && ch <= '9');
+            if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {
+                return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+            } else {
+                yylvalpp->symbol_name[len] = '\0';
+                               cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                ival = 0;
+                AlreadyComplained = 0;
+                for (ii = 0; ii < len; ii++) {
+                    ch = yylvalpp->symbol_name[ii] - '0';
+                    if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) {
+                        if (!AlreadyComplained)
+                           CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");
+                        AlreadyComplained = 1;
+                    }
+                    ival = ival*10 + ch;
+                }
+                yylvalpp->sc_int = ival;
+                if(ival==0)
+                   strcpy(yylvalpp->symbol_name,"0");
+                return CPP_INTCONSTANT;
+            }
+            break;
+        case '-':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '-') {
+                return CPP_DEC_OP;
+            } else if (ch == '=') {
+                return CPP_SUB_ASSIGN;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '-';
+            }
+        case '+':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '+') {
+                return CPP_INC_OP;
+            } else if (ch == '=') {
+                return CPP_ADD_ASSIGN;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '+';
+            }
+        case '*':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '=') {
+                return CPP_MUL_ASSIGN;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '*';
+            }
+        case '%':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '=') {
+                return CPP_MOD_ASSIGN;
+            } else if (ch == '>'){
+                return CPP_RIGHT_BRACE;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '%';
+            }
+        case ':':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '>') {
+                return CPP_RIGHT_BRACKET;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return ':';
+            }
+        case '^':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '^') {
+                return CPP_XOR_OP;
+            } else {
+                if (ch == '=')
+                    return CPP_XOR_ASSIGN;
+                else{
+                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                  return '^';
+                }
+            }
+        
+        case '=':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '=') {
+                return CPP_EQ_OP;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '=';
+            }
+        case '!':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '=') {
+                return CPP_NE_OP;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '!';
+            }
+        case '|':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '|') {
+                return CPP_OR_OP;
+            } else {
+                if (ch == '=')
+                    return CPP_OR_ASSIGN;
+                else{
+                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                  return '|';
+                }
+            }
+        case '&':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '&') {
+                return CPP_AND_OP;
+            } else {
+                if (ch == '=')
+                    return CPP_AND_ASSIGN;
+                else{
+                  cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                  return '&';
+                }
+            }
+        case '<':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '<') {
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                if(ch == '=')
+                    return CPP_LEFT_ASSIGN;
+                else{
+                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                    return CPP_LEFT_OP;
+                }
+            } else {
+                if (ch == '=') {
+                    return CPP_LE_OP;
+                } else {
+                    if (ch == '%')
+                        return CPP_LEFT_BRACE;
+                    else if (ch == ':')
+                        return CPP_LEFT_BRACKET;
+                    else{
+                        cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                        return '<';
+                    }
+                }
+            }
+        case '>':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '>') {
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                if(ch == '=')
+                    return CPP_RIGHT_ASSIGN;
+                else{
+                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                    return CPP_RIGHT_OP;
+                }
+            } else {
+                if (ch == '=') {
+                    return CPP_GE_OP;
+                } else {
+                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                    return '>';
+                }
+            }
+        case '.':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch >= '0' && ch <= '9') {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);
+            } else {
+                if (ch == '.') {
+                    return -1; /* Special EOF hack */
+                } else {
+                    cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                    return '.';
+                }
+            }
+        case '/':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            if (ch == '/') {
+                do {
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                } while (ch != '\n' && ch != EOF);
+                if (ch == EOF)
+                    return -1;
+                return '\n';
+            } else if (ch == '*') {
+                int nlcount = 0;
+                ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                do {
+                    while (ch != '*') {
+                        if (ch == '\n') nlcount++;
+                        if (ch == EOF) {
+                            CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+                            return -1;
+                        }
+                        ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                    }
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                    if (ch == EOF) {
+                        CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+                        return -1;
+                    }
+                } while (ch != '/');
+                if (nlcount) {
+                    return '\n';
+                }
+                /* Go try it again... */
+            } else if (ch == '=') {
+                return CPP_DIV_ASSIGN;
+            } else {
+                cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+                return '/';
+            }
+            break;
+        case '"':
+            ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+            while (ch != '"' && ch != '\n' && ch != EOF) {
+                if (ch == '\\') {
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                    if (ch == '\n' || ch == EOF) {
+                        break;
+                    }
+                }
+                if (len < MAX_STRING_LEN) {
+                    string_val[len] = ch;
+                    len++;
+                    ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+                }
+            };
+            string_val[len] = '\0';
+            if (ch == '"') {
+                yylvalpp->sc_ident = LookUpAddString(atable, string_val);
+                return CPP_STRCONSTANT;
+            } else {
+                CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");
+                return ERROR_SY;
+            }
+        }
+    }
+} /* byte_scan */
+
+int yylex_CPP(char* buf, int maxSize)
+{    
+       yystypepp yylvalpp;
+    int token = '\n';
+
+    for(;;) {
+               
+        char* tokenString = 0;
+        token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);
+               if(check_EOF(token))
+                  return 0;
+               if (token == '#' && (cpp->previous_token == '\n'||cpp->previous_token==0)) {
+                       token = readCPPline(&yylvalpp);
+            if(check_EOF(token))
+                return 0;
+                       continue;
+               }
+        cpp->previous_token = token;
+        /* expand macros */
+        if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
+            cpp->notAVersionToken = 1;
+            continue;
+        }
+        
+        if (token == '\n')
+            continue;
+  
+        if (token == CPP_IDENTIFIER) {
+            cpp->notAVersionToken = 1;
+            tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
+        } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){ 
+            cpp->notAVersionToken = 1;
+            tokenString = yylvalpp.symbol_name;
+               } else {
+            cpp->notAVersionToken = 1;
+            tokenString = GetStringOfAtom(atable,token);
+           }
+                
+        if (tokenString) {
+            if ((signed)strlen(tokenString) >= maxSize) {
+                return maxSize;
+            } else  if (strlen(tokenString) > 0) {
+                           strcpy(buf, tokenString);
+                return (int)strlen(tokenString);
+            }
+
+            return 0;
+        }
+    }
+
+    return 0;
+} /* yylex */
+
+/* Checks if the token just read is EOF or not. */
+int check_EOF(int token)
+{
+   if(token==-1){
+       if(cpp->ifdepth >0){
+               CPPErrorToInfoLog("#endif missing!! Compilation stopped");
+        cpp->CompileError=1;
+       }
+      return 1;
+   }
+   return 0;
+}
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////// End of scanner.c //////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
index 225d20a..8699e48 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// scanner.h\r
-//\r
-\r
-#if !defined(__SCANNER_H)\r
-#define __SCANNER_H 1\r
-\r
-#define MAX_SYMBOL_NAME_LEN 128\r
-#define MAX_STRING_LEN 512\r
-\r
-#include "parser.h"\r
-\r
-// Not really atom table stuff but needed first...\r
-\r
-typedef struct SourceLoc_Rec {\r
-    unsigned short file, line;\r
-} SourceLoc;\r
-\r
-int yyparse (void);\r
-\r
-int yylex_CPP(char* buf, int maxSize);\r
-\r
-typedef struct InputSrc {\r
-    struct InputSrc    *prev;\r
-    int                        (*scan)(struct InputSrc *, yystypepp *);\r
-    int                        (*getch)(struct InputSrc *, yystypepp *);\r
-    void               (*ungetch)(struct InputSrc *, int, yystypepp *);\r
-    int                        name;  /* atom */\r
-    int                        line;\r
-} InputSrc;\r
-\r
-int InitScanner(CPPStruct *cpp);   // Intialise the cpp scanner. \r
-int ScanFromString(char *);      // Start scanning the input from the string mentioned.\r
-int check_EOF(int);              // check if we hit a EOF abruptly \r
-void CPPErrorToInfoLog(char *);   // sticking the msg,line into the Shader's.Info.log\r
-void SetLineNumber(int);\r
-void SetStringNumber(int);\r
-void IncLineNumber(void);\r
-void DecLineNumber(void);\r
-int FreeScanner(void);                 // Free the cpp scanner\r
-#endif // !(defined(__SCANNER_H)\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// scanner.h
+*/
+
+#if !defined(__SCANNER_H)
+#define __SCANNER_H 1
+
+#define MAX_SYMBOL_NAME_LEN 128
+#define MAX_STRING_LEN 512
+
+#include "parser.h"
+
+/* Not really atom table stuff but needed first... */
+
+typedef struct SourceLoc_Rec {
+    unsigned short file, line;
+} SourceLoc;
+
+int yyparse (void);
+
+int yylex_CPP(char* buf, int maxSize);
+
+typedef struct InputSrc {
+    struct InputSrc    *prev;
+    int                        (*scan)(struct InputSrc *, yystypepp *);
+    int                        (*getch)(struct InputSrc *, yystypepp *);
+    void               (*ungetch)(struct InputSrc *, int, yystypepp *);
+    int                        name;  /* atom */
+    int                        line;
+} InputSrc;
+
+int InitScanner(CPPStruct *cpp);   /* Intialise the cpp scanner. */
+int ScanFromString(char *);      /* Start scanning the input from the string mentioned. */
+int check_EOF(int);              /* check if we hit a EOF abruptly */
+void CPPErrorToInfoLog(char *);   /* sticking the msg,line into the Shader's.Info.log */
+void SetLineNumber(int);
+void SetStringNumber(int);
+void IncLineNumber(void);
+void DecLineNumber(void);
+int FreeScanner(void);                 /* Free the cpp scanner */
+#endif /* !(defined(__SCANNER_H) */
+
index c86354f..62f5964 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// slglobals.h\r
-//\r
-\r
-#if !defined(__SLGLOBALS_H)\r
-#define __SLGLOBALS_H 1\r
-\r
-typedef struct CPPStruct_Rec CPPStruct;\r
-\r
-extern CPPStruct *cpp;\r
-\r
-#undef  CPPC_DEBUG_THE_COMPILER\r
-#if defined(_DEBUG)\r
-#define CPPC_DEBUG_THE_COMPILER 1\r
-#endif\r
-\r
-#undef  CPPC_ENABLE_TOOLS\r
-#define CPPC_ENABLE_TOOLS 1\r
-\r
-#include "memory.h"\r
-#include "atom.h"\r
-#include "scanner.h"\r
-#include "cpp.h"\r
-#include "tokens.h"\r
-#include "symbols.h"\r
-#include "compile.h"\r
-#if !defined(NO_PARSER)\r
-#include "parser.h"\r
-#endif\r
-\r
-#if !defined(NULL)\r
-#define NULL 0\r
-#endif\r
-\r
-#endif // !(defined(__SLGLOBALS_H)\r
-\r
-\r
-    \r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// slglobals.h
+*/
+
+#if !defined(__SLGLOBALS_H)
+#define __SLGLOBALS_H 1
+
+typedef struct CPPStruct_Rec CPPStruct;
+
+extern CPPStruct *cpp;
+
+#undef  CPPC_DEBUG_THE_COMPILER
+#if defined(_DEBUG)
+#define CPPC_DEBUG_THE_COMPILER 1
+#endif
+
+#undef  CPPC_ENABLE_TOOLS
+#define CPPC_ENABLE_TOOLS 1
+
+#include "memory.h"
+#include "atom.h"
+#include "scanner.h"
+#include "cpp.h"
+#include "tokens.h"
+#include "symbols.h"
+#include "compile.h"
+#if !defined(NO_PARSER)
+#include "parser.h"
+#endif
+
+#if !defined(NULL)
+#define NULL 0
+#endif
+
+#endif /* !(defined(__SLGLOBALS_H) */
+
+
+    
+
index f7ef690..051d9aa 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// symbols.c\r
-//\r
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-\r
-#include "slglobals.h"\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-Scope *ScopeList = NULL;\r
-Scope *CurrentScope = NULL;\r
-Scope *GlobalScope = NULL;\r
-\r
-static void unlinkScope(void *_scope) {\r
-    Scope *scope = _scope;\r
-\r
-    if (scope->next)\r
-        scope->next->prev = scope->prev;\r
-    if (scope->prev)\r
-        scope->prev->next = scope->next;\r
-    else\r
-        ScopeList = scope->next;\r
-}\r
-\r
-/*\r
- * NewScope()\r
- *\r
- */\r
-Scope *NewScopeInPool(MemoryPool *pool)\r
-{\r
-    Scope *lScope;\r
-\r
-    lScope = mem_Alloc(pool, sizeof(Scope));\r
-    lScope->pool = pool;\r
-    lScope->parent = NULL;\r
-    lScope->funScope = NULL;\r
-    lScope->symbols = NULL;\r
-    \r
-    lScope->level = 0;\r
-\r
-    lScope->programs = NULL;\r
-    if ((lScope->next = ScopeList))\r
-        ScopeList->prev = lScope;\r
-    lScope->prev = 0;\r
-    ScopeList = lScope;\r
-    mem_AddCleanup(pool, unlinkScope, lScope);\r
-    return lScope;\r
-} // NewScope\r
-\r
-/*\r
- * PushScope()\r
- *\r
- */\r
-\r
-void PushScope(Scope *fScope)\r
-{\r
-    Scope *lScope;\r
-\r
-    if (CurrentScope) {\r
-        fScope->level = CurrentScope->level + 1;\r
-        if (fScope->level == 1) {\r
-            if (!GlobalScope) {\r
-                /* HACK - CTD -- if GlobalScope==NULL and level==1, we're\r
-                 * defining a function in the superglobal scope.  Things\r
-                 * will break if we leave the level as 1, so we arbitrarily\r
-                 * set it to 2 */\r
-                fScope->level = 2;\r
-            }\r
-        }\r
-        if (fScope->level >= 2) {\r
-            lScope = fScope;\r
-            while (lScope->level > 2)\r
-                lScope = lScope->next;\r
-            fScope->funScope = lScope;\r
-        }\r
-    } else {\r
-        fScope->level = 0;\r
-    }\r
-    fScope->parent = CurrentScope;\r
-    CurrentScope = fScope;\r
-} // PushScope\r
-\r
-/*\r
- * PopScope()\r
- *\r
- */\r
-\r
-Scope *PopScope(void)\r
-{\r
-    Scope *lScope;\r
-\r
-    lScope = CurrentScope;\r
-    if (CurrentScope)\r
-        CurrentScope = CurrentScope->parent;\r
-    return lScope;\r
-} // PopScope\r
-\r
-/*\r
- * NewSymbol() - Allocate a new symbol node;\r
- *\r
- */\r
-\r
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)\r
-{\r
-    Symbol *lSymb;\r
-    char *pch;\r
-    int ii;\r
-\r
-    lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));\r
-    lSymb->left = NULL;\r
-    lSymb->right = NULL;\r
-    lSymb->next = NULL;\r
-    lSymb->name = name;\r
-    lSymb->loc = *loc;\r
-    lSymb->kind = kind;\r
-    \r
-    // Clear union area:\r
-\r
-    pch = (char *) &lSymb->details;\r
-    for (ii = 0; ii < sizeof(lSymb->details); ii++)\r
-        *pch++ = 0;\r
-    return lSymb;\r
-} // NewSymbol\r
-\r
-/*\r
- * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they\r
- *         are generated in order.  We'll fix this later (by reversing the bit pattern).\r
- */\r
-\r
-static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)\r
-{\r
-    Symbol *lSymb;\r
-    int lrev, frev;\r
-\r
-    lSymb = *fSymbols;\r
-    if (lSymb) {\r
-        frev = GetReversedAtom(atable, fSymb->name);\r
-        while (lSymb) {\r
-            lrev = GetReversedAtom(atable, lSymb->name);\r
-            if (lrev == frev) {\r
-                CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");\r
-                break;\r
-            } else {\r
-                if (lrev > frev) {\r
-                    if (lSymb->left) {\r
-                        lSymb = lSymb->left;\r
-                    } else {\r
-                        lSymb->left = fSymb;\r
-                        break;\r
-                    }\r
-                } else {\r
-                    if (lSymb->right) {\r
-                        lSymb = lSymb->right;\r
-                    } else {\r
-                        lSymb->right = fSymb;\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    } else {\r
-        *fSymbols = fSymb;\r
-    }\r
-} // lAddToTree\r
-\r
-\r
-/*\r
- * AddSymbol() - Add a variable, type, or function name to a scope.\r
- *\r
- */\r
-\r
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)\r
-{\r
-    Symbol *lSymb;\r
-\r
-    if (!fScope)\r
-        fScope = CurrentScope;\r
-    lSymb = NewSymbol(loc, fScope, atom, kind);\r
-    lAddToTree(&fScope->symbols, lSymb);\r
-    return lSymb;\r
-} // AddSymbol\r
-\r
-\r
-/*********************************************************************************************/\r
-/************************************ Symbol Semantic Functions ******************************/\r
-/*********************************************************************************************/\r
-\r
-/*\r
- * LookUpLocalSymbol()\r
- *\r
- */\r
-\r
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom)\r
-{\r
-    Symbol *lSymb;\r
-    int rname, ratom;\r
-\r
-    ratom = GetReversedAtom(atable, atom);\r
-    if (!fScope)\r
-        fScope = CurrentScope;\r
-    lSymb = fScope->symbols;\r
-    while (lSymb) {\r
-        rname = GetReversedAtom(atable, lSymb->name);\r
-        if (rname == ratom) {\r
-            return lSymb;\r
-        } else {\r
-            if (rname > ratom) {\r
-                lSymb = lSymb->left;\r
-            } else {\r
-                lSymb = lSymb->right;\r
-            }\r
-        }\r
-    }\r
-    return NULL;\r
-} // LookUpLocalSymbol\r
-\r
-/*\r
- * LookUpSymbol()\r
- *\r
- */\r
-\r
-Symbol *LookUpSymbol(Scope *fScope, int atom)\r
-{\r
-    Symbol *lSymb;\r
-\r
-    if (!fScope)\r
-        fScope = CurrentScope;\r
-    while (fScope) {\r
-        lSymb = LookUpLocalSymbol(fScope, atom);\r
-        if (lSymb)\r
-            return lSymb;\r
-        fScope = fScope->parent;\r
-    }\r
-    return NULL;\r
-} // LookUpSymbol\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// symbols.c
+*/
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "slglobals.h"
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+Scope *ScopeList = NULL;
+Scope *CurrentScope = NULL;
+Scope *GlobalScope = NULL;
+
+static void unlinkScope(void *_scope) {
+    Scope *scope = _scope;
+
+    if (scope->next)
+        scope->next->prev = scope->prev;
+    if (scope->prev)
+        scope->prev->next = scope->next;
+    else
+        ScopeList = scope->next;
+}
+
+/*
+ * NewScope()
+ *
+ */
+Scope *NewScopeInPool(MemoryPool *pool)
+{
+    Scope *lScope;
+
+    lScope = mem_Alloc(pool, sizeof(Scope));
+    lScope->pool = pool;
+    lScope->parent = NULL;
+    lScope->funScope = NULL;
+    lScope->symbols = NULL;
+    
+    lScope->level = 0;
+
+    lScope->programs = NULL;
+    if ((lScope->next = ScopeList))
+        ScopeList->prev = lScope;
+    lScope->prev = 0;
+    ScopeList = lScope;
+    mem_AddCleanup(pool, unlinkScope, lScope);
+    return lScope;
+} /* NewScope */
+
+/*
+ * PushScope()
+ *
+ */
+
+void PushScope(Scope *fScope)
+{
+    Scope *lScope;
+
+    if (CurrentScope) {
+        fScope->level = CurrentScope->level + 1;
+        if (fScope->level == 1) {
+            if (!GlobalScope) {
+                /* HACK - CTD -- if GlobalScope==NULL and level==1, we're
+                 * defining a function in the superglobal scope.  Things
+                 * will break if we leave the level as 1, so we arbitrarily
+                 * set it to 2 */
+                fScope->level = 2;
+            }
+        }
+        if (fScope->level >= 2) {
+            lScope = fScope;
+            while (lScope->level > 2)
+                lScope = lScope->next;
+            fScope->funScope = lScope;
+        }
+    } else {
+        fScope->level = 0;
+    }
+    fScope->parent = CurrentScope;
+    CurrentScope = fScope;
+} /* PushScope */
+
+/*
+ * PopScope()
+ *
+ */
+
+Scope *PopScope(void)
+{
+    Scope *lScope;
+
+    lScope = CurrentScope;
+    if (CurrentScope)
+        CurrentScope = CurrentScope->parent;
+    return lScope;
+} /* PopScope */
+
+/*
+ * NewSymbol() - Allocate a new symbol node;
+ *
+ */
+
+Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
+{
+    Symbol *lSymb;
+    char *pch;
+    int ii;
+
+    lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
+    lSymb->left = NULL;
+    lSymb->right = NULL;
+    lSymb->next = NULL;
+    lSymb->name = name;
+    lSymb->loc = *loc;
+    lSymb->kind = kind;
+    
+    /* Clear union area: */
+
+    pch = (char *) &lSymb->details;
+    for (ii = 0; ii < sizeof(lSymb->details); ii++)
+        *pch++ = 0;
+    return lSymb;
+} /* NewSymbol */
+
+/*
+ * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
+ *         are generated in order.  We'll fix this later (by reversing the bit pattern).
+ */
+
+static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
+{
+    Symbol *lSymb;
+    int lrev, frev;
+
+    lSymb = *fSymbols;
+    if (lSymb) {
+        frev = GetReversedAtom(atable, fSymb->name);
+        while (lSymb) {
+            lrev = GetReversedAtom(atable, lSymb->name);
+            if (lrev == frev) {
+                CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
+                break;
+            } else {
+                if (lrev > frev) {
+                    if (lSymb->left) {
+                        lSymb = lSymb->left;
+                    } else {
+                        lSymb->left = fSymb;
+                        break;
+                    }
+                } else {
+                    if (lSymb->right) {
+                        lSymb = lSymb->right;
+                    } else {
+                        lSymb->right = fSymb;
+                        break;
+                    }
+                }
+            }
+        }
+    } else {
+        *fSymbols = fSymb;
+    }
+} /* lAddToTree */
+
+
+/*
+ * AddSymbol() - Add a variable, type, or function name to a scope.
+ *
+ */
+
+Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
+{
+    Symbol *lSymb;
+
+    if (!fScope)
+        fScope = CurrentScope;
+    lSymb = NewSymbol(loc, fScope, atom, kind);
+    lAddToTree(&fScope->symbols, lSymb);
+    return lSymb;
+} /* AddSymbol */
+
+
+/*********************************************************************************************/
+/************************************ Symbol Semantic Functions ******************************/
+/*********************************************************************************************/
+
+/*
+ * LookUpLocalSymbol()
+ *
+ */
+
+Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
+{
+    Symbol *lSymb;
+    int rname, ratom;
+
+    ratom = GetReversedAtom(atable, atom);
+    if (!fScope)
+        fScope = CurrentScope;
+    lSymb = fScope->symbols;
+    while (lSymb) {
+        rname = GetReversedAtom(atable, lSymb->name);
+        if (rname == ratom) {
+            return lSymb;
+        } else {
+            if (rname > ratom) {
+                lSymb = lSymb->left;
+            } else {
+                lSymb = lSymb->right;
+            }
+        }
+    }
+    return NULL;
+} /* LookUpLocalSymbol */
+
+/*
+ * LookUpSymbol()
+ *
+ */
+
+Symbol *LookUpSymbol(Scope *fScope, int atom)
+{
+    Symbol *lSymb;
+
+    if (!fScope)
+        fScope = CurrentScope;
+    while (fScope) {
+        lSymb = LookUpLocalSymbol(fScope, atom);
+        if (lSymb)
+            return lSymb;
+        fScope = fScope->parent;
+    }
+    return NULL;
+} /* LookUpSymbol */
+
index 9be86d4..1196b90 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// symbols.h\r
-//\r
-\r
-#if !defined(__SYMBOLS_H)\r
-#define __SYMBOLS_H 1\r
-\r
-#include "memory.h"\r
-\r
-typedef enum symbolkind {\r
-   MACRO_S\r
-} symbolkind;\r
-\r
-// Typedefs for things defined here in "symbols.h":\r
-\r
-typedef struct Scope_Rec Scope;\r
-typedef struct Symbol_Rec Symbol;\r
-\r
-typedef struct SymbolList_Rec {\r
-    struct SymbolList_Rec *next;\r
-    Symbol *symb;\r
-} SymbolList;\r
-\r
-struct Scope_Rec {\r
-    Scope *next, *prev;     // doubly-linked list of all scopes\r
-    Scope *parent;\r
-    Scope *funScope;        // Points to base scope of enclosing function\r
-    MemoryPool *pool;       // pool used for allocation in this scope\r
-    Symbol *symbols;\r
-    \r
-       int level;              // 0 = super globals, 1 = globals, etc.\r
-\r
-    // Only used at global scope (level 1):\r
-    SymbolList *programs;   // List of programs for this compilation.\r
-};\r
-\r
-\r
-// Symbol table is a simple binary tree.\r
-\r
-#include "cpp.h"        // to get MacroSymbol def\r
-\r
-struct Symbol_Rec {\r
-    Symbol *left, *right;\r
-    Symbol *next;\r
-    int name;       // Name atom\r
-    SourceLoc loc;\r
-    symbolkind kind;\r
-    union {\r
-        MacroSymbol mac;\r
-    } details;\r
-};\r
-\r
-extern Scope *CurrentScope;\r
-extern Scope *GlobalScope;\r
-extern Scope *ScopeList;\r
-\r
-Scope *NewScopeInPool(MemoryPool *);\r
-#define NewScope()      NewScopeInPool(CurrentScope->pool)\r
-void PushScope(Scope *fScope);\r
-Scope *PopScope(void);\r
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);\r
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);\r
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom);\r
-Symbol *LookUpSymbol(Scope *fScope, int atom);\r
-void CPPErrorToInfoLog(char *);\r
-\r
-\r
-#endif // !defined(__SYMBOLS_H)\r
-\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// symbols.h
+*/
+
+#if !defined(__SYMBOLS_H)
+#define __SYMBOLS_H 1
+
+#include "memory.h"
+
+typedef enum symbolkind {
+   MACRO_S
+} symbolkind;
+
+/* Typedefs for things defined here in "symbols.h": */
+
+typedef struct Scope_Rec Scope;
+typedef struct Symbol_Rec Symbol;
+
+typedef struct SymbolList_Rec {
+    struct SymbolList_Rec *next;
+    Symbol *symb;
+} SymbolList;
+
+struct Scope_Rec {
+    Scope *next, *prev;     /* doubly-linked list of all scopes */
+    Scope *parent;
+    Scope *funScope;        /* Points to base scope of enclosing function */
+    MemoryPool *pool;       /* pool used for allocation in this scope */
+    Symbol *symbols;
+    
+       int level;              /* 0 = super globals, 1 = globals, etc. */
+
+    /* Only used at global scope (level 1): */
+    SymbolList *programs;   /* List of programs for this compilation. */
+};
+
+
+/* Symbol table is a simple binary tree. */
+
+#include "cpp.h"        /* to get MacroSymbol def */
+
+struct Symbol_Rec {
+    Symbol *left, *right;
+    Symbol *next;
+    int name;       /* Name atom */
+    SourceLoc loc;
+    symbolkind kind;
+    union {
+        MacroSymbol mac;
+    } details;
+};
+
+extern Scope *CurrentScope;
+extern Scope *GlobalScope;
+extern Scope *ScopeList;
+
+Scope *NewScopeInPool(MemoryPool *);
+#define NewScope()      NewScopeInPool(CurrentScope->pool)
+void PushScope(Scope *fScope);
+Scope *PopScope(void);
+Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
+Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
+Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
+Symbol *LookUpSymbol(Scope *fScope, int atom);
+void CPPErrorToInfoLog(char *);
+
+
+#endif /* !defined(__SYMBOLS_H) */
+
index 4a9f2a1..aded6c2 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// tokens.c\r
-//\r
-\r
-#include <assert.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <ctype.h>\r
-\r
-#include "slglobals.h"\r
-\r
-#include "slang_mesa.h"\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-/*\r
- * idstr()\r
- * Copy a string to a malloc'ed block and convert it into something suitable\r
- * for an ID\r
- *\r
- */\r
-\r
-static char *idstr(const char *fstr)\r
-{\r
-    size_t len;\r
-    char *str, *t;\r
-    const char *f;\r
-\r
-    len = strlen(fstr);\r
-    str = (char *) malloc(len + 1);\r
-    for (f=fstr, t=str; *f; f++) {\r
-        if (_mesa_isalnum(*f)) *t++ = *f;\r
-        else if (*f == '.' || *f == '/') *t++ = '_';\r
-    }\r
-    *t = 0;\r
-    return str;\r
-} // idstr\r
-\r
-\r
-/*\r
- * lNewBlock()\r
- *\r
- */\r
-\r
-static TokenBlock *lNewBlock(TokenStream *fTok)\r
-{\r
-    TokenBlock *lBlock;\r
-\r
-    lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);\r
-    lBlock->count = 0;\r
-    lBlock->current = 0;\r
-    lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);\r
-    lBlock->max = 256;\r
-    lBlock->next = NULL;\r
-    if (fTok->head) {\r
-        fTok->current->next = lBlock;\r
-    } else {\r
-        fTok->head = lBlock;\r
-    }\r
-    fTok->current = lBlock;\r
-    return lBlock;\r
-} // lNewBlock\r
-\r
-/*\r
- * lAddByte()\r
- *\r
- */\r
-\r
-static void lAddByte(TokenStream *fTok, unsigned char fVal)\r
-{\r
-    TokenBlock *lBlock;\r
-    lBlock = fTok->current;\r
-    if (lBlock->count >= lBlock->max)\r
-        lBlock = lNewBlock(fTok);\r
-    lBlock->data[lBlock->count++] = fVal;\r
-} // lAddByte\r
-\r
-\r
-\r
-/*\r
- * lReadByte() - Get the next byte from a stream.\r
- *\r
- */\r
-\r
-static int lReadByte(TokenStream *pTok)\r
-{\r
-    TokenBlock *lBlock;\r
-    int lval = -1;\r
-\r
-    lBlock = pTok->current;\r
-    if (lBlock) {\r
-        if (lBlock->current >= lBlock->count) {\r
-            lBlock = lBlock->next;\r
-            if (lBlock)\r
-                lBlock->current = 0;\r
-            pTok->current = lBlock;\r
-        }\r
-        if (lBlock)\r
-            lval = lBlock->data[lBlock->current++];\r
-    }\r
-    return lval;\r
-} // lReadByte\r
-\r
-/////////////////////////////////////// Global Functions://////////////////////////////////////\r
-\r
-/*\r
- * NewTokenStream()\r
- *\r
- */\r
-\r
-TokenStream *NewTokenStream(const char *name)\r
-{\r
-    TokenStream *pTok;\r
-\r
-    pTok = (TokenStream *) malloc(sizeof(TokenStream));\r
-    pTok->next = NULL;\r
-    pTok->name = idstr(name);\r
-    pTok->head = NULL;\r
-    pTok->current = NULL;\r
-    lNewBlock(pTok);\r
-    return pTok;\r
-} // NewTokenStream\r
-\r
-/*\r
- * DeleteTokenStream()\r
- *\r
- */\r
-\r
-void DeleteTokenStream(TokenStream *pTok)\r
-{\r
-    TokenBlock *pBlock, *nBlock;\r
-\r
-    if (pTok) {\r
-        pBlock = pTok->head;\r
-        while (pBlock) {\r
-            nBlock = pBlock->next;\r
-            free(pBlock);\r
-            pBlock = nBlock;\r
-        }\r
-        if (pTok->name)\r
-            free(pTok->name);\r
-        free(pTok);\r
-    }\r
-} // DeleteTokenStream\r
-\r
-/*\r
- * RecordToken() - Add a token to the end of a list for later playback or printout.\r
- *\r
- */\r
-\r
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)\r
-{\r
-    const char *s;\r
-    unsigned char *str=NULL;\r
-\r
-    if (token > 256)\r
-        lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));\r
-    else\r
-        lAddByte(pTok, (unsigned char)(token & 0x7f));\r
-    switch (token) {\r
-    case CPP_IDENTIFIER:\r
-    case CPP_TYPEIDENTIFIER:\r
-    case CPP_STRCONSTANT:\r
-        s = GetAtomString(atable, yylvalpp->sc_ident);\r
-        while (*s)\r
-            lAddByte(pTok, (unsigned char) *s++);\r
-        lAddByte(pTok, 0);\r
-        break;\r
-    case CPP_FLOATCONSTANT:\r
-    case CPP_INTCONSTANT:\r
-         str=yylvalpp->symbol_name;\r
-         while (*str){\r
-            lAddByte(pTok,(unsigned char) *str);\r
-            *str++;\r
-         }\r
-         lAddByte(pTok, 0);\r
-         break;\r
-    case '(':\r
-        lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));\r
-    default:\r
-        break;\r
-    }\r
-} // RecordToken\r
-\r
-/*\r
- * RewindTokenStream() - Reset a token stream in preperation for reading.\r
- *\r
- */\r
-\r
-void RewindTokenStream(TokenStream *pTok)\r
-{\r
-    if (pTok->head) {\r
-        pTok->current = pTok->head;\r
-        pTok->current->current = 0;\r
-    }\r
-} // RewindTokenStream\r
-\r
-/*\r
- * ReadToken() - Read the next token from a stream.\r
- *\r
- */\r
-\r
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)\r
-{\r
-    char symbol_name[MAX_SYMBOL_NAME_LEN + 1];\r
-    char string_val[MAX_STRING_LEN + 1];\r
-    int ltoken, len;\r
-    char ch;\r
-\r
-    ltoken = lReadByte(pTok);\r
-    if (ltoken >= 0) {\r
-        if (ltoken > 127)\r
-            ltoken += 128;\r
-        switch (ltoken) {\r
-        case CPP_IDENTIFIER:\r
-        case CPP_TYPEIDENTIFIER:\r
-            len = 0;\r
-            ch = lReadByte(pTok);\r
-            while ((ch >= 'a' && ch <= 'z') ||\r
-                     (ch >= 'A' && ch <= 'Z') ||\r
-                     (ch >= '0' && ch <= '9') ||\r
-                     ch == '_')\r
-            {\r
-                if (len < MAX_SYMBOL_NAME_LEN) {\r
-                    symbol_name[len] = ch;\r
-                    len++;\r
-                    ch = lReadByte(pTok);\r
-                }\r
-            }\r
-            symbol_name[len] = '\0';\r
-            assert(ch == '\0');\r
-            yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);\r
-            return CPP_IDENTIFIER;\r
-            break;\r
-        case CPP_STRCONSTANT:\r
-            len = 0;\r
-            while ((ch = lReadByte(pTok)) != 0)\r
-                if (len < MAX_STRING_LEN)\r
-                    string_val[len++] = ch;\r
-            string_val[len] = 0;\r
-            yylvalpp->sc_ident = LookUpAddString(atable, string_val);\r
-            break;\r
-        case CPP_FLOATCONSTANT:\r
-            len = 0;\r
-            ch = lReadByte(pTok);\r
-            while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))\r
-            {\r
-                if (len < MAX_SYMBOL_NAME_LEN) {\r
-                    symbol_name[len] = ch;\r
-                    len++;\r
-                    ch = lReadByte(pTok);\r
-                }\r
-            }\r
-            symbol_name[len] = '\0';\r
-            assert(ch == '\0');\r
-            strcpy(yylvalpp->symbol_name,symbol_name);\r
-            yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);\r
-            break;\r
-        case CPP_INTCONSTANT:\r
-            len = 0;\r
-            ch = lReadByte(pTok);\r
-            while ((ch >= '0' && ch <= '9'))\r
-            {\r
-                if (len < MAX_SYMBOL_NAME_LEN) {\r
-                    symbol_name[len] = ch;\r
-                    len++;\r
-                    ch = lReadByte(pTok);\r
-                }\r
-            }\r
-            symbol_name[len] = '\0';\r
-            assert(ch == '\0');\r
-            strcpy(yylvalpp->symbol_name,symbol_name);\r
-            yylvalpp->sc_int=atoi(yylvalpp->symbol_name);\r
-            break;\r
-        case '(':\r
-            yylvalpp->sc_int = lReadByte(pTok);\r
-            break;\r
-        }\r
-        return ltoken;\r
-    }\r
-    return EOF_SY;\r
-} // ReadToken\r
-\r
-typedef struct TokenInputSrc {\r
-    InputSrc            base;\r
-    TokenStream         *tokens;\r
-    int                 (*final)(CPPStruct *);\r
-} TokenInputSrc;\r
-\r
-static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)\r
-{\r
-    int token = ReadToken(in->tokens, yylvalpp);\r
-    int (*final)(CPPStruct *);\r
-    cpp->tokenLoc->file = cpp->currentInput->name;\r
-    cpp->tokenLoc->line = cpp->currentInput->line;\r
-    if (token == '\n') {\r
-        in->base.line++;\r
-        return token;\r
-    }\r
-    if (token > 0) return token;\r
-    cpp->currentInput = in->base.prev;\r
-    final = in->final;\r
-    free(in);\r
-    if (final && !final(cpp)) return -1;\r
-    return cpp->currentInput->scan(cpp->currentInput, yylvalpp);\r
-}\r
-\r
-int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))\r
-{\r
-    TokenInputSrc *in = malloc(sizeof(TokenInputSrc));\r
-    memset(in, 0, sizeof(TokenInputSrc));\r
-    in->base.name = name;\r
-    in->base.prev = cpp->currentInput;\r
-    in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;\r
-    in->base.line = 1;\r
-    in->tokens = ts;\r
-    in->final = final;\r
-    RewindTokenStream(ts);\r
-    cpp->currentInput = &in->base;\r
-    return 1;\r
-}\r
-\r
-typedef struct UngotToken {\r
-    InputSrc    base;\r
-    int         token;\r
-    yystypepp     lval;\r
-} UngotToken;\r
-\r
-static int reget_token(UngotToken *t, yystypepp * yylvalpp)\r
-{\r
-    int token = t->token;\r
-    *yylvalpp = t->lval;\r
-    cpp->currentInput = t->base.prev;\r
-    free(t);\r
-    return token;\r
-}\r
-\r
-void UngetToken(int token, yystypepp * yylvalpp) {\r
-    UngotToken *t = malloc(sizeof(UngotToken));\r
-    memset(t, 0, sizeof(UngotToken));\r
-    t->token = token;\r
-    t->lval = *yylvalpp;\r
-    t->base.scan = (void *)reget_token;\r
-    t->base.prev = cpp->currentInput;\r
-    t->base.name = cpp->currentInput->name;\r
-    t->base.line = cpp->currentInput->line;\r
-    cpp->currentInput = &t->base;\r
-}\r
-\r
-\r
-void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {\r
-    int token;\r
-    char str[100];\r
-\r
-    if (fp == 0) fp = stdout;\r
-    RewindTokenStream(s);\r
-    while ((token = ReadToken(s, yylvalpp)) > 0) {\r
-        switch (token) {\r
-        case CPP_IDENTIFIER:\r
-        case CPP_TYPEIDENTIFIER:\r
-            sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));\r
-            break;\r
-        case CPP_STRCONSTANT:\r
-            sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));\r
-            break;\r
-        case CPP_FLOATCONSTANT:\r
-            //printf("%g9.6 ", yylvalpp->sc_fval);\r
-            break;\r
-        case CPP_INTCONSTANT:\r
-            //printf("%d ", yylvalpp->sc_int);\r
-            break;\r
-        default:\r
-            if (token >= 127)\r
-                sprintf(str, "%s ", GetAtomString(atable, token));\r
-            else\r
-                sprintf(str, "%c", token);\r
-            break;\r
-        }\r
-        CPPDebugLogMsg(str);\r
-    }\r
-}\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
-/////////////////////////////////////// End of tokens.c ///////////////////////////////////////\r
-///////////////////////////////////////////////////////////////////////////////////////////////\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// tokens.c
+*/
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "slglobals.h"
+
+#include "slang_mesa.h"
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
+
+/*
+ * idstr()
+ * Copy a string to a malloc'ed block and convert it into something suitable
+ * for an ID
+ *
+ */
+
+static char *idstr(const char *fstr)
+{
+    size_t len;
+    char *str, *t;
+    const char *f;
+
+    len = strlen(fstr);
+    str = (char *) malloc(len + 1);
+    for (f=fstr, t=str; *f; f++) {
+        if (_mesa_isalnum(*f)) *t++ = *f;
+        else if (*f == '.' || *f == '/') *t++ = '_';
+    }
+    *t = 0;
+    return str;
+} /* idstr */
+
+
+/*
+ * lNewBlock()
+ *
+ */
+
+static TokenBlock *lNewBlock(TokenStream *fTok)
+{
+    TokenBlock *lBlock;
+
+    lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
+    lBlock->count = 0;
+    lBlock->current = 0;
+    lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
+    lBlock->max = 256;
+    lBlock->next = NULL;
+    if (fTok->head) {
+        fTok->current->next = lBlock;
+    } else {
+        fTok->head = lBlock;
+    }
+    fTok->current = lBlock;
+    return lBlock;
+} /* lNewBlock */
+
+/*
+ * lAddByte()
+ *
+ */
+
+static void lAddByte(TokenStream *fTok, unsigned char fVal)
+{
+    TokenBlock *lBlock;
+    lBlock = fTok->current;
+    if (lBlock->count >= lBlock->max)
+        lBlock = lNewBlock(fTok);
+    lBlock->data[lBlock->count++] = fVal;
+} /* lAddByte */
+
+
+
+/*
+ * lReadByte() - Get the next byte from a stream.
+ *
+ */
+
+static int lReadByte(TokenStream *pTok)
+{
+    TokenBlock *lBlock;
+    int lval = -1;
+
+    lBlock = pTok->current;
+    if (lBlock) {
+        if (lBlock->current >= lBlock->count) {
+            lBlock = lBlock->next;
+            if (lBlock)
+                lBlock->current = 0;
+            pTok->current = lBlock;
+        }
+        if (lBlock)
+            lval = lBlock->data[lBlock->current++];
+    }
+    return lval;
+} /* lReadByte */
+
+/*///////////////////////////////////// Global Functions:////////////////////////////////////*/
+
+/*
+ * NewTokenStream()
+ *
+ */
+
+TokenStream *NewTokenStream(const char *name)
+{
+    TokenStream *pTok;
+
+    pTok = (TokenStream *) malloc(sizeof(TokenStream));
+    pTok->next = NULL;
+    pTok->name = idstr(name);
+    pTok->head = NULL;
+    pTok->current = NULL;
+    lNewBlock(pTok);
+    return pTok;
+} /* NewTokenStream */
+
+/*
+ * DeleteTokenStream()
+ *
+ */
+
+void DeleteTokenStream(TokenStream *pTok)
+{
+    TokenBlock *pBlock, *nBlock;
+
+    if (pTok) {
+        pBlock = pTok->head;
+        while (pBlock) {
+            nBlock = pBlock->next;
+            free(pBlock);
+            pBlock = nBlock;
+        }
+        if (pTok->name)
+            free(pTok->name);
+        free(pTok);
+    }
+} /* DeleteTokenStream */
+
+/*
+ * RecordToken() - Add a token to the end of a list for later playback or printout.
+ *
+ */
+
+void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
+{
+    const char *s;
+    unsigned char *str=NULL;
+
+    if (token > 256)
+        lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
+    else
+        lAddByte(pTok, (unsigned char)(token & 0x7f));
+    switch (token) {
+    case CPP_IDENTIFIER:
+    case CPP_TYPEIDENTIFIER:
+    case CPP_STRCONSTANT:
+        s = GetAtomString(atable, yylvalpp->sc_ident);
+        while (*s)
+            lAddByte(pTok, (unsigned char) *s++);
+        lAddByte(pTok, 0);
+        break;
+    case CPP_FLOATCONSTANT:
+    case CPP_INTCONSTANT:
+         str=yylvalpp->symbol_name;
+         while (*str){
+            lAddByte(pTok,(unsigned char) *str);
+            *str++;
+         }
+         lAddByte(pTok, 0);
+         break;
+    case '(':
+        lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
+    default:
+        break;
+    }
+} /* RecordToken */
+
+/*
+ * RewindTokenStream() - Reset a token stream in preperation for reading.
+ *
+ */
+
+void RewindTokenStream(TokenStream *pTok)
+{
+    if (pTok->head) {
+        pTok->current = pTok->head;
+        pTok->current->current = 0;
+    }
+} /* RewindTokenStream */
+
+/*
+ * ReadToken() - Read the next token from a stream.
+ *
+ */
+
+int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
+{
+    char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
+    char string_val[MAX_STRING_LEN + 1];
+    int ltoken, len;
+    char ch;
+
+    ltoken = lReadByte(pTok);
+    if (ltoken >= 0) {
+        if (ltoken > 127)
+            ltoken += 128;
+        switch (ltoken) {
+        case CPP_IDENTIFIER:
+        case CPP_TYPEIDENTIFIER:
+            len = 0;
+            ch = lReadByte(pTok);
+            while ((ch >= 'a' && ch <= 'z') ||
+                     (ch >= 'A' && ch <= 'Z') ||
+                     (ch >= '0' && ch <= '9') ||
+                     ch == '_')
+            {
+                if (len < MAX_SYMBOL_NAME_LEN) {
+                    symbol_name[len] = ch;
+                    len++;
+                    ch = lReadByte(pTok);
+                }
+            }
+            symbol_name[len] = '\0';
+            assert(ch == '\0');
+            yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
+            return CPP_IDENTIFIER;
+            break;
+        case CPP_STRCONSTANT:
+            len = 0;
+            while ((ch = lReadByte(pTok)) != 0)
+                if (len < MAX_STRING_LEN)
+                    string_val[len++] = ch;
+            string_val[len] = 0;
+            yylvalpp->sc_ident = LookUpAddString(atable, string_val);
+            break;
+        case CPP_FLOATCONSTANT:
+            len = 0;
+            ch = lReadByte(pTok);
+            while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
+            {
+                if (len < MAX_SYMBOL_NAME_LEN) {
+                    symbol_name[len] = ch;
+                    len++;
+                    ch = lReadByte(pTok);
+                }
+            }
+            symbol_name[len] = '\0';
+            assert(ch == '\0');
+            strcpy(yylvalpp->symbol_name,symbol_name);
+            yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
+            break;
+        case CPP_INTCONSTANT:
+            len = 0;
+            ch = lReadByte(pTok);
+            while ((ch >= '0' && ch <= '9'))
+            {
+                if (len < MAX_SYMBOL_NAME_LEN) {
+                    symbol_name[len] = ch;
+                    len++;
+                    ch = lReadByte(pTok);
+                }
+            }
+            symbol_name[len] = '\0';
+            assert(ch == '\0');
+            strcpy(yylvalpp->symbol_name,symbol_name);
+            yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+            break;
+        case '(':
+            yylvalpp->sc_int = lReadByte(pTok);
+            break;
+        }
+        return ltoken;
+    }
+    return EOF_SY;
+} /* ReadToken */
+
+typedef struct TokenInputSrc {
+    InputSrc            base;
+    TokenStream         *tokens;
+    int                 (*final)(CPPStruct *);
+} TokenInputSrc;
+
+static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
+{
+    int token = ReadToken(in->tokens, yylvalpp);
+    int (*final)(CPPStruct *);
+    cpp->tokenLoc->file = cpp->currentInput->name;
+    cpp->tokenLoc->line = cpp->currentInput->line;
+    if (token == '\n') {
+        in->base.line++;
+        return token;
+    }
+    if (token > 0) return token;
+    cpp->currentInput = in->base.prev;
+    final = in->final;
+    free(in);
+    if (final && !final(cpp)) return -1;
+    return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+}
+
+int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
+{
+    TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
+    memset(in, 0, sizeof(TokenInputSrc));
+    in->base.name = name;
+    in->base.prev = cpp->currentInput;
+    in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
+    in->base.line = 1;
+    in->tokens = ts;
+    in->final = final;
+    RewindTokenStream(ts);
+    cpp->currentInput = &in->base;
+    return 1;
+}
+
+typedef struct UngotToken {
+    InputSrc    base;
+    int         token;
+    yystypepp     lval;
+} UngotToken;
+
+static int reget_token(UngotToken *t, yystypepp * yylvalpp)
+{
+    int token = t->token;
+    *yylvalpp = t->lval;
+    cpp->currentInput = t->base.prev;
+    free(t);
+    return token;
+}
+
+void UngetToken(int token, yystypepp * yylvalpp) {
+    UngotToken *t = malloc(sizeof(UngotToken));
+    memset(t, 0, sizeof(UngotToken));
+    t->token = token;
+    t->lval = *yylvalpp;
+    t->base.scan = (void *)reget_token;
+    t->base.prev = cpp->currentInput;
+    t->base.name = cpp->currentInput->name;
+    t->base.line = cpp->currentInput->line;
+    cpp->currentInput = &t->base;
+}
+
+
+void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
+    int token;
+    char str[100];
+
+    if (fp == 0) fp = stdout;
+    RewindTokenStream(s);
+    while ((token = ReadToken(s, yylvalpp)) > 0) {
+        switch (token) {
+        case CPP_IDENTIFIER:
+        case CPP_TYPEIDENTIFIER:
+            sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
+            break;
+        case CPP_STRCONSTANT:
+            sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
+            break;
+        case CPP_FLOATCONSTANT:
+            /*printf("%g9.6 ", yylvalpp->sc_fval);*/
+            break;
+        case CPP_INTCONSTANT:
+            /*printf("%d ", yylvalpp->sc_int);*/
+            break;
+        default:
+            if (token >= 127)
+                sprintf(str, "%s ", GetAtomString(atable, token));
+            else
+                sprintf(str, "%c", token);
+            break;
+        }
+        CPPDebugLogMsg(str);
+    }
+}
+
+/*/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////*/
index 54b12fb..09d19f2 100755 (executable)
-//\r
-//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.\r
-//All rights reserved.\r
-//\r
-//Redistribution and use in source and binary forms, with or without\r
-//modification, are permitted provided that the following conditions\r
-//are met:\r
-//\r
-//    Redistributions of source code must retain the above copyright\r
-//    notice, this list of conditions and the following disclaimer.\r
-//\r
-//    Redistributions in binary form must reproduce the above\r
-//    copyright notice, this list of conditions and the following\r
-//    disclaimer in the documentation and/or other materials provided\r
-//    with the distribution.\r
-//\r
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its\r
-//    contributors may be used to endorse or promote products derived\r
-//    from this software without specific prior written permission.\r
-//\r
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-//POSSIBILITY OF SUCH DAMAGE.\r
-//\r
-/****************************************************************************\\r
-Copyright (c) 2002, NVIDIA Corporation.\r
-\r
-NVIDIA Corporation("NVIDIA") supplies this software to you in\r
-consideration of your agreement to the following terms, and your use,\r
-installation, modification or redistribution of this NVIDIA software\r
-constitutes acceptance of these terms.  If you do not agree with these\r
-terms, please do not use, install, modify or redistribute this NVIDIA\r
-software.\r
-\r
-In consideration of your agreement to abide by the following terms, and\r
-subject to these terms, NVIDIA grants you a personal, non-exclusive\r
-license, under NVIDIA's copyrights in this original NVIDIA software (the\r
-"NVIDIA Software"), to use, reproduce, modify and redistribute the\r
-NVIDIA Software, with or without modifications, in source and/or binary\r
-forms; provided that if you redistribute the NVIDIA Software, you must\r
-retain the copyright notice of NVIDIA, this notice and the following\r
-text and disclaimers in all such redistributions of the NVIDIA Software.\r
-Neither the name, trademarks, service marks nor logos of NVIDIA\r
-Corporation may be used to endorse or promote products derived from the\r
-NVIDIA Software without specific prior written permission from NVIDIA.\r
-Except as expressly stated in this notice, no other rights or licenses\r
-express or implied, are granted by NVIDIA herein, including but not\r
-limited to any patent rights that may be infringed by your derivative\r
-works or by other works in which the NVIDIA Software may be\r
-incorporated. No hardware is licensed hereunder. \r
-\r
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT\r
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\r
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,\r
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR\r
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER\r
-PRODUCTS.\r
-\r
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,\r
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY\r
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE\r
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,\r
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF\r
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\****************************************************************************/\r
-//\r
-// tokens.h\r
-//\r
-\r
-#if !defined(__TOKENS_H)\r
-#define __TOKENS_H 1\r
-\r
-#include "parser.h"\r
-\r
-#define EOF_SY (-1)\r
-\r
-typedef struct TokenBlock_Rec TokenBlock;\r
-\r
-typedef struct TokenStream_Rec {\r
-    struct TokenStream_Rec *next;\r
-    char *name;\r
-    TokenBlock *head;\r
-    TokenBlock *current;\r
-} TokenStream;\r
-\r
-struct TokenBlock_Rec {\r
-    TokenBlock *next;\r
-    int current;\r
-    int count;\r
-    int max;\r
-    unsigned char *data;\r
-};\r
-\r
-extern TokenStream stdlib_cpp_stream;\r
-\r
-\r
-TokenStream *NewTokenStream(const char *name);\r
-void DeleteTokenStream(TokenStream *pTok); \r
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);\r
-void RewindTokenStream(TokenStream *pTok);\r
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);\r
-int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));\r
-void UngetToken(int, yystypepp * yylvalpp);\r
-\r
-#if defined(CPPC_ENABLE_TOOLS)\r
-\r
-void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);\r
-\r
-#endif // defined(CPPC_ENABLE_TOOLS)\r
-\r
-#endif // !defined(__TOKENS_H)\r
+/*
+//Copyright (C) 2002-2004  3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//    Redistributions of source code must retain the above copyright
+//    notice, this list of conditions and the following disclaimer.
+//
+//    Redistributions in binary form must reproduce the above
+//    copyright notice, this list of conditions and the following
+//    disclaimer in the documentation and/or other materials provided
+//    with the distribution.
+//
+//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+//    contributors may be used to endorse or promote products derived
+//    from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms.  If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder. 
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/*
+// tokens.h
+*/
+
+#if !defined(__TOKENS_H)
+#define __TOKENS_H 1
+
+#include "parser.h"
+
+#define EOF_SY (-1)
+
+typedef struct TokenBlock_Rec TokenBlock;
+
+typedef struct TokenStream_Rec {
+    struct TokenStream_Rec *next;
+    char *name;
+    TokenBlock *head;
+    TokenBlock *current;
+} TokenStream;
+
+struct TokenBlock_Rec {
+    TokenBlock *next;
+    int current;
+    int count;
+    int max;
+    unsigned char *data;
+};
+
+extern TokenStream stdlib_cpp_stream;
+
+
+TokenStream *NewTokenStream(const char *name);
+void DeleteTokenStream(TokenStream *pTok); 
+void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
+void RewindTokenStream(TokenStream *pTok);
+int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
+int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
+void UngetToken(int, yystypepp * yylvalpp);
+
+#if defined(CPPC_ENABLE_TOOLS)
+
+void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
+
+#endif /* defined(CPPC_ENABLE_TOOLS) */
+
+#endif /* !defined(__TOKENS_H) */