diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 7141c138..bceea381 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -84,7 +84,7 @@ binary.sources += [ 'pawncc.cpp', 'sc1.c', 'sc2.c', - 'sc3.c', + 'sc3.cpp', 'sc4.cpp', 'sc5.cpp', 'sc6.cpp', diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 6a583dab..1a035ee7 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -547,8 +547,8 @@ typedef enum s_optmark { */ int pc_compile(int argc, char **argv); int pc_addconstant(char *name,cell value,int tag); -int pc_addtag(char *name); -int pc_addtag_flags(char *name, int flags); +int pc_addtag(const char *name); +int pc_addtag_flags(const char *name, int flags); int pc_findtag(const char *name); constvalue *pc_tagptr(const char *name); int pc_enablewarning(int number,int enable); diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 2b0e0245..341e0685 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -681,17 +681,19 @@ int pc_findtag(const char *name) #if defined __cplusplus extern "C" #endif -int pc_addtag(char *name) +int pc_addtag(const char *name) { int val; int flags = 0; if (name==NULL) { /* no tagname was given, check for one */ - if (lex(&val,&name)!=tLABEL) { + char *nameptr; + if (lex(&val,&nameptr)!=tLABEL) { lexpush(); return 0; /* untagged */ } /* if */ + name = nameptr; } /* if */ if (isupper(*name)) @@ -700,7 +702,7 @@ int pc_addtag(char *name) return pc_addtag_flags(name, flags); } -int pc_addtag_flags(char *name, int flags) +int pc_addtag_flags(const char *name, int flags) { constvalue *ptr; int last,tag; diff --git a/sourcepawn/compiler/sc3.c b/sourcepawn/compiler/sc3.cpp similarity index 96% rename from sourcepawn/compiler/sc3.c rename to sourcepawn/compiler/sc3.cpp index f7dbb77b..075a1d7a 100644 --- a/sourcepawn/compiler/sc3.c +++ b/sourcepawn/compiler/sc3.cpp @@ -35,7 +35,7 @@ static int skim(int *opstr,void (*testfunc)(int),int dropval,int endval, int (*hier)(value*),value *lval); static void dropout(int lvalue,void (*testfunc)(int val),int exit1,value *lval); static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, - char *forcetag,int chkbitwise); + const char *forcetag,int chkbitwise); static int plnge1(int (*hier)(value *lval),value *lval); static void plnge2(void (*oper)(void), int (*hier)(value *lval), @@ -116,13 +116,17 @@ static int nextop(int *opidx,int *list) SC_FUNC int check_userop(void (*oper)(void),int tag1,int tag2,int numparam, value *lval,int *resulttag) { -static char *binoperstr[] = { "*", "/", "%", "+", "-", "", "", "", - "", "", "", "<=", ">=", "<", ">", "==", "!=" }; -static int binoper_savepri[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, - TRUE, TRUE, TRUE, TRUE, FALSE, FALSE }; -static char *unoperstr[] = { "!", "-", "++", "--" }; -static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; + static const char *binoperstr[] = { + "*", "/", "%", "+", "-", "", "", "", + "", "", "", "<=", ">=", "<", ">", "==", "!=" + }; + static int binoper_savepri[] = { FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, + TRUE, TRUE, TRUE, TRUE, FALSE, FALSE + }; + static const char *unoperstr[] = { "!", "-", "++", "--" }; + static void (*unopers[])(void) = { lneg, neg, user_inc, user_dec }; + char opername[4] = "", symbolname[sNAMEMAX+1]; int i,swapparams,savepri,savealt; int paramspassed; @@ -719,7 +723,7 @@ static void checkfunction(value *lval) * Plunge to a lower level */ static int plnge(int *opstr,int opoff,int (*hier)(value *lval),value *lval, - char *forcetag,int chkbitwise) + const char *forcetag,int chkbitwise) { int lvalue,opidx; int count; @@ -862,10 +866,10 @@ static void plnge2(void (*oper)(void), checkfunction(lval1); checkfunction(lval2); if (lval1->ident==iARRAY || lval1->ident==iREFARRAY) { - char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-"; + const char *ptr=(lval1->sym!=NULL) ? lval1->sym->name : "-unknown-"; error(33,ptr); /* array must be indexed */ } else if (lval2->ident==iARRAY || lval2->ident==iREFARRAY) { - char *ptr=(lval2->sym!=NULL) ? lval2->sym->name : "-unknown-"; + const char *ptr=(lval2->sym!=NULL) ? lval2->sym->name : "-unknown-"; error(33,ptr); /* array must be indexed */ } /* if */ /* ??? ^^^ should do same kind of error checking with functions */ @@ -1033,7 +1037,7 @@ SC_FUNC int sc_getstateid(constvalue **automaton,constvalue **state) assert(*automaton!=NULL); *state=state_find(name,fsa); if (*state==NULL) { - char *fsaname=(*automaton)->name; + const char *fsaname=(*automaton)->name; if (*fsaname=='\0') fsaname="
"; error(87,name,fsaname); /* unknown state for automaton */ @@ -2526,7 +2530,7 @@ static int nesting=0; sc_allowproccall=FALSE; /* parameters may not use procedure call syntax */ if ((sym->flags & flgDEPRECATED)!=0) { - char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; + const char *ptr= (sym->documentation!=NULL) ? sym->documentation : ""; error(234,sym->name,ptr); /* deprecated (probably a native function) */ } /* if */ @@ -2557,10 +2561,9 @@ static int nesting=0; do { if (!pending_this && matchtoken('.')) { namedparams=TRUE; - if (needtoken(tSYMBOL)) - tokeninfo(&lexval,&lexstr); - else - lexstr=""; + if (!needtoken(tSYMBOL)) + break; + tokeninfo(&lexval,&lexstr); argpos=findnamedarg(arg,lexstr); if (argpos<0) { error(17,lexstr); /* undefined symbol */