]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/fteqcc-src/qcc_pr_lex.c
Latest fteqcc and netradiant sources
[voretournament/voretournament.git] / misc / source / fteqcc-src / qcc_pr_lex.c
index 286da96f66e3453e3021a5befee5fdff2b31f894..9bdd11c42d543d22c0c0e5a8f3ea069da45b7107 100644 (file)
@@ -6,6 +6,24 @@
 #endif
 #include "time.h"
 
+// I put the following here to resolve "undefined reference to `__imp__vsnprintf'" with MinGW64 ~ Moodles
+#ifdef __MINGW64__
+#ifndef QCCONLY
+       #if (_MSC_VER >= 1400)
+               //with MSVC 8, use MS extensions
+               #define snprintf linuxlike_snprintf_vc8
+               int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
+               #define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
+       #else
+               //msvc crap
+               #define snprintf linuxlike_snprintf
+               int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
+               #define vsnprintf linuxlike_vsnprintf
+               int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
+       #endif
+#endif
+#endif
+
 #define MEMBERFIELDNAME "__m%s"
 
 #define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1))    //saves about 2-6 out of 120 - expansion of idea from fastqcc
@@ -159,8 +177,7 @@ extern char qccmsourcedir[];
 //also meant to include it.
 void QCC_FindBestInclude(char *newfile, char *currentfile, char *rootpath)
 {
-       char fullname[10248];
-       char *stripfrom;
+       char fullname[1024];
        int doubledots;
 
        char *end = fullname;
@@ -169,6 +186,7 @@ void QCC_FindBestInclude(char *newfile, char *currentfile, char *rootpath)
                return;
 
        doubledots = 0;
+       /*count how far up we need to go*/
        while(!strncmp(newfile, "../", 3) || !strncmp(newfile, "..\\", 3))
        {
                newfile+=3;
@@ -177,31 +195,37 @@ void QCC_FindBestInclude(char *newfile, char *currentfile, char *rootpath)
 
        currentfile += strlen(rootpath);        //could this be bad?
 
-       for(stripfrom = currentfile+strlen(currentfile)-1; stripfrom>currentfile; stripfrom--)
+       strcpy(fullname, rootpath);
+       end = fullname+strlen(end);
+       if (*fullname && end[-1] != '/')
+       {
+               strcpy(end, "/");
+               end = end+strlen(end);
+       }
+       strcpy(end, currentfile);
+       end = end+strlen(end);
+
+       while (end > fullname)
        {
-               if (*stripfrom == '/' || *stripfrom == '\\')
+               end--;
+               /*stop at the slash, unless we're meant to go further*/
+               if (*end == '/' || *end == '\\')
                {
-                       if (doubledots>0)
-                               doubledots--;
-                       else
+                       if (!doubledots)
                        {
-                               stripfrom++;
+                               end++;
                                break;
                        }
+                       doubledots--;
                }
        }
-       strcpy(end, rootpath); end = end+strlen(end);
-       if (*fullname && end[-1] != '/')
-       {
-               strcpy(end, "/");
-               end = end+strlen(end);
-       }
-       strncpy(end, currentfile, stripfrom - currentfile); end += stripfrom - currentfile; *end = '\0';
+
        strcpy(end, newfile);
 
        QCC_Include(fullname);
 }
 
+pbool defaultnoref;
 pbool defaultstatic;
 int ForcedCRC;
 int QCC_PR_LexInteger (void);
@@ -212,10 +236,10 @@ pbool QCC_PR_SimpleGetToken (void);
 int ParsePrecompilerIf(void)
 {
        CompilerConstant_t *c;
-       int eval;
-       char *start = pr_file_p;
+       int eval = 0;
+       //char *start = pr_file_p; //warning: unused variable âstartâ
        if (!QCC_PR_SimpleGetToken())
-       {       
+       {
                if (*pr_file_p == '(')
                {
                        eval = ParsePrecompilerIf();
@@ -364,7 +388,7 @@ pbool QCC_PR_Precompiler(void)
                                        eval = true;
 
                                if (ifmode == 1)
-                                       eval = eval?false:true;         
+                                       eval = eval?false:true;
                        }
 
                        while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
@@ -469,11 +493,11 @@ pbool QCC_PR_Precompiler(void)
                        }
                }
                else if (!strncmp(directive, "endif", 5))
-               {               
+               {
                        while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
                        {
                                pr_file_p++;
-                       }               
+                       }
                        if (ifs <= 0)
                                QCC_PR_ParseError(ERR_NOPRECOMPILERIF, "unmatched #endif");
                        else
@@ -485,9 +509,9 @@ pbool QCC_PR_Precompiler(void)
                        return true;
                }
                else if (!strncmp(directive, "error", 5))
-               {               
+               {
                        pr_file_p = directive+5;
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -500,7 +524,7 @@ pbool QCC_PR_Precompiler(void)
                        QCC_PR_ParseError(ERR_HASHERROR, "#Error: %s", msg);
                }
                else if (!strncmp(directive, "warning", 7))
-               {               
+               {
                        pr_file_p = directive+7;
                        for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
@@ -515,7 +539,7 @@ pbool QCC_PR_Precompiler(void)
                        QCC_PR_ParseWarning(WARN_PRECOMPILERMESSAGE, "#warning: %s", msg);
                }
                else if (!strncmp(directive, "message", 7))
-               {               
+               {
                        pr_file_p = directive+7;
                        for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
@@ -532,7 +556,7 @@ pbool QCC_PR_Precompiler(void)
                else if (!strncmp(directive, "copyright", 9))
                {
                        pr_file_p = directive+9;
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -552,14 +576,14 @@ pbool QCC_PR_Precompiler(void)
                        pr_file_p=directive+4;
                        if (!strncmp(pr_file_p, "id", 2))
                                pr_file_p+=3;
-                       else    
+                       else
                        {
-                               ifmode = QCC_PR_LexInteger();                                   
+                               ifmode = QCC_PR_LexInteger();
                                if (ifmode == 0)
                                        ifmode = 1;
                                pr_file_p++;
                        }
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -574,17 +598,17 @@ pbool QCC_PR_Precompiler(void)
                        else if (ifmode <= 5)
                                strcpy(QCC_Packname[ifmode-1], msg);
                        else
-                               QCC_PR_ParseError(ERR_TOOMANYPACKFILES, "No more than 5 packs are allowed");            
+                               QCC_PR_ParseError(ERR_TOOMANYPACKFILES, "No more than 5 packs are allowed");
                }
                else if (!strncmp(directive, "forcecrc", 8))
-               {               
+               {
                        pr_file_p=directive+8;
 
-                       ForcedCRC = QCC_PR_LexInteger();                                        
+                       ForcedCRC = QCC_PR_LexInteger();
 
                        pr_file_p++;
-                               
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -592,7 +616,7 @@ pbool QCC_PR_Precompiler(void)
                        while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
                        {
                                pr_file_p++;
-                       }       
+                       }
                }
                else if (!strncmp(directive, "includelist", 11))
                {
@@ -623,7 +647,7 @@ pbool QCC_PR_Precompiler(void)
                                if (*pr_file_p == '\r')
                                        pr_file_p++;
 
-                               for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+                               for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                        msg[a] = pr_file_p[a];
 
                                msg[a-1] = '\0';
@@ -633,7 +657,7 @@ pbool QCC_PR_Precompiler(void)
                                        pr_file_p++;
                                }
                        }
-                       
+
                        while(*pr_file_p != '\n' && *pr_file_p != '\0') //read on until the end of the line
                        {
                                pr_file_p++;
@@ -664,7 +688,7 @@ pbool QCC_PR_Precompiler(void)
                        {
                                if (*pr_file_p == '\n')
                                {
-                                       QCC_PR_ParseError(0, "#include continued over line boundy\n");
+                                       QCC_PR_ParseError(0, "#include continued over line boundry\n");
                                        break;
                                }
                                msg[a++] = *pr_file_p;
@@ -686,7 +710,7 @@ pbool QCC_PR_Precompiler(void)
                        }
                }
                else if (!strncmp(directive, "datafile", 8))
-               {               
+               {
                        pr_file_p=directive+8;
 
                        while(*pr_file_p <= ' ')
@@ -698,7 +722,7 @@ pbool QCC_PR_Precompiler(void)
 
                        pr_file_p++;
 
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -721,8 +745,8 @@ pbool QCC_PR_Precompiler(void)
                        printf("Outputfile: %s\n", destfile);
 
                        pr_file_p++;
-                               
-                       for (a = 0; a < 1023 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
+
+                       for (a = 0; a < sizeof(msg)-1 && pr_file_p[a] != '\n' && pr_file_p[a] != '\0'; a++)
                                msg[a] = pr_file_p[a];
 
                        msg[a-1] = '\0';
@@ -750,7 +774,7 @@ pbool QCC_PR_Precompiler(void)
                                }
                                msg[a++] = *pr_file_p;
                        }
-                       
+
                        msg[a] = '\0';
                        {
                                char *end;
@@ -799,6 +823,10 @@ pbool QCC_PR_Precompiler(void)
                        {
                                ForcedCRC = atoi(msg);
                        }
+                       else if (!strncmp(qcc_token, "noref", 8))
+                       {
+                               defaultnoref = atoi(msg);
+                       }
                        else if (!strncmp(qcc_token, "defaultstatic", 13))
                        {
                                defaultstatic = atoi(msg);
@@ -807,7 +835,7 @@ pbool QCC_PR_Precompiler(void)
                        {
        #define MAXSOURCEFILESLIST 8
        extern char sourcefileslist[MAXSOURCEFILESLIST][1024];
-       extern int currentsourcefile;
+       //extern int currentsourcefile; // warning: unused variable âcurrentsourcefileâ
        extern int numsourcefiles;
 
                                int i;
@@ -845,6 +873,8 @@ pbool QCC_PR_Precompiler(void)
                                        qcc_targetformat = QCF_STANDARD;
                                else if (!QC_strcasecmp(msg, "DEBUG"))
                                        qcc_targetformat = QCF_FTEDEBUG;
+                               else if (!QC_strcasecmp(msg, "QTEST"))
+                                       qcc_targetformat = QCF_QTEST;
                                else
                                        QCC_PR_ParseWarning(WARN_BADTARGET, "Unknown target \'%s\'. Ignored.", msg);
                        }
@@ -863,7 +893,7 @@ pbool QCC_PR_Precompiler(void)
 
 #ifndef QCCONLY
        p=0;
-       s2 = qcc_token; 
+       s2 = qcc_token;
        if (!strncmp(s2, "./", 2))
                s2+=2;
        else
@@ -1014,7 +1044,7 @@ void QCC_PR_LexString (void)
        int             c;
        int             len;
        char tmpbuf[2048];
-                       
+
        char *text;
        char *oldf;
        int oldline;
@@ -1083,12 +1113,12 @@ void QCC_PR_LexString (void)
                        pr_file_p = oldf-1;
                        QCC_PR_LexWhitespace();
                        if (*pr_file_p != '\"') //annother string
-                               break;                          
+                               break;
                }
 
                QCC_PR_LexWhitespace();
-               text = pr_file_p;               
-               
+               text = pr_file_p;
+
        } while (1);
 
        strcpy(pr_token, tmpbuf);
@@ -1106,7 +1136,7 @@ void QCC_PR_LexString (void)
        char    *end, *cnst;
 
        int texttype=0;
-       
+
        len = 0;
        pr_file_p++;
        do
@@ -1231,7 +1261,7 @@ void QCC_PR_LexString (void)
                        pr_token[len] = 0;
                        pr_token_type = tt_immediate;
                        pr_immediate_type = type_string;
-                       strcpy (pr_immediate_string, pr_token);                 
+                       strcpy (pr_immediate_string, pr_token);
                        return;
                }
                else if (c == '#')
@@ -1308,7 +1338,7 @@ int QCC_PR_LexInteger (void)
 {
        int             c;
        int             len;
-       
+
        len = 0;
        c = *pr_file_p;
        if (pr_file_p[0] == '0' && pr_file_p[1] == 'x')
@@ -1358,7 +1388,7 @@ void QCC_PR_LexNumber (void)
                base = 10;
 
        while((c = *pr_file_p))
-       {               
+       {
                if (c >= '0' && c <= '9')
                {
                        pr_token[tokenlen++] = c;
@@ -1395,7 +1425,7 @@ void QCC_PR_LexNumber (void)
                                        break;
                                }
                                else
-                               {                                               
+                               {
                                        break;
                                }
                                pr_file_p++;
@@ -1447,7 +1477,7 @@ float QCC_PR_LexFloat (void)
 {
        int             c;
        int             len;
-       
+
        len = 0;
        c = *pr_file_p;
        do
@@ -1471,7 +1501,7 @@ Parses a single quoted vector
 void QCC_PR_LexVector (void)
 {
        int             i;
-       
+
        pr_file_p++;
 
        if (*pr_file_p == '\\')
@@ -1549,7 +1579,7 @@ void QCC_PR_LexName (void)
 {
        int             c;
        int             len;
-       
+
        len = 0;
        c = *pr_file_p;
        do
@@ -1558,11 +1588,11 @@ void QCC_PR_LexName (void)
                len++;
                pr_file_p++;
                c = *pr_file_p;
-       } while ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' 
-       || (c >= '0' && c <= '9'));     
+       } while ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'
+       || (c >= '0' && c <= '9'));
 
        pr_token[len] = 0;
-       pr_token_type = tt_name;        
+       pr_token_type = tt_name;
 }
 
 /*
@@ -1575,9 +1605,9 @@ void QCC_PR_LexPunctuation (void)
        int             i;
        int             len;
        char    *p;
-       
+
        pr_token_type = tt_punct;
-       
+
        for (i=0 ; (p = pr_punctuation[i]) != NULL ; i++)
        {
                len = strlen(p);
@@ -1592,11 +1622,11 @@ void QCC_PR_LexPunctuation (void)
                        return;
                }
        }
-       
+
        QCC_PR_ParseError (ERR_UNKNOWNPUCTUATION, "Unknown punctuation");
 }
 
-               
+
 /*
 ==============
 PR_LexWhitespace
@@ -1605,7 +1635,7 @@ PR_LexWhitespace
 void QCC_PR_LexWhitespace (void)
 {
        int             c;
-       
+
        while (1)
        {
        // skip whitespace
@@ -1625,7 +1655,7 @@ void QCC_PR_LexWhitespace (void)
                                pr_file_p++;
                        }
                }
-               
+
        // skip // comments
                if (c=='/' && pr_file_p[1] == '/')
                {
@@ -1637,7 +1667,7 @@ void QCC_PR_LexWhitespace (void)
                        QCC_PR_NewLine(false);
                        continue;
                }
-               
+
        // skip /* */ comments
                if (c=='/' && pr_file_p[1] == '*')
                {
@@ -1658,7 +1688,7 @@ void QCC_PR_LexWhitespace (void)
                        pr_file_p+=2;
                        continue;
                }
-               
+
                break;          // a real character has been found
        }
 }
@@ -1834,7 +1864,7 @@ Deals with counting sequence numbers and replacing frame macros
 ==============
 */
 void QCC_PR_LexGrab (void)
-{      
+{
        pr_file_p++;    // skip the $
 //     if (!QCC_PR_SimpleGetToken ())
 //             QCC_PR_ParseError ("hanging $");
@@ -1843,7 +1873,7 @@ void QCC_PR_LexGrab (void)
        QCC_PR_LexMacroName();
        if (!*pr_token)
                QCC_PR_ParseError (ERR_BADFRAMEMACRO, "hanging $");
-       
+
 // check for $frame
        if (!STRCMP (pr_token, "frame") || !STRCMP (pr_token, "framesave"))
        {
@@ -1873,7 +1903,7 @@ void QCC_PR_LexGrab (void)
        {
                QCC_PR_LexMacroName ();
                pr_macrovalue = atoi(pr_token);
-               
+
                QCC_PR_Lex ();
        }
        else if (!STRCMP (pr_token, "framerestore"))
@@ -1881,7 +1911,7 @@ void QCC_PR_LexGrab (void)
                QCC_PR_LexMacroName ();
                QCC_PR_ExpandMacro();
                pr_macrovalue = (int)pr_immediate._float;
-               
+
                QCC_PR_Lex ();
        }
        else if (!STRCMP (pr_token, "modelname"))
@@ -1900,7 +1930,7 @@ void QCC_PR_LexGrab (void)
                        pr_macrovalue = i;
                else
                        i = 0;
-               
+
                QCC_PR_Lex ();
        }
 // look for a frame name macro
@@ -1924,38 +1954,6 @@ pbool QCC_PR_UndefineName(char *name)
 
        Hash_Remove(&compconstantstable, name);
        return true;
-       /*
-       a = c-CompilerConstant;
-//     for (a = 0; a < numCompilerConstants; a++)
-       {
-//             if (!STRCMP(name, CompilerConstant[a].name))
-               {
-                       memmove(&CompilerConstant[a], &CompilerConstant[a+1], sizeof(CompilerConstant_t) * (numCompilerConstants-a));
-                       numCompilerConstants--;
-
-
-
-
-                       if (!STRCMP(name, "OP_NODUP"))
-                               qccop_noduplicatestrings = false;
-
-                       if (!STRCMP(name, "OP_COMP_ALL"))               //group 
-                       {
-                               QCC_PR_UndefineName("OP_COMP_STATEMENTS");
-                               QCC_PR_UndefineName("OP_COMP_DEFS");
-                               QCC_PR_UndefineName("OP_COMP_FIELDS");
-                               QCC_PR_UndefineName("OP_COMP_FUNCTIONS");
-                               QCC_PR_UndefineName("OP_COMP_STRINGS");
-                               QCC_PR_UndefineName("OP_COMP_GLOBALS");
-                               QCC_PR_UndefineName("OP_COMP_LINES");
-                               QCC_PR_UndefineName("OP_COMP_TYPES");
-                       }
-
-                       return true;
-               }
-       }
-//     return false;
-*/
 }
 
 CompilerConstant_t *QCC_PR_DefineName(char *name)
@@ -1967,10 +1965,10 @@ CompilerConstant_t *QCC_PR_DefineName(char *name)
 //             QCC_PR_ParseError("Too many compiler constants - %i >= %i", numCompilerConstants, MAX_CONSTANTS);
 
        if (strlen(name) >= MAXCONSTANTLENGTH || !*name)
-               QCC_PR_ParseError(ERR_CONSTANTTOOLONG, "Compiler constant name length is too long or short");
-       
+               QCC_PR_ParseError(ERR_NAMETOOLONG, "Compiler constant name length is too long or short");
+
        cnst = pHash_Get(&compconstantstable, name);
-       if (cnst )
+       if (cnst)
        {
                QCC_PR_ParseWarning(WARN_DUPLICATEDEFINITION, "Duplicate definition for Precompiler constant %s", name);
                Hash_Remove(&compconstantstable, name);
@@ -1982,57 +1980,12 @@ CompilerConstant_t *QCC_PR_DefineName(char *name)
        cnst->numparams = 0;
        strcpy(cnst->name, name);
        cnst->namelen = strlen(name);
-       *cnst->value = '\0';
+       cnst->value = cnst->name + strlen(cnst->name);
        for (i = 0; i < MAXCONSTANTPARAMS; i++)
                cnst->params[i][0] = '\0';
 
        pHash_Add(&compconstantstable, cnst->name, cnst, qccHunkAlloc(sizeof(bucket_t)));
 
-       if (!STRCMP(name, "OP_NODUP"))
-               opt_noduplicatestrings = true;
-
-
-       if (!STRCMP(name, "OP_TIME"))   //group - optimize for a fast compiler
-       {
-               QCC_PR_UndefineName("OP_SIZE");
-               QCC_PR_UndefineName("OP_SPEED");
-
-               QCC_PR_UndefineName("OP_NODUP");
-               QCC_PR_UndefineName("OP_COMP_ALL");
-       }
-
-       if (!STRCMP(name, "OP_SPEED"))  //group - optimize run speed
-       {
-               QCC_PR_UndefineName("OP_SIZE");
-               QCC_PR_UndefineName("OP_TIME");
-
-//             QCC_PR_UndefineName("OP_NODUP");
-               QCC_PR_UndefineName("OP_COMP_ALL");
-       }
-
-       if (!STRCMP(name, "OP_SIZE"))   //group - produce small output.
-       {
-               QCC_PR_UndefineName("OP_SPEED");
-               QCC_PR_UndefineName("OP_TIME");
-
-               QCC_PR_DefineName("OP_NODUP");
-               QCC_PR_DefineName("OP_COMP_ALL");
-       }
-
-       if (!STRCMP(name, "OP_COMP_ALL"))       //group - compress the output
-       {
-               QCC_PR_DefineName("OP_COMP_STATEMENTS");
-               QCC_PR_DefineName("OP_COMP_DEFS");
-               QCC_PR_DefineName("OP_COMP_FIELDS");
-               QCC_PR_DefineName("OP_COMP_FUNCTIONS");
-               QCC_PR_DefineName("OP_COMP_STRINGS");
-               QCC_PR_DefineName("OP_COMP_GLOBALS");
-               QCC_PR_DefineName("OP_COMP_LINES");
-               QCC_PR_DefineName("OP_COMP_TYPES");
-       }
-
-
-
        return cnst;
 }
 
@@ -2048,13 +2001,15 @@ void QCC_PR_ConditionCompilation(void)
 {
        char *oldval;
        char *d;
+       char *dbuf;
+       int dbuflen;
        char *s;
        int quote=false;
        CompilerConstant_t *cnst;
 
        QCC_PR_SimpleGetToken ();
 
-       if (!QCC_PR_SimpleGetToken ())          
+       if (!QCC_PR_SimpleGetToken ())
                QCC_PR_ParseError(ERR_NONAME, "No name defined for compiler constant");
 
        cnst = pHash_Get(&compconstantstable, pr_token);
@@ -2098,11 +2053,21 @@ void QCC_PR_ConditionCompilation(void)
        else cnst->numparams = -1;
 
        s = pr_file_p;
-       d = cnst->value;
+       d = dbuf = NULL;
+       dbuflen = 0;
        while(*s == ' ' || *s == '\t')
                s++;
        while(1)
        {
+               if ((d - dbuf) + 2 >= dbuflen)
+               {
+                       int len = d - dbuf;
+                       dbuflen = (len+128) * 2;
+                       dbuf = qccHunkAlloc(dbuflen);
+                       memcpy(dbuf, d - len, len);
+                       d = dbuf + len;
+               }
+
                if( *s == '\\' )
                {
                        // read over a newline if necessary
@@ -2116,7 +2081,7 @@ void QCC_PR_ConditionCompilation(void)
                                        *d++ = *s++;
                                }
                        }
-               } 
+               }
                else if(*s == '\r' || *s == '\n' || *s == '\0')
                {
                        break;
@@ -2132,11 +2097,8 @@ void QCC_PR_ConditionCompilation(void)
                s++;
        }
        *d = '\0';
-       d--;
-       while(*d<= ' ' && d >= cnst->value)
-               *d-- = '\0';
-       if (strlen(cnst->value) >= sizeof(cnst->value)) //this is too late.
-               QCC_PR_ParseError(ERR_CONSTANTTOOLONG, "Macro %s too long (%i not %i)", cnst->name, strlen(cnst->value), sizeof(cnst->value));
+
+       cnst->value = dbuf;
 
        if (oldval)
        {       //we always warn if it was already defined
@@ -2389,7 +2351,7 @@ int QCC_PR_CheakCompConst(void)
                return true;
        }
        if (!strncmp(pr_file_p, "__FILE__", 8))
-       {               
+       {
                static char retbuf[256];
                sprintf(retbuf, "\"%s\"", strings + s_file);
                pr_file_p = retbuf;
@@ -2408,7 +2370,7 @@ int QCC_PR_CheakCompConst(void)
                return true;
        }
        if (!strncmp(pr_file_p, "__FUNC__", 8))
-       {               
+       {
                static char retbuf[256];
                sprintf(retbuf, "\"%s\"",pr_scope->name);
                pr_file_p = retbuf;
@@ -2431,12 +2393,12 @@ int QCC_PR_CheakCompConst(void)
 char *QCC_PR_CheakCompConstString(char *def)
 {
        char *s;
-       
+
        CompilerConstant_t *c;
 
        c = pHash_Get(&compconstantstable, def);
 
-       if (c)  
+       if (c)
        {
                s = QCC_PR_CheakCompConstString(c->value);
                return s;
@@ -2448,14 +2410,6 @@ CompilerConstant_t *QCC_PR_CheckCompConstDefined(char *def)
 {
        CompilerConstant_t *c = pHash_Get(&compconstantstable, def);
        return c;
-       /*int a;        
-       for (a = 0; a < numCompilerConstants; a++)
-       {
-               if (!strncmp(def, CompilerConstant[a].name, CompilerConstant[a].namelen+1))             
-                       return &CompilerConstant[a];                                                            
-       }
-       return NULL;
-       */
 }
 
 //============================================================================
@@ -2472,11 +2426,11 @@ void QCC_PR_Lex (void)
        int             c;
 
        pr_token[0] = 0;
-       
+
        if (!pr_file_p)
        {
                if (QCC_PR_UnInclude())
-               {       
+               {
                        QCC_PR_Lex();
                        return;
                }
@@ -2489,7 +2443,7 @@ void QCC_PR_Lex (void)
        if (!pr_file_p)
        {
                if (QCC_PR_UnInclude())
-               {       
+               {
                        QCC_PR_Lex();
                        return;
                }
@@ -2498,11 +2452,11 @@ void QCC_PR_Lex (void)
        }
 
        c = *pr_file_p;
-               
+
        if (!c)
        {
                if (QCC_PR_UnInclude())
-               {       
+               {
                        QCC_PR_Lex();
                        return;
                }
@@ -2563,7 +2517,7 @@ void QCC_PR_Lex (void)
 
                return;
        }
-       
+
        if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' )
        {
                if (flag_hashonly || !QCC_PR_CheakCompConst())  //look for a macro.
@@ -2572,7 +2526,7 @@ void QCC_PR_Lex (void)
                        if (pr_token_type == tt_eof)
                        {
                                if (QCC_PR_UnInclude())
-                               {       
+                               {
                                        QCC_PR_Lex();
                                        return;
                                }
@@ -2580,13 +2534,13 @@ void QCC_PR_Lex (void)
                        }
                return;
        }
-       
+
        if (c == '$')
        {
                QCC_PR_LexGrab ();
                return;
        }
-       
+
 // parse symbol strings until a non-symbol is found
        QCC_PR_LexPunctuation ();
 }
@@ -2654,7 +2608,7 @@ void VARGS QCC_PR_ParseError (int errortype, char *error, ...)
                printf ("%s(%i) : error: %s\n", strings + s_file, pr_source_line, string);
        else
                printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string);
-       
+
        longjmp (pr_parse_abort, 1);
 }
 void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error, ...)
@@ -2676,7 +2630,7 @@ void VARGS QCC_PR_ParseErrorPrintDef (int errortype, QCC_def_t *def, char *error
                printf ("%s:%i: error: %s\n", strings + s_file, pr_source_line, string);
 
        QCC_PR_ParsePrintDef(WARN_ERROR, def);
-       
+
        longjmp (pr_parse_abort, 1);
 }
 void VARGS QCC_PR_ParseWarning (int type, char *error, ...)
@@ -2710,6 +2664,30 @@ void VARGS QCC_PR_ParseWarning (int type, char *error, ...)
        }
 }
 
+void VARGS QCC_PR_Note (int type, char *file, int line, char *error, ...)
+{
+               va_list         argptr;
+       char            string[1024];
+
+       if (qccwarningdisabled[type])
+               return;
+
+       va_start (argptr,error);
+       QC_vsnprintf (string,sizeof(string)-1, error,argptr);
+       va_end (argptr);
+
+       QCC_PR_PrintScope();
+       if (file)
+       {
+               if (flag_msvcstyle)
+                       printf ("%s(%i) : note: %s\n", file, line, string);
+               else
+                       printf ("%s:%i: note: %s\n", file, line, string);
+       }
+       else
+               printf ("note: %s\n", string);
+}
+
 void VARGS QCC_PR_Warning (int type, char *file, int line, char *error, ...)
 {
        va_list         argptr;
@@ -2770,7 +2748,7 @@ pbool QCC_PR_CheckToken (char *string)
 
        if (STRCMP (string, pr_token))
                return false;
-       
+
        QCC_PR_Lex ();
        return true;
 }
@@ -2782,7 +2760,7 @@ pbool QCC_PR_CheckImmediate (char *string)
 
        if (STRCMP (string, pr_token))
                return false;
-       
+
        QCC_PR_Lex ();
        return true;
 }
@@ -2791,7 +2769,7 @@ pbool QCC_PR_CheckName(char *string)
 {
        if (pr_token_type != tt_name)
                return false;
-       if (flag_caseinsensative) 
+       if (flag_caseinsensative)
        {
                if (stricmp (string, pr_token))
                        return false;
@@ -2809,7 +2787,7 @@ pbool QCC_PR_CheckKeyword(int keywordenabled, char *string)
 {
        if (!keywordenabled)
                return false;
-       if (flag_caseinsensative) 
+       if (flag_caseinsensative)
        {
                if (stricmp (string, pr_token))
                        return false;
@@ -2836,14 +2814,14 @@ char *QCC_PR_ParseName (void)
 {
        static char     ident[MAX_NAME];
        char *ret;
-       
+
        if (pr_token_type != tt_name)
-               QCC_PR_ParseError (ERR_NOTANAME, "\"%s\" - not a name", pr_token);      
+               QCC_PR_ParseError (ERR_NOTANAME, "\"%s\" - not a name", pr_token);
        if (strlen(pr_token) >= MAX_NAME-1)
                QCC_PR_ParseError (ERR_NAMETOOLONG, "name too long");
        strcpy (ident, pr_token);
        QCC_PR_Lex ();
-       
+
        ret = qccHunkAlloc(strlen(ident)+1);
        strcpy(ret, ident);
        return ret;
@@ -2992,7 +2970,7 @@ QCC_type_t *QCC_PR_FindType (QCC_type_t *type)
 //             check = &qcc_typeinfo[t];
                if (typecmp(&qcc_typeinfo[t], type))
                        continue;
-               
+
 
 //             c2 = check->next;
 //             n2 = type->next;
@@ -3142,7 +3120,7 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype)
                                        strcpy (pr_parm_names[ftype->num_parms], "");
                                ftype->num_parms++;
                        } while (QCC_PR_CheckToken (","));
-       
+
                QCC_PR_Expect (")");
        }
        recursivefunctiontype--;
@@ -3219,7 +3197,7 @@ QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype)
                                        strcpy (pr_parm_names[ftype->num_parms], name);
                                ftype->num_parms++;
                        } while (QCC_PR_CheckToken (";"));
-       
+
                QCC_PR_Expect (")");
        }
        recursivefunctiontype--;
@@ -3312,7 +3290,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
                        {
                                newt = &qcc_typeinfo[i];
                                break;
-                       }       
+                       }
                }
 
                if (newt && forwarddeclaration)
@@ -3334,7 +3312,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
                        return NULL;
                }
 
-               
+
 
                if (QCC_PR_CheckToken(":"))
                {
@@ -3450,7 +3428,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
                newt = QCC_PR_NewType("union", ev_union);
                newt->size=0;
                QCC_PR_Expect("{");
-               
+
                type = NULL;
                if (QCC_PR_CheckToken(","))
                        QCC_PR_ParseError(ERR_NOTANAME, "element missing name");
@@ -3477,7 +3455,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
                        if (newparm->size > newt->size)
                                newt->size = newparm->size;
                        newt->num_parms++;
-                       
+
                        if (type)
                                type->next = newparm;
                        else
@@ -3519,7 +3497,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
                }
        }
        QCC_PR_Lex ();
-       
+
        if (QCC_PR_CheckToken ("("))    //this is followed by parameters. Must be a function.
        {
                type_inlinefunction = true;
@@ -3529,7 +3507,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype)
        {
                if (newtype)
                {
-                       type = QCC_PR_DuplicateType(type);                      
+                       type = QCC_PR_DuplicateType(type);
                }
 
                return type;