Compiler: Fix indentation.

This commit is contained in:
Arkshine 2014-08-17 11:14:15 +02:00
parent ca7b0ceadd
commit 27825963f6
5 changed files with 144 additions and 147 deletions

View File

@ -29,7 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__ #if defined __WIN32__ || defined _WIN32 || defined __MSDOS__
#include <conio.h> #include <conio.h>
#include <io.h> #include <io.h>
#define snprintf _snprintf #define snprintf _snprintf
@ -146,7 +146,7 @@ static int *wqptr; /* pointer to next entry */
#if !defined SC_LIGHT #if !defined SC_LIGHT
static char *sc_documentation=NULL;/* main documentation */ static char *sc_documentation=NULL;/* main documentation */
#endif #endif
#if defined __WIN32__ || defined _WIN32 || defined _Windows #if defined __WIN32__ || defined _WIN32 || defined _Windows
static HWND hwndFinish = 0; static HWND hwndFinish = 0;
#endif #endif
@ -510,7 +510,7 @@ int pc_compile(int argc, char *argv[])
char *tname,*sname; char *tname,*sname;
FILE *ftmp,*fsrc; FILE *ftmp,*fsrc;
int fidx; int fidx;
#if defined __WIN32__ || defined _WIN32 #if defined __WIN32__ || defined _WIN32
tname=_tempnam(NULL,"pawn"); tname=_tempnam(NULL,"pawn");
#elif defined __MSDOS__ || defined _Windows #elif defined __MSDOS__ || defined _Windows
tname=tempnam(NULL,"pawn"); tname=tempnam(NULL,"pawn");
@ -590,7 +590,7 @@ int pc_compile(int argc, char *argv[])
#if !defined NO_DEFINE #if !defined NO_DEFINE
delete_substtable(); delete_substtable();
inst_datetime_defines(); inst_datetime_defines();
inst_binary_name(binfname); inst_binary_name(binfname);
#endif #endif
resetglobals(); resetglobals();
sc_ctrlchar=sc_ctrlchar_org; sc_ctrlchar=sc_ctrlchar_org;
@ -655,7 +655,7 @@ int pc_compile(int argc, char *argv[])
#if !defined NO_DEFINE #if !defined NO_DEFINE
delete_substtable(); delete_substtable();
inst_datetime_defines(); inst_datetime_defines();
inst_binary_name(binfname); inst_binary_name(binfname);
#endif #endif
resetglobals(); resetglobals();
sc_ctrlchar=sc_ctrlchar_org; sc_ctrlchar=sc_ctrlchar_org;
@ -777,7 +777,7 @@ cleanup:
if (retcode==0 && verbosity>=2) if (retcode==0 && verbosity>=2)
pc_printf("\nDone.\n"); pc_printf("\nDone.\n");
} /* if */ } /* if */
#if defined __WIN32__ || defined _WIN32 || defined _Windows #if defined __WIN32__ || defined _WIN32 || defined _Windows
if (IsWindow(hwndFinish)) if (IsWindow(hwndFinish))
PostMessage(hwndFinish,RegisterWindowMessage("PawnNotify"),retcode,0L); PostMessage(hwndFinish,RegisterWindowMessage("PawnNotify"),retcode,0L);
#endif #endif
@ -1044,7 +1044,7 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
strncpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */ strncpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */
ename[_MAX_PATH-1]='\0'; ename[_MAX_PATH-1]='\0';
break; break;
#if defined __WIN32__ || defined _WIN32 || defined _Windows #if defined __WIN32__ || defined _WIN32 || defined _Windows
case 'H': case 'H':
hwndFinish=(HWND)atoi(option_value(ptr)); hwndFinish=(HWND)atoi(option_value(ptr));
if (!IsWindow(hwndFinish)) if (!IsWindow(hwndFinish))
@ -1111,10 +1111,10 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
break; break;
case 't': case 't':
i=atoi(option_value(ptr)); i=atoi(option_value(ptr));
if (i>0) if (i>0)
sc_tabsize=i; sc_tabsize=i;
else else
about(); about();
break; break;
case 'v': case 'v':
verbosity= isdigit(*option_value(ptr)) ? atoi(option_value(ptr)) : 2; verbosity= isdigit(*option_value(ptr)) ? atoi(option_value(ptr)) : 2;
@ -1376,7 +1376,7 @@ static void about(void)
pc_printf(" -d2 full debug information and dynamic checking\n"); pc_printf(" -d2 full debug information and dynamic checking\n");
pc_printf(" -d3 full debug information, dynamic checking, no optimization\n"); pc_printf(" -d3 full debug information, dynamic checking, no optimization\n");
pc_printf(" -e<name> set name of error file (quiet compile)\n"); pc_printf(" -e<name> set name of error file (quiet compile)\n");
#if defined __WIN32__ || defined _WIN32 || defined _Windows #if defined __WIN32__ || defined _WIN32 || defined _Windows
pc_printf(" -H<hwnd> window handle to send a notification message on finish\n"); pc_printf(" -H<hwnd> window handle to send a notification message on finish\n");
#endif #endif
pc_printf(" -i<name> path for include files\n"); pc_printf(" -i<name> path for include files\n");
@ -1398,7 +1398,7 @@ static void about(void)
pc_printf(" -([+/-] require parantheses for function invocation (default=%c)\n", optproccall ? '-' : '+'); pc_printf(" -([+/-] require parantheses for function invocation (default=%c)\n", optproccall ? '-' : '+');
pc_printf(" sym=val define constant \"sym\" with value \"val\"\n"); pc_printf(" sym=val define constant \"sym\" with value \"val\"\n");
pc_printf(" sym= define constant \"sym\" with value 0\n"); pc_printf(" sym= define constant \"sym\" with value 0\n");
#if defined __WIN32__ || defined _WIN32 || defined _Windows || defined __MSDOS__ #if defined __WIN32__ || defined _WIN32 || defined _Windows || defined __MSDOS__
pc_printf("\nOptions may start with a dash or a slash; the options \"-d0\" and \"/d0\" are\n"); pc_printf("\nOptions may start with a dash or a slash; the options \"-d0\" and \"/d0\" are\n");
pc_printf("equivalent.\n"); pc_printf("equivalent.\n");
#endif #endif
@ -1994,10 +1994,10 @@ static int declloc(int fstatic)
/* Although valid, a local variable whose name is equal to that /* Although valid, a local variable whose name is equal to that
* of a global variable or to that of a local variable at a lower * of a global variable or to that of a local variable at a lower
* level might indicate a bug. * level might indicate a bug.
* NOTE - don't bother with the error if there's no valid function! * NOTE - don't bother with the error if there's no valid function!
*/ */
if (((sym=findloc(name))!=NULL && sym->compound!=nestlevel) || findglb(name)!=NULL) if (((sym=findloc(name))!=NULL && sym->compound!=nestlevel) || findglb(name)!=NULL)
if (curfunc!=NULL && (curfunc->usage & uNATIVE)) if (curfunc!=NULL && (curfunc->usage & uNATIVE))
error(219,name); /* variable shadows another symbol */ error(219,name); /* variable shadows another symbol */
while (matchtoken('[')){ while (matchtoken('[')){
ident=iARRAY; ident=iARRAY;
@ -2250,7 +2250,7 @@ static void initials(int ident,int tag,cell *size,int dim[],int numdim,
err++; err++;
} /* if */ } /* if */
} /* for */ } /* for */
if (numdim>1 && dim[numdim-1]==0 && !errorfound && err==0) { if (numdim>1 && dim[numdim-1]==0 && !errorfound && err==0) {
/* also look whether, by any chance, all "counted" final dimensions are /* also look whether, by any chance, all "counted" final dimensions are
* the same value; if so, we can store this * the same value; if so, we can store this
*/ */
@ -2803,7 +2803,7 @@ SC_FUNC symbol *fetchfunc(char *name,int tag)
} /* if */ } /* if */
if (pc_deprecate!=NULL) { if (pc_deprecate!=NULL) {
assert(sym!=NULL); assert(sym!=NULL);
sym->flags |= flgDEPRECATED; sym->flags |= flgDEPRECATED;
if (sc_status==statWRITE) { if (sc_status==statWRITE) {
if (sym->documentation!=NULL) { if (sym->documentation!=NULL) {
free(sym->documentation); free(sym->documentation);
@ -3101,7 +3101,7 @@ static void funcstub(int native)
litidx=0; /* clear the literal pool */ litidx=0; /* clear the literal pool */
assert(loctab.next==NULL); /* local symbol table should be empty */ assert(loctab.next==NULL); /* local symbol table should be empty */
tag=pc_addtag(NULL); /* get the tag of the return value */ tag=pc_addtag(NULL); /* get the tag of the return value */
numdim=0; numdim=0;
while (matchtoken('[')) { while (matchtoken('[')) {
/* the function returns an array, get this tag for the index and the array /* the function returns an array, get this tag for the index and the array
@ -3286,7 +3286,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) { if ((sym->usage & (uPROTOTYPED | uREAD))==uREAD && sym->tag!=0) {
int curstatus=sc_status; int curstatus=sc_status;
sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */ sc_status=statWRITE; /* temporarily set status to WRITE, so the warning isn't blocked */
//error(208); //this is silly, it should be caught the first pass //error(208); //this is silly, it should be caught the first pass
sc_status=curstatus; sc_status=curstatus;
sc_reparse=TRUE; /* must add another pass to "initial scan" phase */ sc_reparse=TRUE; /* must add another pass to "initial scan" phase */
} /* if */ } /* if */
@ -3319,8 +3319,8 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
glbdecl=glb_declared; glbdecl=glb_declared;
} /* if */ } /* if */
if ((sym->flags & flgDEPRECATED) != 0 && (sym->usage & uSTOCK) == 0) { if ((sym->flags & flgDEPRECATED) != 0 && (sym->usage & uSTOCK) == 0) {
char *ptr = (sym->documentation != NULL) ? sym->documentation : ""; char *ptr = (sym->documentation != NULL) ? sym->documentation : "";
error(233, symbolname, ptr); /* deprecated (probably a public function) */ error(233, symbolname, ptr); /* deprecated (probably a public function) */
} /* if */ } /* if */
begcseg(); begcseg();
sym->usage|=uDEFINE; /* set the definition flag */ sym->usage|=uDEFINE; /* set the definition flag */
@ -4252,9 +4252,9 @@ static long max_stacksize_recurse(symbol *sourcesym, symbol *sym, long basesize,
if (sym->refer[i]!=NULL) { if (sym->refer[i]!=NULL) {
assert(sym->refer[i]->ident==iFUNCTN); assert(sym->refer[i]->ident==iFUNCTN);
assert((sym->refer[i]->usage & uNATIVE)==0); /* a native function cannot refer to a user-function */ assert((sym->refer[i]->usage & uNATIVE)==0); /* a native function cannot refer to a user-function */
if (sym->refer[i] == sourcesym) if (sym->refer[i] == sourcesym)
return -1; /* recursion detection */ return -1; /* recursion detection */
size = max_stacksize_recurse(sourcesym, sym->refer[i], sym->x.stacksize, pubfuncparams); size = max_stacksize_recurse(sourcesym, sym->refer[i], sym->x.stacksize, pubfuncparams);
if (size<0) if (size<0)
return size; /* recursion was detected, quit */ return size; /* recursion was detected, quit */
if (maxsize<size) if (maxsize<size)
@ -4349,20 +4349,20 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
if ((sym->usage & uDEFINE)==0) { if ((sym->usage & uDEFINE)==0) {
error(19,sym->name); /* not a label: ... */ error(19,sym->name); /* not a label: ... */
} else if ((sym->usage & uREAD)==0) { } else if ((sym->usage & uREAD)==0) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(203,sym->name); /* symbol isn't used: ... */ error(203,sym->name); /* symbol isn't used: ... */
} /* if */ } /* if */
} /* if */ } /* if */
break; break;
case iFUNCTN: case iFUNCTN:
if ((sym->usage & (uDEFINE | uREAD | uNATIVE | uSTOCK))==uDEFINE) { if ((sym->usage & (uDEFINE | uREAD | uNATIVE | uSTOCK))==uDEFINE) {
funcdisplayname(symname,sym->name); funcdisplayname(symname,sym->name);
if (strlen(symname)>0) { if (strlen(symname)>0) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(203,symname); /* symbol isn't used ... (and not native/stock) */ error(203,symname); /* symbol isn't used ... (and not native/stock) */
} /* if */ } /* if */
} /* if */ } /* if */
if ((sym->usage & uPUBLIC)!=0 || strcmp(sym->name,uMAINFUNC)==0) if ((sym->usage & uPUBLIC)!=0 || strcmp(sym->name,uMAINFUNC)==0)
entry=TRUE; /* there is an entry point */ entry=TRUE; /* there is an entry point */
@ -4372,30 +4372,30 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst)
break; break;
case iCONSTEXPR: case iCONSTEXPR:
if (testconst && (sym->usage & uREAD)==0) { if (testconst && (sym->usage & uREAD)==0) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(203,sym->name); /* symbol isn't used: ... */ error(203,sym->name); /* symbol isn't used: ... */
} /* if */ } /* if */
break; break;
default: default:
/* a variable */ /* a variable */
if (sym->parent!=NULL) if (sym->parent!=NULL)
break; /* hierarchical data type */ break; /* hierarchical data type */
if ((sym->usage & (uWRITTEN | uREAD | uSTOCK))==0) { if ((sym->usage & (uWRITTEN | uREAD | uSTOCK))==0) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */ error(203,sym->name,sym->lnumber); /* symbol isn't used (and not stock) */
} else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) { } else if ((sym->usage & (uREAD | uSTOCK | uPUBLIC))==0) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(204,sym->name); /* value assigned to symbol is never used */ error(204,sym->name); /* value assigned to symbol is never used */
#if 0 // ??? not sure whether it is a good idea to force people use "const" #if 0 // ??? not sure whether it is a good idea to force people use "const"
} else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) { } else if ((sym->usage & (uWRITTEN | uPUBLIC | uCONST))==0 && sym->ident==iREFARRAY) {
errorset(sSETFILE,sym->fnumber); errorset(sSETFILE,sym->fnumber);
errorset(sSETLINE,sym->lnumber); errorset(sSETLINE,sym->lnumber);
error(214,sym->name); /* make array argument "const" */ error(214,sym->name); /* make array argument "const" */
#endif #endif
} /* if */ } /* if */
/* also mark the variable (local or global) to the debug information */ /* also mark the variable (local or global) to the debug information */
if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0) if ((sym->usage & (uWRITTEN | uREAD))!=0 && (sym->usage & uNATIVE)==0)
insert_dbgsymbol(sym); insert_dbgsymbol(sym);
@ -4651,13 +4651,13 @@ static void statement(int *lastindent,int allow_decl)
break; break;
case '{': case '{':
tok=fline; tok=fline;
if (!matchtoken('}')) { /* {} is the empty statement */ if (!matchtoken('}')) { /* {} is the empty statement */
compound(tok==fline); compound(tok==fline);
} else { } else {
lastst = tEMPTYBLOCK; lastst = tEMPTYBLOCK;
} }
/* lastst (for "last statement") does not change /* lastst (for "last statement") does not change
you're not my father, don't tell me what to do */ you're not my father, don't tell me what to do */
break; break;
case ';': case ';':
error(36); /* empty statement */ error(36); /* empty statement */
@ -4947,7 +4947,7 @@ static int doif(void)
if (matchtoken(tELSE)==0){ /* if...else ? */ if (matchtoken(tELSE)==0){ /* if...else ? */
setlabel(flab1); /* no, simple if..., print false label */ setlabel(flab1); /* no, simple if..., print false label */
} else { } else {
lastst_true=lastst; lastst_true=lastst;
/* to avoid the "dangling else" error, we want a warning if the "else" /* to avoid the "dangling else" error, we want a warning if the "else"
* has a lower indent than the matching "if" */ * has a lower indent than the matching "if" */
if (stmtindent<ifindent && sc_tabsize>0) if (stmtindent<ifindent && sc_tabsize>0)
@ -4958,12 +4958,12 @@ static int doif(void)
setlabel(flab1); /* print false label */ setlabel(flab1); /* print false label */
statement(NULL,FALSE); /* do "else" clause */ statement(NULL,FALSE); /* do "else" clause */
setlabel(flab2); /* print true label */ setlabel(flab2); /* print true label */
/* if both the "true" branch and the "false" branch ended with the same /* 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 * kind of statement, set the last statement id to that kind, rather than
* to the generic tIF; this allows for better "unreachable code" checking * to the generic tIF; this allows for better "unreachable code" checking
*/ */
if (lastst == lastst_true) if (lastst == lastst_true)
return lastst; return lastst;
} /* endif */ } /* endif */
return tIF; return tIF;
} }
@ -5343,11 +5343,11 @@ static void doreturn(void)
error(78); /* mix "return;" and "return value;" */ error(78); /* mix "return;" and "return value;" */
ident=doexpr(TRUE,FALSE,TRUE,TRUE,&tag,&sym,TRUE); ident=doexpr(TRUE,FALSE,TRUE,TRUE,&tag,&sym,TRUE);
needtoken(tTERM); needtoken(tTERM);
if (ident == iARRAY && sym == NULL) { if (ident == iARRAY && sym == NULL) {
/* returning a literal string is not supported (it must be a variable) */ /* returning a literal string is not supported (it must be a variable) */
error(39); error(39);
ident = iCONSTEXPR; /* avoid handling an "array" case */ ident = iCONSTEXPR; /* avoid handling an "array" case */
} /* if */ } /* if */
/* see if this function already has a sub type (an array attached) */ /* see if this function already has a sub type (an array attached) */
sub=finddepend(curfunc); sub=finddepend(curfunc);
assert(sub==NULL || sub->ident==iREFARRAY); assert(sub==NULL || sub->ident==iREFARRAY);
@ -5546,7 +5546,7 @@ static void dostate(void)
pc_docexpr=TRUE; /* attach expression as a documentation string */ pc_docexpr=TRUE; /* attach expression as a documentation string */
test(flabel,FALSE,FALSE); /* get expression, branch to flabel if false */ test(flabel,FALSE,FALSE); /* get expression, branch to flabel if false */
pc_docexpr=FALSE; pc_docexpr=FALSE;
pc_deprecate=NULL; pc_deprecate=NULL;
needtoken(')'); needtoken(')');
} else { } else {
flabel=-1; flabel=-1;

View File

@ -156,17 +156,17 @@ static char *extensions[] = { ".inc", ".p", ".pawn" };
PUSHSTK_I(fline); PUSHSTK_I(fline);
inpfname=duplicatestring(name);/* set name of include file */ inpfname=duplicatestring(name);/* set name of include file */
if (inpfname==NULL) if (inpfname==NULL)
error(103); /* insufficient memory */ error(103); /* insufficient memory */
inpf=fp; /* set input file pointer to include file */ inpf=fp; /* set input file pointer to include file */
fnumber++; fnumber++;
fline=0; /* set current line number to 0 */ fline=0; /* set current line number to 0 */
fcurrent=fnumber; fcurrent=fnumber;
icomment=0; /* not in a comment */ icomment=0; /* not in a comment */
insert_dbgfile(inpfname); /* attach to debug information */ insert_dbgfile(inpfname); /* attach to debug information */
insert_inputfile(inpfname); /* save for the error system */ insert_inputfile(inpfname); /* save for the error system */
assert(sc_status == statFIRST || strcmp(get_inputfile(fcurrent), inpfname) == 0); assert(sc_status == statFIRST || strcmp(get_inputfile(fcurrent), inpfname) == 0);
setfiledirect(inpfname); /* (optionally) set in the list file */ setfiledirect(inpfname); /* (optionally) set in the list file */
listline=-1; /* force a #line directive when changing the file */ listline=-1; /* force a #line directive when changing the file */
sc_is_utf8=(short)scan_utf8(inpf,name); sc_is_utf8=(short)scan_utf8(inpf,name);
return TRUE; return TRUE;
} }
@ -322,7 +322,7 @@ static void readline(unsigned char *line)
inpf=(FILE *)POPSTK_P(); inpf=(FILE *)POPSTK_P();
insert_dbgfile(inpfname); insert_dbgfile(inpfname);
setfiledirect(inpfname); setfiledirect(inpfname);
assert(sc_status==statFIRST || strcmp(get_inputfile(fcurrent),inpfname)==0); assert(sc_status==statFIRST || strcmp(get_inputfile(fcurrent),inpfname)==0);
listline=-1; /* force a #line directive when changing the file */ listline=-1; /* force a #line directive when changing the file */
} /* if */ } /* if */
@ -596,7 +596,7 @@ static int htoi(cell *val,const unsigned char *curptr)
#if defined __APPLE__ #if defined __APPLE__
static double pow10(double d) static double pow10(double d)
{ {
return pow(10, d); return pow(10, d);
} }
#endif #endif
@ -914,7 +914,7 @@ static int command(void)
if ((ifstack[iflevel-1] & PARSEMODE)==PARSEMODE) { if ((ifstack[iflevel-1] & PARSEMODE)==PARSEMODE) {
/* there has been a parse mode already on this level, so skip the rest */ /* there has been a parse mode already on this level, so skip the rest */
ifstack[iflevel-1] |= (char)SKIPMODE; ifstack[iflevel-1] |= (char)SKIPMODE;
/* if we were already skipping this section, allow expressions with /* if we were already skipping this section, allow expressions with
* undefined symbols; otherwise check the expression to catch errors * undefined symbols; otherwise check the expression to catch errors
*/ */
if (tok==tpELSEIF) { if (tok==tpELSEIF) {
@ -1027,27 +1027,27 @@ static int command(void)
error(27); /* invalid character constant */ error(27); /* invalid character constant */
sc_ctrlchar=(char)val; sc_ctrlchar=(char)val;
} /* if */ } /* if */
} }
else if (strcmp(str, "deprecated") == 0) { else if (strcmp(str, "deprecated") == 0) {
while (*lptr <= ' ' && *lptr != '\0') while (*lptr <= ' ' && *lptr != '\0')
lptr++; lptr++;
len = strlen((char*)lptr); len = strlen((char*)lptr);
pc_deprecate = (char*)malloc(len + 1); pc_deprecate = (char*)malloc(len + 1);
if (pc_deprecate != NULL) if (pc_deprecate != NULL)
{ {
strcpy(pc_deprecate, (char*)lptr); strcpy(pc_deprecate, (char*)lptr);
if (pc_deprecate[len - 1] == '\n') /* remove extra \n as already appended in .scp file */ if (pc_deprecate[len - 1] == '\n') /* remove extra \n as already appended in .scp file */
pc_deprecate[len-1] = '\0'; pc_deprecate[len-1] = '\0';
} }
lptr = (unsigned char*)strchr((char*)lptr, '\0'); /* skip to end (ignore "extra characters on line") */ lptr = (unsigned char*)strchr((char*)lptr, '\0'); /* skip to end (ignore "extra characters on line") */
} else if (strcmp(str,"dynamic")==0) { } else if (strcmp(str,"dynamic")==0) {
preproc_expr(&sc_stksize,NULL); preproc_expr(&sc_stksize,NULL);
} else if ( !strcmp(str,"library") || } else if ( !strcmp(str,"library") ||
!strcmp(str, "reqlib") || !strcmp(str, "reqlib") ||
!strcmp(str, "reqclass") || !strcmp(str, "reqclass") ||
!strcmp(str, "loadlib") || !strcmp(str, "loadlib") ||
!strcmp(str, "explib") || !strcmp(str, "explib") ||
!strcmp(str, "expclass") || !strcmp(str, "expclass") ||
!strcmp(str, "defclasslib") ) { !strcmp(str, "defclasslib") ) {
char name[sNAMEMAX+1],sname[sNAMEMAX+1]; char name[sNAMEMAX+1],sname[sNAMEMAX+1];
const char *prefix = ""; const char *prefix = "";
@ -1087,7 +1087,7 @@ static int command(void)
} else { } else {
sname[0] = '_'; sname[0] = '_';
} }
} }
} /* if */ } /* if */
if (strlen(name)==0) { if (strlen(name)==0) {
curlibrary=NULL; curlibrary=NULL;
@ -1097,20 +1097,20 @@ static int command(void)
/* add the name if it does not yet exist in the table */ /* add the name if it does not yet exist in the table */
char newname[sNAMEMAX+1]; char newname[sNAMEMAX+1];
if (strlen(name) + strlen(prefix) + strlen(sname) <= sNAMEMAX) if (strlen(name) + strlen(prefix) + strlen(sname) <= sNAMEMAX)
{ {
strcpy(newname, prefix); strcpy(newname, prefix);
strcat(newname, name); strcat(newname, name);
strcat(newname, sname); strcat(newname, sname);
if (newname[0] != '?') if (newname[0] != '?')
{ {
if (find_constval(&libname_tab,newname,0)==NULL) if (find_constval(&libname_tab,newname,0)==NULL)
{ {
curlibrary=append_constval(&libname_tab,newname,0,0); curlibrary=append_constval(&libname_tab,newname,0,0);
} }
} else { } else {
exporttag(pc_addtag(newname)); exporttag(pc_addtag(newname));
} }
} }
} /* if */ } /* if */
} else if (strcmp(str,"pack")==0) { } else if (strcmp(str,"pack")==0) {
cell val; cell val;
@ -1154,8 +1154,8 @@ static int command(void)
} else if (strcmp(str,"tabsize")==0) { } else if (strcmp(str,"tabsize")==0) {
cell val; cell val;
preproc_expr(&val,NULL); preproc_expr(&val,NULL);
if (val>0) if (val>0)
sc_tabsize=(int)val; sc_tabsize=(int)val;
} else if (strcmp(str,"align")==0) { } else if (strcmp(str,"align")==0) {
sc_alignnext=TRUE; sc_alignnext=TRUE;
} else if (strcmp(str,"unused")==0) { } else if (strcmp(str,"unused")==0) {
@ -1289,7 +1289,7 @@ static int command(void)
} /* while */ } /* while */
end=lptr; end=lptr;
/* check pattern to match */ /* check pattern to match */
if (!alpha(*start)) { if (!alpha(*start)) {
error(74); /* pattern must start with an alphabetic character */ error(74); /* pattern must start with an alphabetic character */
break; break;
} /* if */ } /* if */
@ -1371,7 +1371,7 @@ static int command(void)
case tpERROR: case tpERROR:
while (*lptr<=' ' && *lptr!='\0') while (*lptr<=' ' && *lptr!='\0')
lptr++; lptr++;
if (!SKIPPING) if (!SKIPPING)
error(111,lptr); /* user error */ error(111,lptr); /* user error */
break; break;
default: default:
@ -1450,7 +1450,7 @@ static const unsigned char *skippgroup(const unsigned char *string)
break; break;
default: default:
assert(0); assert(0);
close='\0'; /* only to avoid a compiler warning */ close='\0'; /* only to avoid a compiler warning */
}/* switch */ }/* switch */
string++; string++;
@ -1531,7 +1531,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
/* store the parameter (overrule any earlier) */ /* store the parameter (overrule any earlier) */
if (args[arg]!=NULL) if (args[arg]!=NULL)
free(args[arg]); free(args[arg]);
else else
argsnum++; argsnum++;
len=(int)(e-s); len=(int)(e-s);
args[arg]=(unsigned char*)malloc(len+1); args[arg]=(unsigned char*)malloc(len+1);
@ -1674,7 +1674,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
while ((*start<=' ' && *start!='\0') || *start=='(') while ((*start<=' ' && *start!='\0') || *start=='(')
start++; start++;
/* skip the symbol behind it */ /* skip the symbol behind it */
while (alphanum(*start)) while (alphanum(*start))
start++; start++;
/* drop back into the main loop */ /* drop back into the main loop */
continue; continue;
@ -1682,7 +1682,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
/* get the prefix (length), look for a matching definition */ /* get the prefix (length), look for a matching definition */
prefixlen=0; prefixlen=0;
end=start; end=start;
while (alphanum(*end)) { while (alphanum(*end)) {
prefixlen++; prefixlen++;
end++; end++;
} /* while */ } /* while */
@ -2447,7 +2447,7 @@ SC_FUNC int get_actual_compound(symbol *sym)
while (sym->parent) while (sym->parent)
sym = sym->parent; sym = sym->parent;
} }
return sym->compound; return sym->compound;
} }
@ -2461,7 +2461,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
* specified nesting level */ * specified nesting level */
while (root->next!=NULL) { while (root->next!=NULL) {
sym=root->next; sym=root->next;
if (get_actual_compound(sym)<level) if (get_actual_compound(sym)<level)
break; break;
switch (sym->ident) { switch (sym->ident) {
case iLABEL: case iLABEL:
@ -2551,7 +2551,7 @@ static symbol *find_symbol(const symbol *root,const char *name,int fnumber,int i
while (ptr!=NULL) { while (ptr!=NULL) {
if (hash==ptr->hash && strcmp(name,ptr->name)==0 if (hash==ptr->hash && strcmp(name,ptr->name)==0
&& (ptr->parent==NULL || includechildren) && (ptr->parent==NULL || includechildren)
&& (fnumber<0 || (ptr->fnumber<0 || ptr->fnumber==fnumber))) && (fnumber<0 || (ptr->fnumber<0 || ptr->fnumber==fnumber)))
return ptr; return ptr;
ptr=ptr->next; ptr=ptr->next;
} /* while */ } /* while */
@ -2620,7 +2620,7 @@ SC_FUNC void markusage(symbol *sym,int usage)
assert(sym!=NULL); assert(sym!=NULL);
sym->usage |= (char)usage; sym->usage |= (char)usage;
if ((usage & uWRITTEN) != 0) if ((usage & uWRITTEN) != 0)
sym->lnumber=fline; sym->lnumber=fline;
/* check if (global) reference must be added to the symbol */ /* check if (global) reference must be added to the symbol */
if ((usage & (uREAD | uWRITTEN))!=0) { if ((usage & (uREAD | uWRITTEN))!=0) {
/* only do this for global symbols */ /* only do this for global symbols */

View File

@ -288,8 +288,7 @@ SC_FUNC int matchtag(int formaltag,int actualtag,int allowcoerce)
* tag is "coerced" to zero * tag is "coerced" to zero
*/ */
if (!allowcoerce || formaltag!=0 || (actualtag & FIXEDTAG)!=0) if (!allowcoerce || formaltag!=0 || (actualtag & FIXEDTAG)!=0)
return FALSE; return FALSE;
} /* if */ } /* if */
return TRUE; return TRUE;
} }
@ -505,9 +504,9 @@ static int plnge_rel(int *opstr,int opoff,int (*hier)(value *lval),value *lval)
error(212); error(212);
if (count>0) { if (count>0) {
relop_prefix(); relop_prefix();
boolresult = lval->boolresult; boolresult = lval->boolresult;
*lval=lval2; /* copy right hand expression of the previous iteration */ *lval=lval2; /* copy right hand expression of the previous iteration */
lval->boolresult = boolresult; lval->boolresult = boolresult;
} /* if */ } /* if */
opidx+=opoff; opidx+=opoff;
plnge2(op1[opidx],hier,lval,&lval2); plnge2(op1[opidx],hier,lval,&lval2);
@ -1040,13 +1039,13 @@ static int hier13(value *lval)
lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */ lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */
else if (lval->ident!=iREFARRAY) else if (lval->ident!=iREFARRAY)
lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */ lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */
if (orig_heap!=decl_heap) { if (orig_heap!=decl_heap) {
diff2=abs(decl_heap-orig_heap); diff2=abs(decl_heap-orig_heap);
decl_heap=orig_heap; decl_heap=orig_heap;
} }
if (diff1==diff2) { if (diff1==diff2) {
decl_heap+=(diff1/2); decl_heap+=(diff1/2);
} else { } else {
decl_heap+=(diff1+diff2); decl_heap+=(diff1+diff2);
} }
return FALSE; /* conditional expression is no lvalue */ return FALSE; /* conditional expression is no lvalue */

View File

@ -21,7 +21,7 @@
*/ */
#include <assert.h> #include <assert.h>
#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__ #if defined __WIN32__ || defined _WIN32 || defined __MSDOS__
#include <io.h> #include <io.h>
#endif #endif
#if defined LINUX || defined __APPLE__ || defined __GNUC__ #if defined LINUX || defined __APPLE__ || defined __GNUC__
@ -187,7 +187,7 @@ SC_FUNC void errorset(int code,int line)
case sEXPRRELEASE: case sEXPRRELEASE:
errstart=-1; /* forget start line number */ errstart=-1; /* forget start line number */
errline=-1; errline=-1;
errfile=-1; errfile=-1;
break; break;
case sSETLINE: case sSETLINE:
errstart=-1; /* force error line number, forget start line */ errstart=-1; /* force error line number, forget start line */

View File

@ -278,23 +278,23 @@ SC_FUNC stringpair *insert_subst(char *pattern,char *substitution,int prefixlen)
adjustindex(*pattern); adjustindex(*pattern);
if (pc_deprecate != NULL) { if (pc_deprecate != NULL) {
assert(cur != NULL); assert(cur != NULL);
cur->flags |= flgDEPRECATED; cur->flags |= flgDEPRECATED;
if (sc_status == statWRITE) { if (sc_status == statWRITE) {
if (cur->documentation != NULL) { if (cur->documentation != NULL) {
free(cur->documentation); free(cur->documentation);
cur->documentation = NULL; cur->documentation = NULL;
} /* if */ } /* if */
cur->documentation = pc_deprecate; cur->documentation = pc_deprecate;
} }
else { else {
free(pc_deprecate); free(pc_deprecate);
} /* if */ } /* if */
pc_deprecate = NULL; pc_deprecate = NULL;
} }
else { else {
cur->flags = 0; cur->flags = 0;
cur->documentation = NULL; cur->documentation = NULL;
} /* if */ } /* if */
return cur; return cur;
} }
@ -309,22 +309,20 @@ SC_FUNC stringpair *find_subst(char *name,int length)
if (item!=NULL) if (item!=NULL)
item=find_stringpair(item,name,length); item=find_stringpair(item,name,length);
if (item && (item->flags & flgDEPRECATED) != 0) if (item && (item->flags & flgDEPRECATED) != 0) {
{ static char macro[128];
static char macro[128]; char *rem, *msg = (item->documentation != NULL) ? item->documentation : "";
char *rem, *msg = (item->documentation != NULL) ? item->documentation : ""; strncpy(macro, item->first, sizeof(macro));
strncpy(macro, item->first, sizeof(macro)); macro[sizeof(macro) - 1] = '\0';
macro[sizeof(macro) - 1] = '\0';
/* If macro contains an opening parentheses and a percent sign, then assume that /* If macro contains an opening parentheses and a percent sign, then assume that
* it takes arguments and remove them from the warning message. * it takes arguments and remove them from the warning message.
*/ */
if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem) if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem) {
{ *rem = '\0';
*rem = '\0'; }
}
error(233, macro, msg); /* deprecated (macro/constant) */ error(233, macro, msg); /* deprecated (macro/constant) */
} }
return item; return item;
} }
@ -475,9 +473,9 @@ SC_FUNC stringlist *insert_dbgline(int linenr)
} }
#ifdef WIN32 #ifdef WIN32
#define LONGCAST long #define LONGCAST long
#else #else
#define LONGCAST cell #define LONGCAST cell
#endif #endif
SC_FUNC stringlist *insert_dbgsymbol(symbol *sym) SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
@ -510,7 +508,7 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
if (sym->ident==iARRAY || sym->ident==iREFARRAY) { if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
symbol *sub; symbol *sub;
#if !defined NDEBUG #if !defined NDEBUG
count = sym->dim.array.level; count = sym->dim.array.level;
#endif #endif
strcat(string," [ "); strcat(string," [ ");
for (sub=sym; sub!=NULL; sub=finddepend(sub)) { for (sub=sym; sub!=NULL; sub=finddepend(sub)) {