Port sc5 to C++.

This commit is contained in:
David Anderson 2014-08-22 00:09:28 -07:00
parent 3eb1faa470
commit 9c005d93ed
5 changed files with 8 additions and 8 deletions

View File

@ -86,7 +86,7 @@ binary.sources += [
'sc2.c', 'sc2.c',
'sc3.c', 'sc3.c',
'sc4.c', 'sc4.c',
'sc5.c', 'sc5.cpp',
'sc6.cpp', 'sc6.cpp',
'sc7.cpp', 'sc7.cpp',
'scexpand.cpp', 'scexpand.cpp',

View File

@ -67,7 +67,7 @@ int pc_printf(const char *message,...)
* If the function returns 0, the parser attempts to continue compilation. * If the function returns 0, the parser attempts to continue compilation.
* On a non-zero return value, the parser aborts. * 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" }; static const char *prefix[3]={ "error", "fatal error", "warning" };

View File

@ -564,7 +564,7 @@ const char *type_to_name(int tag);
int pc_printf(const char *message,...); int pc_printf(const char *message,...);
/* error report function */ /* 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 */ /* input from source file */
void *pc_opensrc(char *filename); /* reading only */ void *pc_opensrc(char *filename); /* reading only */

View File

@ -42,7 +42,7 @@ unsigned char errstr_table [][2] = {
}; };
/*-*SCPACK end of pair table, do not change or remove this line */ /*-*SCPACK end of pair table, do not change or remove this line */
static char *errmsg[] = { static const char *errmsg[] = {
#ifdef SCPACK #ifdef SCPACK
/*001*/ "expected token: \"%s\", but found \"%s\"\n", /*001*/ "expected token: \"%s\", but found \"%s\"\n",
/*002*/ "only a single statement (or expression) can follow each \"case\"\n", /*002*/ "only a single statement (or expression) can follow each \"case\"\n",
@ -362,7 +362,7 @@ static char *errmsg[] = {
#endif #endif
}; };
static char *fatalmsg[] = { static const char *fatalmsg[] = {
#ifdef SCPACK #ifdef SCPACK
/*160*/ "cannot read from file: \"%s\"\n", /*160*/ "cannot read from file: \"%s\"\n",
/*161*/ "cannot write to file: \"%s\"\n", /*161*/ "cannot write to file: \"%s\"\n",
@ -398,7 +398,7 @@ static char *fatalmsg[] = {
#endif #endif
}; };
static char *warnmsg[] = { static const char *warnmsg[] = {
#ifdef SCPACK #ifdef SCPACK
/*200*/ "symbol \"%s\" is truncated to %d characters\n", /*200*/ "symbol \"%s\" is truncated to %d characters\n",
/*201*/ "redefinition of constant/macro (symbol \"%s\")\n", /*201*/ "redefinition of constant/macro (symbol \"%s\")\n",

View File

@ -69,10 +69,10 @@ static int sErrLine; /* forced line number for the error message */
*/ */
SC_FUNC int error(int number,...) 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 int lastline,errorcount;
static short lastfile; static short lastfile;
char *msg,*pre; const char *msg,*pre;
va_list argptr; va_list argptr;
// sErrLine is used to temporarily change the line number of reported errors. // sErrLine is used to temporarily change the line number of reported errors.