From 9c005d93edf7aabb79d6779fbc966664a60fc5bd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 22 Aug 2014 00:09:28 -0700 Subject: [PATCH] Port sc5 to C++. --- sourcepawn/compiler/AMBuilder | 2 +- sourcepawn/compiler/libpawnc.cpp | 2 +- sourcepawn/compiler/sc.h | 2 +- sourcepawn/compiler/sc5-in.scp | 6 +++--- sourcepawn/compiler/{sc5.c => sc5.cpp} | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename sourcepawn/compiler/{sc5.c => sc5.cpp} (95%) diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index 0a12ffbd..bc4b93c0 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -86,7 +86,7 @@ binary.sources += [ 'sc2.c', 'sc3.c', 'sc4.c', - 'sc5.c', + 'sc5.cpp', 'sc6.cpp', 'sc7.cpp', 'scexpand.cpp', diff --git a/sourcepawn/compiler/libpawnc.cpp b/sourcepawn/compiler/libpawnc.cpp index 594b3e3f..f3fa6f59 100644 --- a/sourcepawn/compiler/libpawnc.cpp +++ b/sourcepawn/compiler/libpawnc.cpp @@ -67,7 +67,7 @@ int pc_printf(const char *message,...) * If the function returns 0, the parser attempts to continue compilation. * On a non-zero return value, the parser aborts. */ -int pc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr) +int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr) { static const char *prefix[3]={ "error", "fatal error", "warning" }; diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h index 8217ca5d..8894ec61 100644 --- a/sourcepawn/compiler/sc.h +++ b/sourcepawn/compiler/sc.h @@ -564,7 +564,7 @@ const char *type_to_name(int tag); int pc_printf(const char *message,...); /* error report function */ -int pc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr); +int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr); /* input from source file */ void *pc_opensrc(char *filename); /* reading only */ diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 57d289b2..653eb02d 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -42,7 +42,7 @@ unsigned char errstr_table [][2] = { }; /*-*SCPACK end of pair table, do not change or remove this line */ -static char *errmsg[] = { +static const char *errmsg[] = { #ifdef SCPACK /*001*/ "expected token: \"%s\", but found \"%s\"\n", /*002*/ "only a single statement (or expression) can follow each \"case\"\n", @@ -362,7 +362,7 @@ static char *errmsg[] = { #endif }; -static char *fatalmsg[] = { +static const char *fatalmsg[] = { #ifdef SCPACK /*160*/ "cannot read from file: \"%s\"\n", /*161*/ "cannot write to file: \"%s\"\n", @@ -398,7 +398,7 @@ static char *fatalmsg[] = { #endif }; -static char *warnmsg[] = { +static const char *warnmsg[] = { #ifdef SCPACK /*200*/ "symbol \"%s\" is truncated to %d characters\n", /*201*/ "redefinition of constant/macro (symbol \"%s\")\n", diff --git a/sourcepawn/compiler/sc5.c b/sourcepawn/compiler/sc5.cpp similarity index 95% rename from sourcepawn/compiler/sc5.c rename to sourcepawn/compiler/sc5.cpp index 96d5740b..f2444947 100644 --- a/sourcepawn/compiler/sc5.c +++ b/sourcepawn/compiler/sc5.cpp @@ -69,10 +69,10 @@ static int sErrLine; /* forced line number for the error message */ */ SC_FUNC int error(int number,...) { -static char *prefix[3]={ "error", "fatal error", "warning" }; +static const char *prefix[3]={ "error", "fatal error", "warning" }; static int lastline,errorcount; static short lastfile; - char *msg,*pre; + const char *msg,*pre; va_list argptr; // sErrLine is used to temporarily change the line number of reported errors.