Port sc2 to C++.
This commit is contained in:
parent
4608050bd2
commit
48d228e2b1
@ -83,7 +83,7 @@ binary.sources += [
|
||||
'memfile.cpp',
|
||||
'pawncc.cpp',
|
||||
'sc1.c',
|
||||
'sc2.c',
|
||||
'sc2.cpp',
|
||||
'sc3.cpp',
|
||||
'sc4.cpp',
|
||||
'sc5.cpp',
|
||||
|
@ -828,7 +828,7 @@ SC_FUNC stringlist *insert_docstring(char *string);
|
||||
SC_FUNC char *get_docstring(int index);
|
||||
SC_FUNC void delete_docstring(int index);
|
||||
SC_FUNC void delete_docstringtable(void);
|
||||
SC_FUNC stringlist *insert_autolist(char *string);
|
||||
SC_FUNC stringlist *insert_autolist(const char *string);
|
||||
SC_FUNC char *get_autolist(int index);
|
||||
SC_FUNC void delete_autolisttable(void);
|
||||
SC_FUNC stringlist *insert_dbgfile(const char *filename);
|
||||
@ -844,7 +844,7 @@ SC_FUNC int cp_path(const char *root,const char *directory);
|
||||
SC_FUNC int cp_set(const char *name);
|
||||
SC_FUNC cell cp_translate(const unsigned char *string,const unsigned char **endptr);
|
||||
SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **endptr);
|
||||
SC_FUNC int scan_utf8(FILE *fp,const char *filename);
|
||||
SC_FUNC int scan_utf8(void *fp,const char *filename);
|
||||
|
||||
/* function prototypes in SCSTATE.C */
|
||||
SC_FUNC constvalue *automaton_add(const char *name);
|
||||
@ -942,9 +942,9 @@ SC_VDECL int sc_require_newdecls; /* only newdecls are allowed */
|
||||
SC_VDECL constvalue sc_automaton_tab; /* automaton table */
|
||||
SC_VDECL constvalue sc_state_tab; /* state table */
|
||||
|
||||
SC_VDECL FILE *inpf; /* file read from (source or include) */
|
||||
SC_VDECL FILE *inpf_org; /* main source file */
|
||||
SC_VDECL FILE *outf; /* file written to */
|
||||
SC_VDECL void *inpf; /* file read from (source or include) */
|
||||
SC_VDECL void *inpf_org; /* main source file */
|
||||
SC_VDECL void *outf; /* file written to */
|
||||
|
||||
SC_VDECL jmp_buf errbuf; /* target of longjmp() on a fatal error */
|
||||
|
||||
|
@ -47,7 +47,7 @@ static cell litchar(const unsigned char **lptr,int flags);
|
||||
static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int automaton,int *cmptag);
|
||||
|
||||
static void substallpatterns(unsigned char *line,int buffersize);
|
||||
static int match(char *st,int end);
|
||||
static int match(const char *st,int end);
|
||||
static int alpha(char c);
|
||||
|
||||
#define SKIPMODE 1 /* bit field in "#if" stack */
|
||||
@ -134,7 +134,8 @@ SC_FUNC void clearstk(void)
|
||||
|
||||
SC_FUNC int plungequalifiedfile(char *name)
|
||||
{
|
||||
static char *extensions[] = { ".inc", ".p", ".pawn" };
|
||||
static const char *extensions[] = { ".inc", ".p", ".pawn" };
|
||||
|
||||
void *fp;
|
||||
char *ext;
|
||||
int ext_idx;
|
||||
@ -1251,7 +1252,7 @@ static int command(void)
|
||||
break;
|
||||
default: {
|
||||
char s2[20];
|
||||
extern char *sc_tokens[];/* forward declaration */
|
||||
extern const char *sc_tokens[];/* forward declaration */
|
||||
if (tok<256)
|
||||
sprintf(s2,"%c",(char)tok);
|
||||
else
|
||||
@ -1482,7 +1483,7 @@ static char *strdel(char *str,size_t len)
|
||||
return str;
|
||||
}
|
||||
|
||||
static char *strins(char *dest,char *src,size_t srclen)
|
||||
static char *strins(char *dest,const char *src,size_t srclen)
|
||||
{
|
||||
size_t destlen=strlen(dest);
|
||||
assert(srclen<=strlen(src));
|
||||
@ -1943,7 +1944,7 @@ SC_FUNC void lexinit(void)
|
||||
sTokenBuffer = &sNormalBuffer;
|
||||
}
|
||||
|
||||
char *sc_tokens[] = {
|
||||
const char *sc_tokens[] = {
|
||||
"*=", "/=", "%=", "+=", "-=", "<<=", ">>>=", ">>=", "&=", "^=", "|=",
|
||||
"||", "&&", "==", "!=", "<=", ">=", "<<", ">>>", ">>", "++", "--",
|
||||
"...", "..", "::",
|
||||
@ -2003,7 +2004,6 @@ static void lexpop()
|
||||
SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
{
|
||||
int i,toolong,newline;
|
||||
char **tokptr;
|
||||
const unsigned char *starttoken;
|
||||
|
||||
if (sTokenBuffer->depth > 0) {
|
||||
@ -2054,7 +2054,7 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
tok->start.col = (int)(lptr - pline);
|
||||
|
||||
i=tFIRST;
|
||||
tokptr=sc_tokens;
|
||||
const char **tokptr=sc_tokens;
|
||||
while (i<=tMIDDLE) { /* match multi-character operators */
|
||||
if (*lptr==**tokptr && match(*tokptr,FALSE)) {
|
||||
tok->id = i;
|
||||
@ -2440,7 +2440,7 @@ SC_FUNC int require_newline(int allow_semi)
|
||||
*
|
||||
* Global references: lptr (altered)
|
||||
*/
|
||||
static int match(char *st,int end)
|
||||
static int match(const char *st,int end)
|
||||
{
|
||||
int k;
|
||||
const unsigned char *ptr;
|
@ -391,7 +391,7 @@ SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **end
|
||||
}
|
||||
#endif
|
||||
|
||||
SC_FUNC int scan_utf8(FILE *fp,const char *filename)
|
||||
SC_FUNC int scan_utf8(void *fp,const char *filename)
|
||||
{
|
||||
#if defined NO_UTF8
|
||||
return 0;
|
||||
|
@ -137,7 +137,7 @@ static int delete_stringpair(stringpair *root,stringpair *item)
|
||||
}
|
||||
|
||||
/* ----- string list functions ----------------------------------- */
|
||||
static stringlist *insert_string(stringlist *root,char *string)
|
||||
static stringlist *insert_string(stringlist *root,const char *string)
|
||||
{
|
||||
stringlist *cur;
|
||||
|
||||
@ -418,7 +418,7 @@ SC_FUNC void delete_docstringtable(void)
|
||||
/* ----- autolisting --------------------------------------------- */
|
||||
static stringlist autolist;
|
||||
|
||||
SC_FUNC stringlist *insert_autolist(char *string)
|
||||
SC_FUNC stringlist *insert_autolist(const char *string)
|
||||
{
|
||||
return insert_string(&autolist,string);
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ SC_VDEFINE int sc_require_newdecls=0; /* Require new-style declarations */
|
||||
SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */
|
||||
SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */
|
||||
|
||||
SC_VDEFINE FILE *inpf = NULL; /* file read from (source or include) */
|
||||
SC_VDEFINE FILE *inpf_org= NULL; /* main source file */
|
||||
SC_VDEFINE FILE *outf = NULL; /* (intermediate) text file written to */
|
||||
SC_VDEFINE void *inpf = NULL; /* file read from (source or include) */
|
||||
SC_VDEFINE void *inpf_org= NULL; /* main source file */
|
||||
SC_VDEFINE void *outf = NULL; /* (intermediate) text file written to */
|
||||
|
||||
SC_VDEFINE jmp_buf errbuf;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user