From d792a19e4ae7c0fdd310306af3f2be6874883308 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Mon, 28 Aug 2006 15:22:02 +0000 Subject: [PATCH] updated compiler to 3.2.3636 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4067 --- sourcepawn/compiler/amx.h | 4 +- sourcepawn/compiler/amxdbg.h | 2 +- sourcepawn/compiler/libpawnc.c | 2 +- sourcepawn/compiler/pawncc.c | 2 +- sourcepawn/compiler/sc.h | 124 +++++++++-------- sourcepawn/compiler/sc1.c | 244 ++++++++++++++++++++++----------- sourcepawn/compiler/sc2.c | 28 +++- sourcepawn/compiler/sc3.c | 27 +++- sourcepawn/compiler/sc4.c | 10 +- sourcepawn/compiler/sc5.scp | 186 ++++++++++++------------- sourcepawn/compiler/sc6.c | 7 +- sourcepawn/compiler/sci18n.c | 2 +- sourcepawn/compiler/sclist.c | 6 +- sourcepawn/compiler/scmemfil.c | 11 +- sourcepawn/compiler/scvars.c | 2 +- sourcepawn/compiler/svnrev.h | 10 +- 16 files changed, 397 insertions(+), 270 deletions(-) diff --git a/sourcepawn/compiler/amx.h b/sourcepawn/compiler/amx.h index 6ba09a92..3c473a77 100644 --- a/sourcepawn/compiler/amx.h +++ b/sourcepawn/compiler/amx.h @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: amx.h 3579 2006-06-06 13:35:29Z thiadmer $ + * Version: $Id: amx.h 3633 2006-08-11 16:20:18Z thiadmer $ */ #ifndef AMX_H_INCLUDED @@ -266,6 +266,7 @@ typedef struct tagAMX { cell alt ; cell reset_stk ; cell reset_hea ; + /* extra fields for increased performance */ cell sysreq_d ; /* relocated address/value for the SYSREQ.D opcode */ #if defined JIT /* support variables for the JIT */ @@ -341,6 +342,7 @@ enum { #define AMX_FLAG_COMPACT 0x04 /* compact encoding */ #define AMX_FLAG_SLEEP 0x08 /* script uses the sleep instruction (possible re-entry or power-down mode) */ #define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no BREAK opcodes */ +#define AMX_FLAG_SYSREQN 0x800 /* script new (optimized) version of SYSREQ opcode */ #define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ #define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ #define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ diff --git a/sourcepawn/compiler/amxdbg.h b/sourcepawn/compiler/amxdbg.h index 4fc3c1c1..606b4806 100644 --- a/sourcepawn/compiler/amxdbg.h +++ b/sourcepawn/compiler/amxdbg.h @@ -21,7 +21,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: amxdbg.h 3519 2006-02-17 17:57:04Z thiadmer $ + * Version: $Id: amxdbg.h 3612 2006-07-22 09:59:46Z thiadmer $ */ #ifndef AMXDBG_H_INCLUDED diff --git a/sourcepawn/compiler/libpawnc.c b/sourcepawn/compiler/libpawnc.c index c2aa9f27..ddf84261 100644 --- a/sourcepawn/compiler/libpawnc.c +++ b/sourcepawn/compiler/libpawnc.c @@ -20,7 +20,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: libsc.c 3114 2005-03-17 14:48:29Z thiadmer $ + * Version: $Id: libpawnc.c 3612 2006-07-22 09:59:46Z thiadmer $ */ #include #include diff --git a/sourcepawn/compiler/pawncc.c b/sourcepawn/compiler/pawncc.c index f9839590..ff78485c 100644 --- a/sourcepawn/compiler/pawncc.c +++ b/sourcepawn/compiler/pawncc.c @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) cod.flags = 0; if (hdr->flags & AMX_FLAG_DEBUG) { - cod.flags |= SP_FILE_DEBUG; + cod.flags |= SP_FLAG_DEBUG; } cod.code = sizeof(cod); cod.main = hdr->cip; diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 4f839169..5c5e004e 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -25,7 +25,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc.h 3590 2006-06-24 14:16:39Z thiadmer $ + * Version: $Id: sc.h 3636 2006-08-14 15:42:05Z thiadmer $ */ #ifndef SC_H_INCLUDED #define SC_H_INCLUDED @@ -279,11 +279,11 @@ typedef struct s_stringpair { #define opargs(n) ((n)*sizeof(cell)) /* size of typical argument */ /* Tokens recognized by lex() - * Some of these constants are assigned as well to the variable "lastst" + * Some of these constants are assigned as well to the variable "lastst" (see SC1.C) */ #define tFIRST 256 /* value of first multi-character operator */ #define tMIDDLE 280 /* value of last multi-character operator */ -#define tLAST 326 /* value of last multi-character match-able token */ +#define tLAST 329 /* value of last multi-character match-able token */ /* multi-character operators */ #define taMULT 256 /* *= */ #define taDIV 257 /* /= */ @@ -312,62 +312,66 @@ typedef struct s_stringpair { #define tDBLCOLON 280 /* :: */ /* reserved words (statements) */ #define tASSERT 281 -#define tBREAK 282 -#define tCASE 283 -#define tCHAR 284 -#define tCONST 285 -#define tCONTINUE 286 -#define tDEFAULT 287 -#define tDEFINED 288 -#define tDO 289 -#define tELSE 290 -#define tENUM 291 -#define tEXIT 292 -#define tFOR 293 -#define tFORWARD 294 -#define tGOTO 295 -#define tIF 296 -#define tNATIVE 297 -#define tNEW 298 -#define tDECL 299 -#define tOPERATOR 300 -#define tPUBLIC 301 -#define tRETURN 302 -#define tSIZEOF 303 -#define tSLEEP 304 -#define tSTATE 305 -#define tSTATIC 306 -#define tSTOCK 307 -#define tSWITCH 308 -#define tTAGOF 309 -#define tWHILE 310 +#define tBEGIN 282 +#define tBREAK 283 +#define tCASE 284 +#define tCHAR 285 +#define tCONST 286 +#define tCONTINUE 287 +#define tDEFAULT 288 +#define tDEFINED 289 +#define tDO 290 +#define tELSE 291 +#define tEND 292 +#define tENUM 293 +#define tEXIT 294 +#define tFOR 295 +#define tFORWARD 296 +#define tGOTO 297 +#define tIF 298 +#define tNATIVE 299 +#define tNEW 300 +#define tDECL 301 +#define tOPERATOR 302 +#define tPUBLIC 303 +#define tRETURN 304 +#define tSIZEOF 305 +#define tSLEEP 306 +#define tSTATE 307 +#define tSTATIC 308 +#define tSTOCK 309 +#define tSWITCH 310 +#define tTAGOF 311 +#define tTHEN 312 +#define tWHILE 313 /* compiler directives */ -#define tpASSERT 311 /* #assert */ -#define tpDEFINE 312 -#define tpELSE 313 /* #else */ -#define tpELSEIF 314 /* #elseif */ -#define tpEMIT 315 -#define tpENDIF 316 -#define tpENDINPUT 317 -#define tpENDSCRPT 318 -#define tpERROR 319 -#define tpFILE 320 -#define tpIF 321 /* #if */ -#define tINCLUDE 322 -#define tpLINE 323 -#define tpPRAGMA 324 -#define tpTRYINCLUDE 325 -#define tpUNDEF 326 +#define tpASSERT 314 /* #assert */ +#define tpDEFINE 315 +#define tpELSE 316 /* #else */ +#define tpELSEIF 317 /* #elseif */ +#define tpEMIT 318 +#define tpENDIF 319 +#define tpENDINPUT 320 +#define tpENDSCRPT 321 +#define tpERROR 322 +#define tpFILE 323 +#define tpIF 324 /* #if */ +#define tINCLUDE 325 +#define tpLINE 326 +#define tpPRAGMA 327 +#define tpTRYINCLUDE 328 +#define tpUNDEF 329 /* semicolon is a special case, because it can be optional */ -#define tTERM 327 /* semicolon or newline */ -#define tENDEXPR 328 /* forced end of expression */ +#define tTERM 330 /* semicolon or newline */ +#define tENDEXPR 331 /* forced end of expression */ /* other recognized tokens */ -#define tNUMBER 329 /* integer number */ -#define tRATIONAL 330 /* rational number */ -#define tSYMBOL 331 -#define tLABEL 332 -#define tSTRING 333 -#define tEXPR 334 /* for assigment to "lastst" only */ +#define tNUMBER 332 /* integer number */ +#define tRATIONAL 333 /* rational number */ +#define tSYMBOL 334 +#define tLABEL 335 +#define tSTRING 336 +#define tEXPR 337 /* for assigment to "lastst" only (see SC1.C) */ +#define tENDLESS 338 /* endless loop, for assigment to "lastst" only */ /* (reversed) evaluation of staging buffer */ #define sSTARTREORDER 0x01 @@ -698,15 +702,15 @@ SC_FUNC void delete_dbgstringtable(void); typedef unsigned char MEMFILE; #define tMEMFILE 1 #endif -MEMFILE *mfcreate(char *filename); +MEMFILE *mfcreate(const char *filename); void mfclose(MEMFILE *mf); int mfdump(MEMFILE *mf); -long mflength(MEMFILE *mf); +long mflength(const MEMFILE *mf); long mfseek(MEMFILE *mf,long offset,int whence); -unsigned int mfwrite(MEMFILE *mf,unsigned char *buffer,unsigned int size); +unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size); unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size); char *mfgets(MEMFILE *mf,char *string,unsigned int size); -int mfputs(MEMFILE *mf,char *string); +int mfputs(MEMFILE *mf,const char *string); /* function prototypes in SCI18N.C */ #define MAXCODEPAGE 12 diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index bd4ea550..aaa97ed6 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -20,7 +20,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc1.c 3591 2006-06-25 14:30:07Z thiadmer $ + * Version: $Id: sc1.c 3636 2006-08-14 15:42:05Z thiadmer $ */ #include #include @@ -109,21 +109,21 @@ static long max_stacksize(symbol *root,int *recursion); static int testsymbols(symbol *root,int level,int testlabs,int testconst); static void destructsymbols(symbol *root,int level); static constvalue *find_constval_byval(constvalue *table,cell val); +static symbol *fetchlab(char *name); static void statement(int *lastindent,int allow_decl); -static void compound(int stmt_sameline); +static void compound(int stmt_sameline,int starttok); +static int test(int label,int parens,int invert); static int doexpr(int comma,int chkeffect,int allowarray,int mark_endexpr, int *tag,symbol **symptr,int chkfuncresult); static void doassert(void); static void doexit(void); -static void test(int label,int parens,int invert); -static void doif(void); -static void dowhile(void); -static void dodo(void); -static void dofor(void); +static int doif(void); +static int dowhile(void); +static int dodo(void); +static int dofor(void); static void doswitch(void); static void dogoto(void); static void dolabel(void); -static symbol *fetchlab(char *name); static void doreturn(void); static void dobreak(void); static void docont(void); @@ -134,10 +134,17 @@ static void delwhile(void); static int *readwhile(void); static void inst_datetime_defines(void); +enum { + TEST_PLAIN, /* no parentheses */ + TEST_THEN, /* '(' ')' or 'then' */ + TEST_DO, /* '(' ')' or 'do' */ + TEST_OPT, /* '(' ')' or */ +}; static int norun = 0; /* the compiler never ran */ -static int autozero = 1; /* if 1 will zero out the variable, if 0 omit the zeroing */ +static int autozero = 1; /* if 1 will zero out the variable, if 0 omit the zeroing */ static int lastst = 0; /* last executed statement type */ static int nestlevel = 0; /* number of active (open) compound statements */ +static int endlessloop= 0; /* nesting level of endless loop */ static int rettype = 0; /* the type that a "return" expression should have */ static int skipinput = 0; /* number of lines to skip from the first input file */ static int optproccall = TRUE; /* support "procedure call" */ @@ -449,9 +456,9 @@ cleanup: pc_printf("Stack/heap size: %8ld bytes; ", (long)pc_stksize*sizeof(cell)); pc_printf("estimated max. usage"); if (recursion) - pc_printf(" is unknown, due to recursion\n"); + pc_printf(": unknown, due to recursion\n"); else if ((pc_memflags & suSLEEP_INSTR)!=0) - pc_printf(" is unknown, due to the \"sleep\" instruction\n"); + pc_printf(": unknown, due to the \"sleep\" instruction\n"); else pc_printf("=%ld cells (%ld bytes)\n",stacksize,stacksize*sizeof(cell)); pc_printf("Total requirements:%8ld bytes\n", (long)hdrsize+(long)code_idx+(long)glb_declared*sizeof(cell)+(long)pc_stksize*sizeof(cell)); @@ -1415,6 +1422,9 @@ static void dumplits(void) { int j,k; + if (sc_status==statSKIP) + return; + k=0; while (k1 && dim[numdim-1]==0) { + /* also look whether, by any chance, all "counted" final dimensions are + * the same value; if so, we can store this + */ + constvalue *ld=lastdim.next; + int d,match; + for (d=0; dname,NULL,16)==d); + if (d==0) + match=ld->value; + else if (match!=ld->value) + break; + ld=ld->next; + } /* for */ + if (d==dim[numdim-2]) + dim[numdim-1]=match; + } /* if */ /* after all arrays have been initalized, we know the (major) dimensions * of the array and we can properly adjust the indirection vectors */ @@ -2446,26 +2474,28 @@ static void decl_const(int vclass) int symbolline; symbol *sym; - insert_docstring_separator(); /* see comment in newfunc() */ - tag=pc_addtag(NULL); - if (lex(&val,&str)!=tSYMBOL) /* read in (new) token */ - error(20,str); /* invalid symbol name */ - symbolline=fline; /* save line where symbol was found */ - strcpy(constname,str); /* save symbol name */ - needtoken('='); - constexpr(&val,&exprtag,NULL);/* get value */ + insert_docstring_separator(); /* see comment in newfunc() */ + do { + tag=pc_addtag(NULL); + if (lex(&val,&str)!=tSYMBOL) /* read in (new) token */ + error(20,str); /* invalid symbol name */ + symbolline=fline; /* save line where symbol was found */ + strcpy(constname,str); /* save symbol name */ + needtoken('='); + constexpr(&val,&exprtag,NULL); /* get value */ + /* add_constant() checks for duplicate definitions */ + if (!matchtag(tag,exprtag,FALSE)) { + /* temporarily reset the line number to where the symbol was defined */ + int orgfline=fline; + fline=symbolline; + error(213); /* tagname mismatch */ + fline=orgfline; + } /* if */ + sym=add_constant(constname,val,vclass,tag); + if (sym!=NULL) + sc_attachdocumentation(sym);/* attach any documenation to the constant */ + } while (matchtoken(',')); /* enddo */ /* more? */ needtoken(tTERM); - /* add_constant() checks for duplicate definitions */ - if (!matchtag(tag,exprtag,FALSE)) { - /* temporarily reset the line number to where the symbol was defined */ - int orgfline=fline; - fline=symbolline; - error(213); /* tagname mismatch */ - fline=orgfline; - } /* if */ - sym=add_constant(constname,val,vclass,tag); - if (sym!=NULL) - sc_attachdocumentation(sym);/* attach any documenation to the function */ } /* decl_enum - declare enumerated constants @@ -4597,7 +4627,7 @@ redef_enumfield: */ static void statement(int *lastindent,int allow_decl) { - int tok; + int tok,save; cell val; char *st; @@ -4650,29 +4680,26 @@ static void statement(int *lastindent,int allow_decl) } /* if */ break; case '{': - tok=fline; + case tBEGIN: + save=fline; if (!matchtoken('}')) /* {} is the empty statement */ - compound(tok==fline); + compound(save==fline,tok); /* lastst (for "last statement") does not change */ break; case ';': error(36); /* empty statement */ break; case tIF: - doif(); - lastst=tIF; + lastst=doif(); break; case tWHILE: - dowhile(); - lastst=tWHILE; + lastst=dowhile(); break; case tDO: - dodo(); - lastst=tDO; + lastst=dodo(); break; case tFOR: - dofor(); - lastst=tFOR; + lastst=dofor(); break; case tSWITCH: doswitch(); @@ -4734,23 +4761,24 @@ static void statement(int *lastindent,int allow_decl) } /* switch */ } -static void compound(int stmt_sameline) +static void compound(int stmt_sameline,int starttok) { int indent=-1; cell save_decl=declared; int count_stmt=0; int block_start=fline; /* save line where the compound block started */ + int endtok; /* if there is more text on this line, we should adjust the statement indent */ if (stmt_sameline) { int i; const unsigned char *p=lptr; /* go back to the opening brace */ - while (*p!='{') { + while (*p!=starttok) { assert(p>pline); p--; } /* while */ - assert(*p=='{'); /* it should be found */ + assert(*p==starttok); /* it should be found */ /* go forward, skipping white-space */ p++; while (*p<=' ' && *p!='\0') @@ -4764,13 +4792,14 @@ static void compound(int stmt_sameline) stmtindent++; } /* if */ + endtok=(starttok=='{') ? '}' : tEND; nestlevel+=1; /* increase compound statement level */ - while (matchtoken('}')==0){ /* repeat until compound statement is closed */ + while (matchtoken(endtok)==0){/* repeat until compound statement is closed */ if (!freading){ error(30,block_start); /* compound block not closed at end of file */ break; } else { - if (count_stmt>0 && (lastst==tRETURN || lastst==tBREAK || lastst==tCONTINUE)) + if (count_stmt>0 && (lastst==tRETURN || lastst==tBREAK || lastst==tCONTINUE || lastst==tENDLESS)) error(225); /* unreachable code */ statement(&indent,TRUE); /* do a statement */ count_stmt++; @@ -4864,11 +4893,12 @@ SC_FUNC int constexpr(cell *val,int *tag,symbol **symptr) * * Global references: sc_intest (altered, but restored upon termination) */ -static void test(int label,int parens,int invert) +static int test(int label,int parens,int invert) { int index,tok; cell cidx; int ident,tag; + int endtok; cell constval; symbol *sym; int localstaging=FALSE; @@ -4884,8 +4914,15 @@ static void test(int label,int parens,int invert) PUSHSTK_I(sc_intest); sc_intest=TRUE; - if (parens) - needtoken('('); + endtok=0; + if (parens!=TEST_PLAIN) { + if (matchtoken('(')) + endtok=')'; + else if (parens==TEST_THEN) + endtok=tTHEN; + else if (parens==TEST_DO) + endtok=tDO; + } /* if */ do { stgget(&index,&cidx); /* mark position (of last expression) in * code generator */ @@ -4894,17 +4931,19 @@ static void test(int label,int parens,int invert) if (tok) markexpr(sEXPR,NULL,0); } while (tok); /* do */ - if (parens) - needtoken(')'); + if (endtok!=0) + needtoken(endtok); if (ident==iARRAY || ident==iREFARRAY) { char *ptr=(sym->name!=NULL) ? sym->name : "-unknown-"; error(33,ptr); /* array must be indexed */ } /* if */ if (ident==iCONSTEXPR) { /* constant expression */ + int testtype=0; sc_intest=(short)POPSTK_I();/* restore stack */ stgdel(index,cidx); if (constval) { /* code always executed */ error(206); /* redundant test: always non-zero */ + testtype=tENDLESS; } else { error(205); /* redundant code: never executed */ jumplabel(label); @@ -4913,7 +4952,7 @@ static void test(int label,int parens,int invert) stgout(0); /* write "jumplabel" code */ stgset(FALSE); /* stop staging */ } /* if */ - return; + return testtype; } /* if */ if (tag!=0 && tag!=pc_addtag("bool")) if (check_userop(lneg,tag,0,1,NULL,&tag)) @@ -4929,37 +4968,49 @@ static void test(int label,int parens,int invert) * assert() when localstaging is set to TRUE) */ stgset(FALSE); /* stop staging */ } /* if */ + return 0; } -static void doif(void) +static int doif(void) { int flab1,flab2; int ifindent; + int lastst_true; ifindent=stmtindent; /* save the indent of the "if" instruction */ flab1=getlabel(); /* get label number for false branch */ - test(flab1,TRUE,FALSE); /* get expression, branch to flab1 if false */ + test(flab1,TEST_THEN,FALSE); /* get expression, branch to flab1 if false */ statement(NULL,FALSE); /* if true, do a statement */ - if (matchtoken(tELSE)==0){ /* if...else ? */ + if (!matchtoken(tELSE)) { /* if...else ? */ setlabel(flab1); /* no, simple if..., print false label */ } else { + lastst_true=lastst; /* save last statement of the "true" branch */ /* to avoid the "dangling else" error, we want a warning if the "else" * has a lower indent than the matching "if" */ if (stmtindent0) error(217); /* loose indentation */ flab2=getlabel(); if ((lastst!=tRETURN) && (lastst!=tGOTO)) - jumplabel(flab2); + jumplabel(flab2); /* "true" branch jumps around "else" clause, unless the "true" branch statement already jumped */ setlabel(flab1); /* print false label */ statement(NULL,FALSE); /* do "else" clause */ setlabel(flab2); /* print true label */ - } /* endif */ + /* if both the "true" branch and the "false" branch ended with the same + * kind of statement, set the last statement id to that kind, rather than + * to the generic tIF; this allows for better "unreachable code" checking + */ + if (lastst==lastst_true) + return lastst; + } /* if */ + return tIF; } -static void dowhile(void) +static int dowhile(void) { int wq[wqSIZE]; /* allocate local queue */ + int save_endlessloop,retcode; + save_endlessloop=endlessloop; addwhile(wq); /* add entry to queue for "break" */ setlabel(wq[wqLOOP]); /* loop label */ /* The debugger uses the "break" opcode to be able to "break" out of @@ -4967,21 +5018,27 @@ static void dowhile(void) * tiniest loop, set it below the top of the loop */ setline(TRUE); - test(wq[wqEXIT],TRUE,FALSE); /* branch to wq[wqEXIT] if false */ + endlessloop=test(wq[wqEXIT],TEST_DO,FALSE);/* branch to wq[wqEXIT] if false */ statement(NULL,FALSE); /* if so, do a statement */ jumplabel(wq[wqLOOP]); /* and loop to "while" start */ setlabel(wq[wqEXIT]); /* exit label */ delwhile(); /* delete queue entry */ + + retcode=endlessloop ? tENDLESS : tWHILE; + endlessloop=save_endlessloop; + return retcode; } /* * Note that "continue" will in this case not jump to the top of the loop, but * to the end: just before the TRUE-or-FALSE testing code. */ -static void dodo(void) +static int dodo(void) { int wq[wqSIZE],top; + int save_endlessloop,retcode; + save_endlessloop=endlessloop; addwhile(wq); /* see "dowhile" for more info */ top=getlabel(); /* make a label first */ setlabel(top); /* loop label */ @@ -4989,26 +5046,32 @@ static void dodo(void) needtoken(tWHILE); setlabel(wq[wqLOOP]); /* "continue" always jumps to WQLOOP. */ setline(TRUE); - test(wq[wqEXIT],TRUE,FALSE); + endlessloop=test(wq[wqEXIT],TEST_OPT,FALSE); jumplabel(top); setlabel(wq[wqEXIT]); delwhile(); needtoken(tTERM); + + retcode=endlessloop ? tENDLESS : tDO; + endlessloop=save_endlessloop; + return retcode; } -static void dofor(void) +static int dofor(void) { int wq[wqSIZE],skiplab; cell save_decl; - int save_nestlevel,index; + int save_nestlevel,save_endlessloop; + int index,endtok; int *ptr; save_decl=declared; save_nestlevel=nestlevel; + save_endlessloop=endlessloop; addwhile(wq); skiplab=getlabel(); - needtoken('('); + endtok= matchtoken('(') ? ')' : tDO; if (matchtoken(';')==0) { /* new variable declarations are allowed here */ if (matchtoken(tNEW)) { @@ -5016,7 +5079,7 @@ static void dofor(void) * 'compound statement' level of it own. */ nestlevel++; - autozero=1; + autozero=1; declloc(FALSE); /* declare local variable */ } else { doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 1 */ @@ -5046,14 +5109,16 @@ static void dofor(void) stgmark(sSTARTREORDER); stgmark((char)(sEXPRSTART+0)); /* mark start of 2nd expression in stage */ setlabel(skiplab); /* jump to this point after 1st expression */ - if (matchtoken(';')==0) { - test(wq[wqEXIT],FALSE,FALSE); /* expression 2 (jump to wq[wqEXIT] if false) */ + if (matchtoken(';')) { + endlessloop=1; + } else { + endlessloop=test(wq[wqEXIT],TEST_PLAIN,FALSE);/* expression 2 (jump to wq[wqEXIT] if false) */ needtoken(';'); } /* if */ stgmark((char)(sEXPRSTART+1)); /* mark start of 3th expression in stage */ - if (matchtoken(')')==0) { + if (!matchtoken(endtok)) { doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 3 */ - needtoken(')'); + needtoken(endtok); } /* if */ stgmark(sENDREORDER); /* mark end of reversed evaluation */ stgout(index); @@ -5075,6 +5140,10 @@ static void dofor(void) delete_symbols(&loctab,nestlevel,FALSE,TRUE); nestlevel=save_nestlevel; /* reset 'compound statement' nesting level */ } /* if */ + + index=endlessloop ? tENDLESS : tFOR; + endlessloop=save_endlessloop; + return index; } /* The switch statement is incompatible with its C sibling: @@ -5092,16 +5161,17 @@ static void dofor(void) static void doswitch(void) { int lbl_table,lbl_exit,lbl_case; - int tok,swdefault,casecount; + int swdefault,casecount; + int tok,endtok; cell val; char *str; constvalue caselist = { NULL, "", 0, 0}; /* case list starts empty */ constvalue *cse,*csp; char labelname[sNAMEMAX+1]; - needtoken('('); + endtok= matchtoken('(') ? ')' : tDO; doexpr(TRUE,FALSE,FALSE,FALSE,NULL,NULL,TRUE);/* evaluate switch expression */ - needtoken(')'); + needtoken(endtok); /* generate the code for the switch statement, the label is the address * of the case table (to be generated later). */ @@ -5109,7 +5179,12 @@ static void doswitch(void) lbl_case=0; /* just to avoid a compiler warning */ ffswitch(lbl_table); - needtoken('{'); + if (matchtoken(tBEGIN)) { + endtok=tEND; + } else { + endtok='}'; + needtoken('{'); + } /* if */ lbl_exit=getlabel(); /* get label number for jumping out of switch */ swdefault=FALSE; casecount=0; @@ -5195,15 +5270,14 @@ static void doswitch(void) */ jumplabel(lbl_exit); break; - case '}': - /* nothing, but avoid dropping into "default" */ - break; default: - error(2); - indent_nowarn=TRUE; /* disable this check */ - tok='}'; /* break out of the loop after an error */ + if (tok!=endtok) { + error(2); + indent_nowarn=TRUE; /* disable this check */ + tok=endtok; /* break out of the loop after an error */ + } /* if */ } /* switch */ - } while (tok!='}'); + } while (tok!=endtok); #if !defined NDEBUG /* verify that the case table is sorted (unfortunatly, duplicates can @@ -5238,7 +5312,7 @@ static void doassert(void) if ((sc_debug & sCHKBOUNDS)!=0) { flab1=getlabel(); /* get label number for "OK" branch */ - test(flab1,FALSE,TRUE); /* get expression and branch to flab1 if true */ + test(flab1,TEST_PLAIN,TRUE);/* get expression and branch to flab1 if true */ insert_dbgline(fline); /* make sure we can find the correct line number */ ffabort(xASSERTION); setlabel(flab1); @@ -5260,6 +5334,9 @@ static void dogoto(void) cell val; symbol *sym; + /* if we were inside an endless loop, assume that we jump out of it */ + endlessloop=0; + if (lex(&val,&st)==tSYMBOL) { sym=fetchlab(st); jumplabel((int)sym->addr); @@ -5443,6 +5520,7 @@ static void dobreak(void) { int *ptr; + endlessloop=0; /* if we were inside an endless loop, we just jumped out */ ptr=readwhile(); /* readwhile() gives an error if not in loop */ needtoken(tTERM); if (ptr==NULL) @@ -5530,7 +5608,7 @@ static void dostate(void) if (matchtoken('(')) { flabel=getlabel(); /* get label number for "false" branch */ pc_docexpr=TRUE; /* attach expression as a documentation string */ - test(flabel,FALSE,FALSE); /* get expression, branch to flabel if false */ + test(flabel,TEST_PLAIN,FALSE);/* get expression, branch to flabel if false */ pc_docexpr=FALSE; needtoken(')'); } else { diff --git a/sourcepawn/compiler/sc2.c b/sourcepawn/compiler/sc2.c index 859ec30f..4e2d6a98 100644 --- a/sourcepawn/compiler/sc2.c +++ b/sourcepawn/compiler/sc2.c @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc2.c 3590 2006-06-24 14:16:39Z thiadmer $ + * Version: $Id: sc2.c 3636 2006-08-14 15:42:05Z thiadmer $ */ #include #include @@ -947,11 +947,27 @@ static int command(void) if ((ifstack[iflevel-1] & PARSEMODE)==PARSEMODE) { /* there has been a parse mode already on this level, so skip the rest */ ifstack[iflevel-1] |= (char)SKIPMODE; + /* if we were already skipping this section, allow expressions with + * undefined symbols; otherwise check the expression to catch errors + */ + if (tok==tpELSEIF) { + if (skiplevel==iflevel) + preproc_expr(&val,NULL); /* get, but ignore the expression */ + else + lptr=strchr(lptr,'\0'); + } /* if */ } else { /* previous conditions were all FALSE */ if (tok==tpELSEIF) { - /* get new expression */ - preproc_expr(&val,NULL); /* get value (or 0 on error) */ + /* if we were already skipping this section, allow expressions with + * undefined symbols; otherwise check the expression to catch errors + */ + if (skiplevel==iflevel) { + preproc_expr(&val,NULL); /* get value (or 0 on error) */ + } else { + lptr=strchr(lptr,'\0'); + val=0; + } /* if */ ifstack[iflevel-1]=(char)(val ? PARSEMODE : SKIPMODE); } else { /* a simple #else, clear skip mode */ @@ -1816,10 +1832,10 @@ char *sc_tokens[] = { "*=", "/=", "%=", "+=", "-=", "<<=", ">>>=", ">>=", "&=", "^=", "|=", "||", "&&", "==", "!=", "<=", ">=", "<<", ">>>", ">>", "++", "--", "...", "..", "::", - "assert", "break", "case", "char", "const", "continue", "default", - "defined", "do", "else", "enum", "exit", "for", "forward", "goto", + "assert", "*begin", "break", "case", "char", "const", "continue", "default", + "defined", "do", "else", "*end", "enum", "exit", "for", "forward", "goto", "if", "native", "new", "decl", "operator", "public", "return", "sizeof", - "sleep", "state", "static", "stock", "switch", "tagof", "while", + "sleep", "state", "static", "stock", "switch", "tagof", "*then", "while", "#assert", "#define", "#else", "#elseif", "#emit", "#endif", "#endinput", "#endscript", "#error", "#file", "#if", "#include", "#line", "#pragma", "#tryinclude", "#undef", diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.c index 9c5df24c..dc6785df 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.c @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc3.c 3598 2006-07-04 13:44:04Z thiadmer $ + * Version: $Id: sc3.c 3635 2006-08-13 12:19:41Z thiadmer $ */ #include #include @@ -619,9 +619,26 @@ static void plnge2(void (*oper)(void), } /* if */ } -static cell truemodulus(cell a,cell b) +static cell flooreddiv(cell a,cell b,int return_remainder) { - return (a % b + b) % b; + cell q,r; + + if (b==0) { + error(29); + return 0; + } /* if */ + /* first implement truncated division in a portable way */ + #define IABS(a) ((a)>=0 ? (a) : (-a)) + q=IABS(a)/IABS(b); + if ((cell)(a ^ b)<0) + q=-q; /* swap sign if either "a" or "b" is negative (but not both) */ + r=a-q*b; /* calculate the matching remainder */ + /* now "fiddle" with the values to get floored division */ + if (r!=0 && (cell)(r ^ b)<0) { + q--; + r+=b; + } /* if */ + return return_remainder ? r : q; } static cell calc(cell left,void (*oper)(),cell right,char *boolresult) @@ -657,9 +674,9 @@ static cell calc(cell left,void (*oper)(),cell right,char *boolresult) else if (oper==os_mult) return (left * right); else if (oper==os_div) - return (left - truemodulus(left,right)) / right; + return flooreddiv(left,right,0); else if (oper==os_mod) - return truemodulus(left,right); + return flooreddiv(left,right,1); else error(29); /* invalid expression, assumed 0 (this should never occur) */ return 0; diff --git a/sourcepawn/compiler/sc4.c b/sourcepawn/compiler/sc4.c index 70e39dde..e271037d 100644 --- a/sourcepawn/compiler/sc4.c +++ b/sourcepawn/compiler/sc4.c @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc4.c 3579 2006-06-06 13:35:29Z thiadmer $ + * Version: $Id: sc4.c 3633 2006-08-11 16:20:18Z thiadmer $ */ #include #include @@ -214,7 +214,7 @@ SC_FUNC void writetrailer(void) */ SC_FUNC void begcseg(void) { - if (curseg!=sIN_CSEG || fcurrent!=fcurseg) { + if (sc_status!=statSKIP && (curseg!=sIN_CSEG || fcurrent!=fcurseg)) { stgwrite("\n"); stgwrite("CODE "); outval(fcurrent,FALSE); @@ -232,7 +232,7 @@ SC_FUNC void begcseg(void) */ SC_FUNC void begdseg(void) { - if (curseg!=sIN_DSEG || fcurrent!=fcurseg) { + if (sc_status!=statSKIP && (curseg!=sIN_DSEG || fcurrent!=fcurseg)) { stgwrite("\n"); stgwrite("DATA "); outval(fcurrent,FALSE); @@ -245,6 +245,10 @@ SC_FUNC void begdseg(void) SC_FUNC void setline(int chkbounds) { + if (sc_asmfile) { + stgwrite("\t; line "); + outval(fline,TRUE); + } /* if */ if ((sc_debug & sSYMBOLIC)!=0 || chkbounds && (sc_debug & sCHKBOUNDS)!=0) { /* generate a "break" (start statement) opcode rather than a "line" opcode * because earlier versions of Small/Pawn have an incompatible version of the diff --git a/sourcepawn/compiler/sc5.scp b/sourcepawn/compiler/sc5.scp index 25e4baa2..1bf02541 100644 --- a/sourcepawn/compiler/sc5.scp +++ b/sourcepawn/compiler/sc5.scp @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc5.sch 3590 2006-06-24 14:16:39Z thiadmer $ + * Version: $Id: sc5.sch 3633 2006-08-11 16:20:18Z thiadmer $ */ SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); @@ -27,13 +27,13 @@ SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned ch /*-*SCPACK start of pair table, do not change or remove this line */ unsigned char errstr_table[][2] = { {101,32}, {111,110}, {116,32}, {105,110}, {97,114}, {116,105}, {100,32}, {115,32}, {101,114}, {97,108}, {101,110}, {37,115}, {133,129}, {34,139}, {141,34}, {117,110}, - {110,111}, {114,101}, {115,105}, {121,32}, {97,116}, {111,114}, {97,110}, {32,142}, {109,98}, {115,116}, {41,10}, {100,101}, {109,138}, {101,134}, {98,108}, {140,32}, - {111,108}, {114,97}, {144,130}, {118,137}, {143,99}, {102,164}, {115,121}, {166,152}, {167,160}, {117,115}, {97,32}, {115,146}, {97,158}, {149,32}, {132,161}, {105,134}, + {114,101}, {110,111}, {115,105}, {121,32}, {97,116}, {111,114}, {97,110}, {32,142}, {109,98}, {115,116}, {41,10}, {100,101}, {109,138}, {101,134}, {98,108}, {140,32}, + {111,108}, {114,97}, {145,130}, {118,137}, {143,99}, {102,164}, {115,121}, {166,152}, {167,160}, {117,115}, {97,32}, {115,146}, {97,158}, {149,32}, {132,161}, {105,134}, {103,32}, {163,175}, {103,117}, {178,156}, {136,32}, {132,179}, {131,177}, {111,102}, {116,104}, {101,120}, {105,135}, {165,159}, {101,100}, {99,104}, {118,132}, {168,151}, - {105,172}, {190,192}, {155,102}, {174,147}, {183,32}, {109,97}, {116,111}, {99,129}, {101,135}, {181,130}, {98,128}, {115,10}, {112,145}, {153,148}, {44,32}, {40,191}, - {169,130}, {151,10}, {101,10}, {207,154}, {109,208}, {116,97}, {105,99}, {194,131}, {193,128}, {34,32}, {129,32}, {132,97}, {100,105}, {146,122}, {110,32}, {137,32}, - {104,97}, {101,108}, {117,108}, {99,111}, {108,111}, {109,148}, {199,153}, {58,209}, {111,112}, {97,115}, {108,128}, {232,136}, {230,150}, {150,32}, {204,171}, {131,176}, - {212,202}, {102,105}, {119,105}, {185,238}, {109,112}, {116,136}, {165,140}, {197,147}, {102,149}, {111,32}, {131,32}, {213,176}, {110,117}, {115,117}, {118,128} + {105,172}, {190,192}, {155,102}, {174,147}, {183,32}, {109,97}, {116,111}, {99,129}, {101,135}, {112,144}, {181,130}, {98,128}, {115,10}, {153,148}, {44,32}, {40,191}, + {169,130}, {151,10}, {101,10}, {207,154}, {109,208}, {116,97}, {194,131}, {193,128}, {34,32}, {129,32}, {105,99}, {132,97}, {100,105}, {146,122}, {110,32}, {137,32}, + {104,97}, {101,108}, {117,108}, {99,111}, {108,111}, {109,148}, {199,153}, {58,209}, {111,112}, {97,115}, {108,128}, {232,136}, {230,150}, {150,32}, {201,171}, {131,176}, + {212,203}, {102,105}, {119,105}, {185,238}, {109,112}, {116,136}, {165,140}, {197,147}, {102,149}, {111,32}, {131,32}, {213,176}, {110,117}, {115,117}, {118,128} }; /*-*SCPACK end of pair table, do not change or remove this line */ @@ -134,96 +134,96 @@ static char *errmsg[] = { #else "\271pect\235\306k\212:\227\316bu\202fo\217\206\216\012", "\201l\223\252s\203g\352\315e\234\202(\255\363\201) c\355f\240\344w ea\275 \042c\351e\042\012", - "\233cl\333\237\304\252\344c\337\330\324appe\204 \372\252\343\364o\217\206\236ock\012", + "\233cl\333\237\304\252\344c\337\327\324appe\204 \372\252\343\364o\217\206\236ock\012", "\366\227 \272\242i\364le\234t\274\012", - "\273\367\242\340\376\265t\313", + "\273\367\242\340\376\265t\314", "\360a\253gn\235\306 \355\256y\012", - "\353\224\255c\226\242\312\221\327\274\012", + "\353\224\255c\226\242\313\220\326\274\012", "\360\252\354\202\363\201; \351\375m\235z\210o\012", "\266\303\335\200(nega\205ve\316z\210\371\255ou\202\304bo\217ds\232", "\266\273\255\233cl\333\214\012", - "\266out\222d\200\366\313", - "\266\273c\211l\316\242\252\261add\221s\313", - "\220 \212tr\223po\203\202(\220 pu\236\326 \366s\232", + "\266out\222d\200\366\314", + "\266\273c\211l\316\242\252\261add\220s\314", + "\221 \212tr\223po\203\202(\221 pu\236\332 \366s\232", "\266\315e\234t; \242\372s\362t\275\012", - "\042\302a\342t\331c\351\200\360\270\200l\351\202c\351\200\372s\362t\275 \315e\234t\012", + "\042\302a\342t\330c\351\200\360\270\200l\351\202c\351\200\372s\362t\275 \315e\234t\012", "m\342\205p\352\302a\342t\207\372\042s\362t\275\042\012", - "\217\327\235\277\012", + "\217\326\235\277\012", "\203i\205\211iza\237d\224\252\271ce\274\207\233cl\204\235\335\322", "\242\252lab\341\347", "\266\250 nam\200\216\012", - "\250 \211\221ad\223\327\274\347", + "\250 \211\220ad\223\326\274\347", "\360l\243u\200(n\201-\354t\232", "\303a\253gn\234\202\360\222\364\352a\253gn\234t\012", - "\042b\221ak\331\255\042\307t\203ue\331\272ou\202\304\307t\271t\012", + "\042b\220ak\330\255\042\307t\203ue\330\272ou\202\304\307t\271t\012", "\273head\357\334ff\210\207from pro\306typ\322", - "\220 \345\275\357\042#if...\042\012", + "\221 \345\275\357\042#if...\042\012", "\266\275\333ct\264\354t\012", "\266\375bscrip\202(\242\355\303\255\306\371m\226\223\375bscripts)\347", "\266\363\201\316\351\375m\235z\210o\012", "\343\364o\217\206\315e\234\202\242c\344s\235a\202\270\200\212\206\304\361\352(\231\204t\235a\202l\203\200%d\232", - "\217k\220w\336\334\221c\205v\322", - "\303\203\233x ou\202\304bo\217d\207(\330\216\232", - "\303\360\203\233x\235(\330\216\232", - "\311do\310\242\340\376\252\302a\342\202\243u\200(\311%d\232", - "\311typ\200mis\345\275 (\311%d\232", + "\217k\221w\336\334\220c\205v\322", + "\303\203\233x ou\202\304bo\217d\207(\327\216\232", + "\303\360\203\233x\235(\327\216\232", + "\312do\310\242\340\376\252\302a\342\202\243u\200(\312%d\232", + "\312typ\200mis\345\275 (\312%d\232", "e\364t\223\315e\234t\012", "\266\231r\357(po\253\236\223n\201-\365m\203\224\235\231r\203g\232", - "\271t\241 \275\333c\365\207\332l\203\322", - "\354\202\250 \340\207\220 \335\322", - "dupl\326\224\200\042c\351e\331lab\341 (\243u\200%d\232", - "\266\341lip\222s\316\303\335\200\272\242k\220wn\012", - "\266\343\230\203a\237\304cl\351\207speci\361\210\313", + "\271t\241 \275\333c\365\207\331l\203\322", + "\354\202\250 \340\207\221 \335\322", + "dupl\332\224\200\042c\351e\330lab\341 (\243u\200%d\232", + "\266\341lip\222s\316\303\335\200\272\242k\221wn\012", + "\266\343\230\203a\237\304cl\351\207speci\361\210\314", "\275\333ct\264\354\202\271ce\274\207r\226g\200f\255pack\235\231r\203g\012", - "po\222\214\337p\333me\365\207\324\314c\274\200\211l nam\235p\333me\365\313", - "\306\371m\226\223\273\265t\313", - "\217k\220w\336\303\335\200(\330\216\232", + "po\222\214\337p\333me\365\207\324\311c\274\200\211l nam\235p\333me\365\314", + "\306\371m\226\223\273\265t\314", + "\217k\221w\336\303\335\200(\327\216\232", "\303\335\310d\371\242\345\275\316\255\233\231\203a\237\303\272\306\371sm\211l\012", "\303\334\234\222\201\207d\371\242\345\275\012", "\266l\203\200\307t\203ua\214\012", "\266r\226g\322", - "\266\375bscript\316\251\200\042[ ]\331\353\224\225\207\332\305j\255\334\234\222\201\313", + "\266\375bscript\316\251\200\042[ ]\330\353\224\225\207\331\305j\255\334\234\222\201\314", "m\342\205-\334\234\222\201\337\256y\207\360f\342l\223\203i\205\211iz\274\012", - "\271ce\274\357\305ximum \374\230\264\304\334\234\222\201\313", + "\271ce\274\357\305ximum \374\230\264\304\334\234\222\201\314", "\217\345\275\235c\344s\357b\241c\200(\042}\042\232", "\231\204\202\304\273bod\223\362\270ou\202\273head\210\012", - "\256ys\316\344c\337\301\310\226\206\273\265t\207c\226\242\312pu\236\326 (\330\216\232", - "\217f\203ish\235\363\332be\370\200\343\364il\264\334\221c\205v\322", - "dupl\326\224\200\265t; sam\200\311\272p\351s\235tw\326\322", - "\273\311\367\242\340\376\252\302a\342\202\243u\200(\330\216\232", - "m\342\205p\352\042#\341se\331\334\221c\205v\310betwe\212 \042#if ... #\212\334f\042\012", - "\042#\341seif\331\334\221c\205\376f\240\344w\207\355\042#\341se\331\334\221c\205v\322", + "\256ys\316\344c\337\301\310\226\206\273\265t\207c\226\242\313pu\236\332 (\327\216\232", + "\217f\203ish\235\363\331be\370\200\343\364il\264\334\220c\205v\322", + "dupl\332\224\200\265t; sam\200\312\272p\351s\235tw\332\322", + "\273\312\367\242\340\376\252\302a\342\202\243u\200(\327\216\232", + "m\342\205p\352\042#\341se\330\334\220c\205v\310betwe\212 \042#if ... #\212\334f\042\012", + "\042#\341seif\330\334\220c\205\376f\240\344w\207\355\042#\341se\330\334\220c\205v\322", "\374\230\264\304\353\226d\207do\310\242\361\202\270\200\353\224\225\012", - "\273\221s\342\202\373\304\353\224\225\227 \360\216\012", - "c\226\242\275\226g\200\314\327\235\353\224\225\313", - "\273\311\367\201l\223\340\376\252s\203g\352\373(\311%d\232", - "\273\311\367\242\312\252\221f\210\212c\200\311\255\355\303(\311\216\232", - "\330c\226\242\312bo\270 \252\221f\210\212c\200\226\206\355\303(\330\216\232", - "\266\241\214\337\374\230\264\314ci\222\332\372#p\241g\305\012", - "\241\214\337\374\230\264\370\305\202\211\221ad\223\327\274\012", + "\273\220s\342\202\373\304\353\224\225\227 \360\216\012", + "c\226\242\275\226g\200\311\326\235\353\224\225\314", + "\273\312\367\201l\223\340\376\252s\203g\352\373(\312%d\232", + "\273\312\367\242\313\252\220f\210\212c\200\312\255\355\303(\312\216\232", + "\327c\226\242\313bo\270 \252\220f\210\212c\200\226\206\355\303(\327\216\232", + "\266\241\214\337\374\230\264\311ci\222\331\372#p\241g\305\012", + "\241\214\337\374\230\264\370\305\202\211\220ad\223\326\274\012", "\241\214\337\374\230\264\375pp\225\202wa\207\242\212\254\274\012", - "\251\210-\327\235\353\224\255\360\233cl\204\235be\370\200\251\200(\366\227\232", - "\042\335e\267\331\353\224\255\272\266\332\042\366\331\250\313", - "\273\311\360\355\303(\311\216\232", - "#\327\200p\224\365\336\324\231\204\202\362\270 \355\211p\340be\205c \275\333c\365\012", + "\251\210-\326\235\353\224\255\360\233cl\204\235be\370\200\251\200(\366\227\232", + "\042\335e\267\330\353\224\255\272\266\331\042\366\330\250\314", + "\273\312\360\355\303(\312\216\232", + "#\326\200p\224\365\336\324\231\204\202\362\270 \355\211p\340be\205c \275\333c\365\012", "\203pu\202l\203\200\306\371l\201\260(aft\264\375bs\205tu\214s\232", "\246n\325x \210r\255\372\270\200\363\201\316\255\266\273c\211l\012", "m\211\370m\235UTF-8 \212\343d\203g\316\255c\225rupt\235\361le: \213\012", - "\273\251\310bo\270 \042\221turn\331\226\206\042\221tur\336<\243ue>\042\012", - "\203\307\222\231\212\202\221tur\336typ\310(\303& n\201-\256y\232", - "\217k\220w\336\250\316\255\242\252\354\202\250 \323", + "\273\251\310bo\270 \042\220turn\330\226\206\042\220tur\336<\243ue>\042\012", + "\203\307\222\231\212\202\220tur\336typ\310(\303& n\201-\256y\232", + "\217k\221w\336\250\316\255\242\252\354\202\250 \323", "c\226\242\325k\200\252\373a\207\252\302a\342\202\243u\200f\255\355\203\233x\235\303p\333met\264\323", - "\251\210-\327\235\353\224\225\207\226\206na\205\376\366\207\367\242\340\376\315e\313", - "\252\273\255\330\367\201l\223b\341\201\260\306 \252s\203g\352au\306\345\332\323", - "\315\200\307fl\326t: \201\200\304\270\200\315\310\272\211\221ad\223a\253gn\235\306 a\220\270\264i\364le\234\325\237\323", - "\220 \315\310\204\200\327\235f\255\277\012", - "\217k\220w\336au\306\345\201\321", - "\217k\220w\336\315\200\216 f\255au\306\345\201\321", - "pu\236\326 \301\310\226\206\344c\337\301\310\367\242\340\376\315\310\323", - "\315\200\301\310\367\242\312\203i\205\211iz\235\323", - "pu\236\326 \366\207\367\242\221tur\336\256y\207\323", - "a\230i\262ou\207\354t; \373ov\210rid\200\272\221qui\221\206\323", - "\374\230\264\304\265t\207do\310\242\345\275 \327i\214\012", + "\251\210-\326\235\353\224\225\207\226\206na\205\376\366\207\367\242\340\376\315e\314", + "\252\273\255\327\367\201l\223b\341\201\260\306 \252s\203g\352au\306\345\331\323", + "\315\200\307fl\332t: \201\200\304\270\200\315\310\272\211\220ad\223a\253gn\235\306 a\221\270\264i\364le\234\325\237\323", + "\221 \315\310\204\200\326\235f\255\277\012", + "\217k\221w\336au\306\345\201\321", + "\217k\221w\336\315\200\216 f\255au\306\345\201\321", + "pu\236\332 \301\310\226\206\344c\337\301\310\367\242\340\376\315\310\323", + "\315\200\301\310\367\242\313\203i\205\211iz\235\323", + "pu\236\332 \366\207\367\242\220tur\336\256y\207\323", + "a\230i\262ou\207\354t; \373ov\210rid\200\272\220qui\220\206\323", + "\374\230\264\304\265t\207do\310\242\345\275 \326i\214\012" #endif }; @@ -248,14 +248,14 @@ static char *fatalmsg[] = { /*110*/ "assertion failed: %s\n", /*111*/ "user error: %s\n", #else - "c\226\242\221a\206from \361le\347", + "c\226\242\220a\206from \361le\347", "c\226\242writ\200\306 \361le\347", "t\254\200ov\210f\344w\347", - "\203\375ff\326i\212\202mem\225y\012", + "\203\375ff\332i\212\202mem\225y\012", "\266\351se\230l\264\203\231ruc\214\321", - "\374m\210\326 ov\210f\344w\316\271ce\274\357capacity\012", + "\374m\210\332 ov\210f\344w\316\271ce\274\357capacity\012", "\343\364il\235scrip\202\271ce\274\207\270\200\305ximum mem\225\223\335\200(%l\206bytes\232", - "\306\371m\226\223\210r\255messag\310\332\201\200l\203\322", + "\306\371m\226\223\210r\255messag\310\331\201\200l\203\322", "\343\233pag\200\305pp\357\361\352\242fo\217d\012", "\266p\224h\347", "\351s\210\237fail\274: \213\012", @@ -303,42 +303,42 @@ static char *warnmsg[] = { /*235*/ "public function lacks forward declaration (symbol \"%s\")\n", /*236*/ "unknown parameter in substitution (incorrect #define pattern)\n" #else - "\277 \272tr\244\224\235\306 %\206\275\333c\365\313", - "\221\327i\237\304\354t/\305cr\371\323", - "\374\230\264\304\265t\207do\310\242\345\275 \327i\214\012", + "\277 \272tr\244\224\235\306 %\206\275\333c\365\314", + "\220\326i\237\304\354t/\305cr\371\323", + "\374\230\264\304\265t\207do\310\242\345\275 \326i\214\012", "\250 \272nev\264\251\274\347", "\250 \272a\253gn\235\252\243u\200\270a\202\272nev\264\251\274\347", - "\221d\217d\226\202\343\233: \354\202\363\332\272z\210o\012", - "\221d\217d\226\202te\231: \354\202\363\332\272n\201-z\210o\012", - "\217k\220w\336#p\241g\305\012", - "\273\362\270 \373\221s\342\202\251\235be\370\200\327i\214\316\370c\357\221p\204s\322", - "\366\227 sho\342\206\221tur\336\252\243u\322", + "\220d\217d\226\202\343\233: \354\202\363\331\272z\210o\012", + "\220d\217d\226\202te\231: \354\202\363\331\272n\201-z\210o\012", + "\217k\221w\336#p\241g\305\012", + "\273\362\270 \373\220s\342\202\251\235be\370\200\326i\214\316\370c\357\220p\204s\322", + "\366\227 sho\342\206\220tur\336\252\243u\322", "po\253\236\200\251\200\304\250 be\370\200\203i\205\211iza\214\347", "po\253\236\223\217\203t\212\233\206a\253gn\234t\012", "po\253\236\223\217\203t\212\233\206bit\362s\200\353a\214\012", "\373mis\345\275\012", - "po\253\236\223\252\042\346\331\303\311wa\207\203t\212\233d\347", - "\363\332\340\207\220 effect\012", + "po\253\236\223\252\042\346\330\303\312wa\207\203t\212\233d\347", + "\363\331\340\207\221 effect\012", "ne\231\235\343m\234t\012", "\344os\200\203d\212\325\214\012", - "\240\206\231y\352pro\306typ\310\251\235\362\270 \350\214\337sem\326\240umn\313", - "\344c\337\330\216 s\340dow\207\252\330a\202\252\314c\274\357lev\341\012", - "\363\332\362\270 \373ov\210rid\200\324appe\204 betwe\212 p\204\212\270ese\313", + "\240\206\231y\352pro\306typ\310\251\235\362\270 \350\214\337sem\332\240umn\314", + "\344c\337\327\216 s\340dow\207\252\327a\202\252\311c\274\357lev\341\012", + "\363\331\362\270 \373ov\210rid\200\324appe\204 betwe\212 p\204\212\270ese\314", "lab\341 nam\200\216 s\340dow\207\373nam\322", - "\374\230\264\304\334git\207\271ce\274\207\241\214\337\374\230\264\314ci\222\201\012", - "\221d\217d\226\202\042\335e\267\042: \311\335\200\272\211way\2071 \323", - "\203\233\365m\203\224\200\303\335\200\372\042\335e\267\331\363\332\323", - "\217\221a\275\254\200\343\233\012", - "\252\330\272a\253gn\235\306 its\341f \323", - "m\225\200\203i\205\211l\210\207\270\355\212um \361\341d\313", + "\374\230\264\304\334git\207\271ce\274\207\241\214\337\374\230\264\311ci\222\201\012", + "\220d\217d\226\202\042\335e\267\042: \312\335\200\272\211way\2071 \323", + "\203\233\365m\203\224\200\303\335\200\372\042\335e\267\330\363\331\323", + "\217\220a\275\254\200\343\233\012", + "\252\327\272a\253gn\235\306 its\341f \323", + "m\225\200\203i\205\211l\210\207\270\355\212um \361\341d\314", "l\212g\270 \304\203i\205\211l\264\271ce\274\207\335\200\304\270\200\212um \361\341d\012", "\203\233x \373mis\345\275 \323", - "\220 i\364le\234\325\237f\255\315\200\216 \372\366\227\316\220 f\211l-back\012", - "\315\200specif\326a\237\332\370w\204\206\233cl\333\237\272ig\220\221d\012", + "\221 i\364le\234\325\237f\255\315\200\216 \372\366\227\316\221 f\211l-back\012", + "\315\200specif\332a\237\331\370w\204\206\233cl\333\237\272ig\221\220d\012", "outpu\202\361\352\272writt\212\316bu\202\362\270 \343\364ac\202\212\343d\357\334s\254\274\012", - "\315\200\330\216 s\340dow\207\252g\344b\337\301\322", - "\273\272\233pr\326\224\235\317) \213\012", - "pu\236\326 \273lack\207\370w\204\206\233cl\333\237\323", - "\217k\220w\336p\333met\264\372\375bs\205tu\237(\203c\225\221c\202#\327\200p\224\365n\232" + "\315\200\327\216 s\340dow\207\252g\344b\337\301\322", + "\273\272\233\311c\224\235\317) \213\012", + "pu\236\332 \273lack\207\370w\204\206\233cl\333\237\323", + "\217k\221w\336p\333met\264\372\375bs\205tu\237(\203c\225\220c\202#\326\200p\224\365n\232" #endif }; diff --git a/sourcepawn/compiler/sc6.c b/sourcepawn/compiler/sc6.c index 2ea5f2d4..73845bf0 100644 --- a/sourcepawn/compiler/sc6.c +++ b/sourcepawn/compiler/sc6.c @@ -18,7 +18,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sc6.c 3579 2006-06-06 13:35:29Z thiadmer $ + * Version: $Id: sc6.c 3633 2006-08-11 16:20:18Z thiadmer $ */ #include #include @@ -670,7 +670,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin) symbol *sym, **nativelist; constvalue *constptr; cell mainaddr; - char nullchar = 0; + char nullchar; /* if compression failed, restart the assembly with compaction switched off */ if (setjmp(compact_err)!=0) { @@ -785,8 +785,9 @@ SC_FUNC int assemble(FILE *fout,FILE *fin) pc_writebin(fout,&hdr,sizeof hdr); /* dump zeros up to the rest of the header, so that we can easily "seek" */ + nullchar='\0'; for (nameofs=sizeof hdr; nameofs #include diff --git a/sourcepawn/compiler/sclist.c b/sourcepawn/compiler/sclist.c index 18c961b0..bf25550d 100644 --- a/sourcepawn/compiler/sclist.c +++ b/sourcepawn/compiler/sclist.c @@ -2,7 +2,9 @@ * * o Name list (aliases) * o Include path list - * o Macro defintions (text substitutions) + * o Macro definitions (text substitutions) + * o Documentation tags and automatic listings + * o Debug strings * * Copyright (c) ITB CompuPhase, 2001-2006 * @@ -22,7 +24,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: sclist.c 3579 2006-06-06 13:35:29Z thiadmer $ + * Version: $Id: sclist.c 3633 2006-08-11 16:20:18Z thiadmer $ */ #include #include diff --git a/sourcepawn/compiler/scmemfil.c b/sourcepawn/compiler/scmemfil.c index 4924e71d..c33d2485 100644 --- a/sourcepawn/compiler/scmemfil.c +++ b/sourcepawn/compiler/scmemfil.c @@ -31,12 +31,15 @@ #include #include "memfile.h" +#if defined FORTIFY + #include +#endif typedef memfile_t MEMFILE; #define tMEMFILE 1 #include "sc.h" -MEMFILE *mfcreate(char *filename) +MEMFILE *mfcreate(const char *filename) { return memfile_creat(filename, 4096); } @@ -64,7 +67,7 @@ int mfdump(MEMFILE *mf) return okay; } -long mflength(MEMFILE *mf) +long mflength(const MEMFILE *mf) { return mf->usedoffs; } @@ -105,7 +108,7 @@ long mfseek(MEMFILE *mf,long offset,int whence) return offset; } -unsigned int mfwrite(MEMFILE *mf,unsigned char *buffer,unsigned int size) +unsigned int mfwrite(MEMFILE *mf,const unsigned char *buffer,unsigned int size) { return (memfile_write(mf, buffer, size) ? size : 0); } @@ -152,7 +155,7 @@ char *mfgets(MEMFILE *mf,char *string,unsigned int size) return string; } -int mfputs(MEMFILE *mf,char *string) +int mfputs(MEMFILE *mf,const char *string) { unsigned int written,length; diff --git a/sourcepawn/compiler/scvars.c b/sourcepawn/compiler/scvars.c index 3efef129..c1419386 100644 --- a/sourcepawn/compiler/scvars.c +++ b/sourcepawn/compiler/scvars.c @@ -20,7 +20,7 @@ * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * - * Version: $Id: scvars.c 3577 2006-06-02 16:22:52Z thiadmer $ + * Version: $Id: scvars.c 3633 2006-08-11 16:20:18Z thiadmer $ */ #include #include /* for _MAX_PATH */ diff --git a/sourcepawn/compiler/svnrev.h b/sourcepawn/compiler/svnrev.h index b0d8a703..3843eb5b 100644 --- a/sourcepawn/compiler/svnrev.h +++ b/sourcepawn/compiler/svnrev.h @@ -1,9 +1,9 @@ #define SMC_VERSION 1 #define SMC_REVISION 0 #define SMC_BUILD 1 -#define SMC_VERSTRING "1.0.1.3599" +#define SMC_VERSTRING "1.0.1.3636" -#define SVN_REV 3599 -#define SVN_REVSTR "3599" -#define SVN_REVDATE "2006-07-05" -#define SVN_REVSTAMP 20060705L +#define SVN_REV 3636 +#define SVN_REVSTR "3636" +#define SVN_REVDATE "2006-08-14" +#define SVN_REVSTAMP 20060814L