Updated cstrike gamedata.
1 /* Pawn compiler - Error message system
2 * In fact a very simple system, using only 'panic mode'.
4 * Copyright (c) ITB CompuPhase, 1997-2006
6 * This software is provided "as-is", without any express or implied warranty.
7 * In no event will the authors be held liable for any damages arising from
8 * the use of this software.
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software in
16 * a product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 * 3. This notice may not be removed or altered from any source distribution.
25 #if defined __WIN32__ || defined _WIN32 || defined __MSDOS__
28 #if defined LINUX || defined __GNUC__
33 #include <stdarg.h> /* ANSI standardized variable argument list functions */
36 #include <alloc/fortify.h>
42 #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */
51 #define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0])
52 static unsigned char warndisable[(NUM_WARNINGS + 7) / 8]; /* 8 flags in a char */
55 static int errstart; /* line number at which the instruction started */
56 static int errline; /* forced line number for the error message */
60 * Outputs an error message (note: msg is passed optionally).
61 * If an error is found, the variable "errflag" is set and subsequent
62 * errors are ignored until lex() finds a semicolumn or a keyword
63 * (lex() resets "errflag" in that case).
65 * Global references: inpfname (reffered to only)
66 * fline (reffered to only)
67 * fcurrent (reffered to only)
70 SC_FUNC int error(int number,...)
72 static char *prefix[3]={ "error", "fatal error", "warning" };
73 static int lastline,errorcount;
74 static short lastfile;
78 /* errflag is reset on each semicolon.
79 * In a two-pass compiler, an error should not be reported twice. Therefore
80 * the error reporting is enabled only in the second pass (and only when
81 * actually producing output). Fatal errors may never be ignored.
83 if ((errflag || sc_status!=statWRITE) && (number<120 || number>=200))
86 /* also check for disabled warnings */
88 int index=(number-200)/8;
89 int mask=1 << ((number-200)%8);
90 if ((warndisable[index] & mask)!=0)
97 errflag=TRUE; /* set errflag (skip rest of erroneous expression) */
99 } else if (number<200){
100 msg=fatalmsg[number-120];
102 errnum++; /* a fatal error also counts as an error */
104 msg=warnmsg[number-200];
109 assert(errstart<=fline);
114 assert(errstart<=errline);
115 va_start(argptr,number);
116 if (strlen(errfname)==0) {
117 int start= (errstart==errline) ? -1 : errstart;
118 if (pc_error(number,msg,inpfname,start,errline,argptr)) {
120 pc_closeasm(outf,TRUE);
123 longjmp(errbuf,3); /* user abort */
126 FILE *fp=fopen(errfname,"a");
128 if (errstart>=0 && errstart!=errline)
129 fprintf(fp,"%s(%d -- %d) : %s %03d: ",inpfname,errstart,errline,pre,number);
131 fprintf(fp,"%s(%d) : %s %03d: ",inpfname,errline,pre,number);
132 vfprintf(fp,msg,argptr);
138 if (number>=120 && number<200 || errnum>25){
139 if (strlen(errfname)==0) {
140 va_start(argptr,number);
141 pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr);
145 pc_closeasm(outf,TRUE);
148 longjmp(errbuf,2); /* fatal error, quit */
152 /* check whether we are seeing many errors on the same line */
153 if ((errstart<0 && lastline!=fline) || lastline<errstart || lastline>fline || fcurrent!=lastfile)
160 error(127); /* too many error/warning messages on one line */
165 SC_FUNC void errorset(int code,int line)
169 errflag=FALSE; /* start reporting errors */
172 errflag=TRUE; /* stop reporting errors */
175 errstart=fline; /* save start line number */
178 errstart=-1; /* forget start line number */
187 /* sc_enablewarning()
188 * Enables or disables a warning (errors cannot be disabled).
189 * Initially all warnings are enabled. The compiler does this by setting bits
190 * for the *disabled* warnings and relying on the array to be zero-initialized.
192 * Parameter enable can be:
197 int pc_enablewarning(int number,int enable)
203 return FALSE; /* errors and fatal errors cannot be disabled */
205 if (number>=NUM_WARNINGS)
209 mask=(unsigned char)(1 << (number%8));
212 warndisable[index] |= mask;
215 warndisable[index] &= (unsigned char)~mask;
218 warndisable[index] ^= mask;