Use symbols for fatal errors and bump them by 20 slots.

This commit is contained in:
David Anderson 2014-11-07 17:41:33 -08:00
parent 2c31b99ce3
commit a8796543af
9 changed files with 82 additions and 63 deletions

View File

@ -74,7 +74,7 @@ static const char *prefix[3]={ "error", "fatal error", "warning" };
if (number!=0) { if (number!=0) {
int idx; int idx;
if (number < 160 || (number >= 200 && sc_warnings_are_errors)) if (number < FIRST_FATAL_ERROR || (number >= 200 && sc_warnings_are_errors))
idx = 0; idx = 0;
else if (number < 200) else if (number < 200)
idx = 1; idx = 1;

View File

@ -938,4 +938,23 @@ typedef struct array_info_s
cell *base; /* &litq[startlit] */ cell *base; /* &litq[startlit] */
} array_info_t; } array_info_t;
enum FatalError {
FIRST_FATAL_ERROR = 180,
FATAL_ERROR_READ = FIRST_FATAL_ERROR,
FATAL_ERROR_WRITE,
FATAL_ERROR_ALLOC_OVERFLOW,
FATAL_ERROR_OOM,
FATAL_ERROR_INVALID_INSN,
FATAL_ERROR_INT_OVERFLOW,
FATAL_ERROR_SCRIPT_OVERFLOW,
FATAL_ERROR_OVERWHELMED_BY_BAD,
FATAL_ERROR_NO_CODEPAGE,
FATAL_ERROR_INVALID_PATH,
FATAL_ERROR_ASSERTION_FAILED,
FATAL_ERROR_USER_ERROR,
FATAL_ERRORS_TOTAL
};
#endif /* SC_H_INCLUDED */ #endif /* SC_H_INCLUDED */

View File

@ -218,17 +218,17 @@ int pc_compile(int argc, char *argv[])
sp_Globals = NewHashTable(); sp_Globals = NewHashTable();
if (!sp_Globals) if (!sp_Globals)
error(163); error(FATAL_ERROR_OOM);
/* allocate memory for fixed tables */ /* allocate memory for fixed tables */
inpfname=(char*)malloc(_MAX_PATH); inpfname=(char*)malloc(_MAX_PATH);
if (inpfname==NULL) if (inpfname==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
litq=(cell*)malloc(litmax*sizeof(cell)); litq=(cell*)malloc(litmax*sizeof(cell));
if (litq==NULL) if (litq==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
if (!phopt_init()) if (!phopt_init())
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
setopt(argc,argv,outfname,errfname,incfname,reportname,codepage); setopt(argc,argv,outfname,errfname,incfname,reportname,codepage);
strcpy(binfname,outfname); strcpy(binfname,outfname);
@ -254,7 +254,7 @@ int pc_compile(int argc, char *argv[])
lcl_tabsize=sc_tabsize; lcl_tabsize=sc_tabsize;
#if !defined NO_CODEPAGE #if !defined NO_CODEPAGE
if (!cp_set(codepage)) /* set codepage */ if (!cp_set(codepage)) /* set codepage */
error(168); /* codepage mapping file not found */ error(FATAL_ERROR_NO_CODEPAGE);
#endif #endif
/* optionally create a temporary input file that is a collection of all /* optionally create a temporary input file that is a collection of all
* input files * input files
@ -271,7 +271,7 @@ int pc_compile(int argc, char *argv[])
tname=tempnam(NULL,"pawn"); tname=tempnam(NULL,"pawn");
#elif defined(MACOS) && !defined(__MACH__) #elif defined(MACOS) && !defined(__MACH__)
/* tempnam is not supported for the Macintosh CFM build. */ /* tempnam is not supported for the Macintosh CFM build. */
error(164,get_sourcefile(1)); error(FATAL_ERROR_INVALID_INSN,get_sourcefile(1));
tname=NULL; tname=NULL;
sname=NULL; sname=NULL;
#else #else
@ -287,7 +287,7 @@ int pc_compile(int argc, char *argv[])
pc_closesrc(ftmp); pc_closesrc(ftmp);
remove(tname); remove(tname);
strcpy(inpfname,sname); /* avoid invalid filename */ strcpy(inpfname,sname); /* avoid invalid filename */
error(160,sname); error(FATAL_ERROR_READ,sname);
} /* if */ } /* if */
pc_writesrc(ftmp,(unsigned char*)"#file \""); pc_writesrc(ftmp,(unsigned char*)"#file \"");
pc_writesrc(ftmp,(unsigned char*)sname); pc_writesrc(ftmp,(unsigned char*)sname);
@ -306,11 +306,11 @@ int pc_compile(int argc, char *argv[])
} /* if */ } /* if */
inpf_org=pc_opensrc(inpfname); inpf_org=pc_opensrc(inpfname);
if (inpf_org==NULL) if (inpf_org==NULL)
error(160,inpfname); error(FATAL_ERROR_READ,inpfname);
freading=TRUE; freading=TRUE;
outf=(FILE*)pc_openasm(outfname); /* first write to assembler file (may be temporary) */ outf=(FILE*)pc_openasm(outfname); /* first write to assembler file (may be temporary) */
if (outf==NULL) if (outf==NULL)
error(161,outfname); error(FATAL_ERROR_WRITE,outfname);
setconstants(); /* set predefined constants and tagnames */ setconstants(); /* set predefined constants and tagnames */
for (i=0; i<skipinput; i++) /* skip lines in the input file */ for (i=0; i<skipinput; i++) /* skip lines in the input file */
if (pc_readsrc(inpf_org,pline,sLINEMAX)!=NULL) if (pc_readsrc(inpf_org,pline,sLINEMAX)!=NULL)
@ -366,7 +366,7 @@ int pc_compile(int argc, char *argv[])
plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */ plungefile(incfname,FALSE,TRUE); /* parse "default.inc" */
} else { } else {
if (!plungequalifiedfile(incfname)) /* parse "prefix" include file */ if (!plungequalifiedfile(incfname)) /* parse "prefix" include file */
error(160,incfname); /* cannot read from ... (fatal error) */ error(FATAL_ERROR_READ,incfname);
} /* if */ } /* if */
} /* if */ } /* if */
preprocess(); /* fetch first line */ preprocess(); /* fetch first line */
@ -486,7 +486,7 @@ cleanup:
pc_printf("Total requirements:%8ld bytes\n", (long)code_idx+(long)glb_declared*sizeof(cell)+(long)pc_stksize*sizeof(cell)); pc_printf("Total requirements:%8ld bytes\n", (long)code_idx+(long)glb_declared*sizeof(cell)+(long)pc_stksize*sizeof(cell));
} /* if */ } /* if */
if (flag_exceed) if (flag_exceed)
error(166,pc_amxlimit+pc_amxram); /* this causes a jump back to label "cleanup" */ error(FATAL_ERROR_INT_OVERFLOW,pc_amxlimit+pc_amxram); /* this causes a jump back to label "cleanup" */
} /* if */ } /* if */
#endif #endif
@ -1086,14 +1086,14 @@ static void parserespf(char *filename,char *oname,char *ename,char *pname,
long size; long size;
if ((fp=fopen(filename,"r"))==NULL) if ((fp=fopen(filename,"r"))==NULL)
error(160,filename); /* error reading input file */ error(FATAL_ERROR_READ,filename);
/* load the complete file into memory */ /* load the complete file into memory */
fseek(fp,0L,SEEK_END); fseek(fp,0L,SEEK_END);
size=ftell(fp); size=ftell(fp);
fseek(fp,0L,SEEK_SET); fseek(fp,0L,SEEK_SET);
assert(size<INT_MAX); assert(size<INT_MAX);
if ((string=(char *)malloc((int)size+1))==NULL) if ((string=(char *)malloc((int)size+1))==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
/* fill with zeros; in MS-DOS, fread() may collapse CR/LF pairs to /* fill with zeros; in MS-DOS, fread() may collapse CR/LF pairs to
* a single '\n', so the string size may be smaller than the file * a single '\n', so the string size may be smaller than the file
* size. */ * size. */
@ -1102,7 +1102,7 @@ static void parserespf(char *filename,char *oname,char *ename,char *pname,
fclose(fp); fclose(fp);
/* allocate table for option pointers */ /* allocate table for option pointers */
if ((argv=(char **)malloc(MAX_OPTIONS*sizeof(char*)))==NULL) if ((argv=(char **)malloc(MAX_OPTIONS*sizeof(char*)))==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
/* fill the options table */ /* fill the options table */
ptr=strtok(string," \t\r\n"); ptr=strtok(string," \t\r\n");
for (argc=1; argc<MAX_OPTIONS && ptr!=NULL; argc++) { for (argc=1; argc<MAX_OPTIONS && ptr!=NULL; argc++) {
@ -1111,7 +1111,7 @@ static void parserespf(char *filename,char *oname,char *ename,char *pname,
ptr=strtok(NULL," \t\r\n"); ptr=strtok(NULL," \t\r\n");
} /* for */ } /* for */
if (ptr!=NULL) if (ptr!=NULL)
error(162,"option table"); /* table overflow */ error(FATAL_ERROR_ALLOC_OVERFLOW,"option table");
/* parse the option table */ /* parse the option table */
parseoptions(argc,argv,oname,ename,pname,rname,codepage); parseoptions(argc,argv,oname,ename,pname,rname,codepage);
/* free allocated memory */ /* free allocated memory */
@ -1221,7 +1221,7 @@ static void setconfig(char *root)
# if !defined NO_CODEPAGE # if !defined NO_CODEPAGE
*ptr='\0'; *ptr='\0';
if (!cp_path(path,"codepage")) if (!cp_path(path,"codepage"))
error(169,path); /* codepage path */ error(FATAL_ERROR_INVALID_PATH,path);
# endif /* !NO_CODEPAGE */ # endif /* !NO_CODEPAGE */
/* also copy the root path (for the XML documentation) */ /* also copy the root path (for the XML documentation) */
@ -3160,7 +3160,7 @@ static void parse_old_array_dims(declinfo_t *decl, int flags)
type->size = needsub(&type->idxtag[type->numdim], enumrootp); type->size = needsub(&type->idxtag[type->numdim], enumrootp);
if (type->size > INT_MAX) if (type->size > INT_MAX)
error(165); error(FATAL_ERROR_INT_OVERFLOW);
type->dim[type->numdim++] = type->size; type->dim[type->numdim++] = type->size;
} while (matchtoken('[')); } while (matchtoken('['));
@ -3994,7 +3994,7 @@ static void domethodmap(LayoutSpec spec)
methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * (map->nummethods + 1)); methods = (methodmap_method_t **)realloc(map->methods, sizeof(methodmap_method_t *) * (map->nummethods + 1));
if (!methods) { if (!methods) {
error(163); error(FATAL_ERROR_OOM);
return; return;
} }
map->methods = methods; map->methods = methods;
@ -4521,7 +4521,7 @@ static void decl_enum(int vclass)
enumsym->usage |= uENUMROOT; enumsym->usage |= uENUMROOT;
/* start a new list for the element names */ /* start a new list for the element names */
if ((enumroot=(constvalue*)malloc(sizeof(constvalue)))==NULL) if ((enumroot=(constvalue*)malloc(sizeof(constvalue)))==NULL)
error(163); /* insufficient memory (fatal error) */ error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */
memset(enumroot,0,sizeof(constvalue)); memset(enumroot,0,sizeof(constvalue));
} else { } else {
enumsym=NULL; enumsym=NULL;
@ -4671,7 +4671,7 @@ static void attachstatelist(symbol *sym, int state_id)
constvalue *stateptr; constvalue *stateptr;
if (sym->states==NULL) { if (sym->states==NULL) {
if ((sym->states=(constvalue*)malloc(sizeof(constvalue)))==NULL) if ((sym->states=(constvalue*)malloc(sizeof(constvalue)))==NULL)
error(163); /* insufficient memory (fatal error) */ error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */
memset(sym->states,0,sizeof(constvalue)); memset(sym->states,0,sizeof(constvalue));
} /* if */ } /* if */
/* see whether the id already exists (add new state only if it does not /* see whether the id already exists (add new state only if it does not
@ -5483,7 +5483,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag)
/* redimension the argument list, add the entry iVARARGS */ /* redimension the argument list, add the entry iVARARGS */
sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo));
if (sym->dim.arglist==0) if (sym->dim.arglist==0)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */
sym->dim.arglist[argcnt].ident=iVARARGS; sym->dim.arglist[argcnt].ident=iVARARGS;
sym->dim.arglist[argcnt].hasdefault=FALSE; sym->dim.arglist[argcnt].hasdefault=FALSE;
@ -5492,7 +5492,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag)
sym->dim.arglist[argcnt].numtags=decl.type.numtags; sym->dim.arglist[argcnt].numtags=decl.type.numtags;
sym->dim.arglist[argcnt].tags=(int*)malloc(decl.type.numtags*sizeof decl.type.tags[0]); sym->dim.arglist[argcnt].tags=(int*)malloc(decl.type.numtags*sizeof decl.type.tags[0]);
if (sym->dim.arglist[argcnt].tags==NULL) if (sym->dim.arglist[argcnt].tags==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
memcpy(sym->dim.arglist[argcnt].tags,decl.type.tags,decl.type.numtags*sizeof decl.type.tags[0]); memcpy(sym->dim.arglist[argcnt].tags,decl.type.tags,decl.type.numtags*sizeof decl.type.tags[0]);
} else { } else {
if (argcnt>oldargcnt || sym->dim.arglist[argcnt].ident!=iVARARGS) if (argcnt>oldargcnt || sym->dim.arglist[argcnt].ident!=iVARARGS)
@ -5525,7 +5525,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag)
/* redimension the argument list, add the entry */ /* redimension the argument list, add the entry */
sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo)); sym->dim.arglist=(arginfo*)realloc(sym->dim.arglist,(argcnt+2)*sizeof(arginfo));
if (sym->dim.arglist==0) if (sym->dim.arglist==0)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */ memset(&sym->dim.arglist[argcnt+1],0,sizeof(arginfo)); /* keep the list terminated */
sym->dim.arglist[argcnt]=arg; sym->dim.arglist[argcnt]=arg;
} else { } else {
@ -5684,7 +5684,7 @@ static void doarg(declinfo_t *decl, int offset, int fpublic, int chkshadow, argi
cell val; cell val;
tokeninfo(&val,&name); tokeninfo(&val,&name);
if ((arg->defvalue.size.symname=duplicatestring(name)) == NULL) if ((arg->defvalue.size.symname=duplicatestring(name)) == NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
arg->defvalue.size.level=0; arg->defvalue.size.level=0;
if (size_tag_token==uSIZEOF || size_tag_token==uCOUNTOF) { if (size_tag_token==uSIZEOF || size_tag_token==uCOUNTOF) {
while (matchtoken('[')) { while (matchtoken('[')) {
@ -5709,7 +5709,7 @@ static void doarg(declinfo_t *decl, int offset, int fpublic, int chkshadow, argi
arg->numtags=type->numtags; arg->numtags=type->numtags;
arg->tags=(int*)malloc(type->numtags * sizeof(type->tags[0])); arg->tags=(int*)malloc(type->numtags * sizeof(type->tags[0]));
if (arg->tags==NULL) if (arg->tags==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM); /* insufficient memory */
memcpy(arg->tags, type->tags, type->numtags * sizeof(type->tags[0])); memcpy(arg->tags, type->tags, type->numtags * sizeof(type->tags[0]));
argsym=findloc(decl->name); argsym=findloc(decl->name);
if (argsym!=NULL) { if (argsym!=NULL) {
@ -6458,7 +6458,7 @@ static constvalue *insert_constval(constvalue *prev,constvalue *next,const char
constvalue *cur; constvalue *cur;
if ((cur=(constvalue*)malloc(sizeof(constvalue)))==NULL) if ((cur=(constvalue*)malloc(sizeof(constvalue)))==NULL)
error(163); /* insufficient memory (fatal error) */ error(FATAL_ERROR_OOM); /* insufficient memory (fatal error) */
memset(cur,0,sizeof(constvalue)); memset(cur,0,sizeof(constvalue));
if (name!=NULL) { if (name!=NULL) {
assert(strlen(name)<=sNAMEMAX); assert(strlen(name)<=sNAMEMAX);
@ -7758,7 +7758,7 @@ static void addwhile(int *ptr)
ptr[wqLOOP]=getlabel(); ptr[wqLOOP]=getlabel();
ptr[wqEXIT]=getlabel(); ptr[wqEXIT]=getlabel();
if (wqptr>=(wq+wqTABSZ-wqSIZE)) if (wqptr>=(wq+wqTABSZ-wqSIZE))
error(162,"loop table"); /* loop table overflow (too many active loops)*/ error(FATAL_ERROR_ALLOC_OVERFLOW,"loop table"); /* loop table overflow (too many active loops)*/
k=0; k=0;
while (k<wqSIZE){ /* copy "ptr" to while queue table */ while (k<wqSIZE){ /* copy "ptr" to while queue table */
*wqptr=*ptr; *wqptr=*ptr;

View File

@ -96,7 +96,7 @@ void pushstk(stkitem val)
assert(newsize>stktop); assert(newsize>stktop);
newstack=(stkitem*)malloc(newsize*sizeof(stkitem)); newstack=(stkitem*)malloc(newsize*sizeof(stkitem));
if (newstack==NULL) if (newstack==NULL)
error(162,"parser stack"); /* stack overflow (recursive include?) */ error(FATAL_ERROR_ALLOC_OVERFLOW,"parser stack");
/* swap the stacks */ /* swap the stacks */
memcpy(newstack,stack,stkidx*sizeof(stkitem)); memcpy(newstack,stack,stkidx*sizeof(stkitem));
if (stack!=NULL) if (stack!=NULL)
@ -172,7 +172,7 @@ int plungequalifiedfile(char *name)
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(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
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 */
@ -276,7 +276,7 @@ static void doinclude(int silent)
result=plungefile(name,(c!='>'),TRUE); result=plungefile(name,(c!='>'),TRUE);
if (!result && !silent) if (!result && !silent)
error(160,name); /* cannot read from ... (fatal error) */ error(FATAL_ERROR_READ,name);
} }
/* readline /* readline
@ -890,7 +890,7 @@ static int command(void)
ret=CMD_IF; ret=CMD_IF;
assert(iflevel>=0); assert(iflevel>=0);
if (iflevel>=sCOMP_STACK) if (iflevel>=sCOMP_STACK)
error(162,"Conditional compilation stack"); /* table overflow */ error(FATAL_ERROR_ALLOC_OVERFLOW,"Conditional compilation stack");
iflevel++; iflevel++;
if (SKIPPING) if (SKIPPING)
break; /* break out of switch */ break; /* break out of switch */
@ -979,7 +979,7 @@ static int command(void)
free(inpfname); free(inpfname);
inpfname=duplicatestring(pathname); inpfname=duplicatestring(pathname);
if (inpfname==NULL) if (inpfname==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
fline=0; fline=0;
} /* if */ } /* if */
} /* if */ } /* if */
@ -1023,7 +1023,7 @@ static int command(void)
name[i]='\0'; name[i]='\0';
} /* if */ } /* if */
if (!cp_set(name)) if (!cp_set(name))
error(168); /* codepage mapping file not found */ error(FATAL_ERROR_NO_CODEPAGE);
} else if (strcmp(str,"compress")==0) { } else if (strcmp(str,"compress")==0) {
cell val; cell val;
preproc_expr(&val,NULL); preproc_expr(&val,NULL);
@ -1292,7 +1292,7 @@ static int command(void)
/* store matched pattern */ /* store matched pattern */
pattern=(char*)malloc(count+1); pattern=(char*)malloc(count+1);
if (pattern==NULL) if (pattern==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
lptr=start; lptr=start;
count=0; count=0;
while (lptr!=end) { while (lptr!=end) {
@ -1326,7 +1326,7 @@ static int command(void)
/* store matched substitution */ /* store matched substitution */
substitution=(char*)malloc(count+1); /* +1 for '\0' */ substitution=(char*)malloc(count+1); /* +1 for '\0' */
if (substitution==NULL) if (substitution==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
lptr=start; lptr=start;
count=0; count=0;
while (lptr!=end) { while (lptr!=end) {
@ -1542,7 +1542,7 @@ static int substpattern(unsigned char *line,size_t buffersize,char *pattern,char
len=(int)(e-s); len=(int)(e-s);
args[arg]=(unsigned char*)malloc(len+1); args[arg]=(unsigned char*)malloc(len+1);
if (args[arg]==NULL) if (args[arg]==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
strlcpy((char*)args[arg],(char*)s,len+1); strlcpy((char*)args[arg],(char*)s,len+1);
/* character behind the pattern was matched too */ /* character behind the pattern was matched too */
if (*e==*p) { if (*e==*p) {
@ -2469,7 +2469,7 @@ static void chk_grow_litq(void)
litmax+=sDEF_LITMAX; litmax+=sDEF_LITMAX;
p=(cell *)realloc(litq,litmax*sizeof(cell)); p=(cell *)realloc(litq,litmax*sizeof(cell));
if (p==NULL) if (p==NULL)
error(162,"literal table"); /* literal table overflow (fatal error) */ error(FATAL_ERROR_ALLOC_OVERFLOW,"literal table");
litq=p; litq=p;
} /* if */ } /* if */
} }
@ -2662,7 +2662,7 @@ static symbol *add_symbol(symbol *root,symbol *entry,int sort)
root=root->next; root=root->next;
if ((newsym=(symbol *)malloc(sizeof(symbol)))==NULL) { if ((newsym=(symbol *)malloc(sizeof(symbol)))==NULL) {
error(163); error(FATAL_ERROR_OOM);
return NULL; return NULL;
} /* if */ } /* if */
memcpy(newsym,entry,sizeof(symbol)); memcpy(newsym,entry,sizeof(symbol));
@ -3057,7 +3057,7 @@ symbol *addsym(const char *name,cell addr,int ident,int vclass,int tag,int usage
/* create an empty referrer list */ /* create an empty referrer list */
if ((refer=(symbol**)malloc(sizeof(symbol*)))==NULL) { if ((refer=(symbol**)malloc(sizeof(symbol*)))==NULL) {
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
return NULL; return NULL;
} /* if */ } /* if */
*refer=NULL; *refer=NULL;

View File

@ -2212,7 +2212,7 @@ restart:
*/ */
sym=fetchfunc(lastsymbol); sym=fetchfunc(lastsymbol);
if (sym==NULL) if (sym==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
markusage(sym,uREAD); markusage(sym,uREAD);
} else { } else {
return error(12); /* invalid function call */ return error(12); /* invalid function call */
@ -2358,7 +2358,7 @@ static int primary(value *lval)
assert(sc_status==statFIRST); assert(sc_status==statFIRST);
sym=fetchfunc(st); sym=fetchfunc(st);
if (sym==NULL) if (sym==NULL)
error(163); /* insufficient memory */ error(FATAL_ERROR_OOM);
} /* if */ } /* if */
assert(sym!=NULL); assert(sym!=NULL);
assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC); assert(sym->ident==iFUNCTN || sym->ident==iREFFUNC);

View File

@ -365,24 +365,24 @@ static const char *errmsg[] = {
static const char *fatalmsg[] = { static const char *fatalmsg[] = {
#ifdef SCPACK #ifdef SCPACK
/*160*/ "cannot read from file: \"%s\"\n", /*180*/ "cannot read from file: \"%s\"\n",
/*161*/ "cannot write to file: \"%s\"\n", /*181*/ "cannot write to file: \"%s\"\n",
/*162*/ "table overflow: \"%s\"\n", /*182*/ "table overflow: \"%s\"\n",
/* table can be: loop table /* table can be: loop table
* literal table * literal table
* staging buffer * staging buffer
* option table (response file) * option table (response file)
* peephole optimizer table * peephole optimizer table
*/ */
/*163*/ "insufficient memory\n", /*183*/ "insufficient memory\n",
/*164*/ "invalid assembler instruction \"%s\"\n", /*184*/ "invalid assembler instruction \"%s\"\n",
/*165*/ "numeric overflow, exceeding capacity\n", /*185*/ "numeric overflow, exceeding capacity\n",
/*166*/ "compiled script exceeds the maximum memory size (%ld bytes)\n", /*186*/ "compiled script exceeds the maximum memory size (%ld bytes)\n",
/*167*/ "too many error messages on one line\n", /*187*/ "too many error messages on one line\n",
/*168*/ "codepage mapping file not found\n", /*188*/ "codepage mapping file not found\n",
/*169*/ "invalid path: \"%s\"\n", /*189*/ "invalid path: \"%s\"\n",
/*170*/ "assertion failed: %s\n", /*190*/ "assertion failed: %s\n",
/*171*/ "user error: %s\n", /*191*/ "user error: %s\n",
#else #else
"\256\214a\204from \344le:\354", "\256\214a\204from \344le:\354",
"\256writ\200\266 \344le:\354", "\256writ\200\266 \344le:\354",

View File

@ -89,7 +89,7 @@ static short lastfile;
* the error reporting is enabled only in the second pass (and only when * the error reporting is enabled only in the second pass (and only when
* actually producing output). Fatal errors may never be ignored. * actually producing output). Fatal errors may never be ignored.
*/ */
int not_fatal = (number < 160 || number >= 200); int not_fatal = (number < FIRST_FATAL_ERROR || number >= 200);
if (errflag && not_fatal) if (errflag && not_fatal)
return 0; return 0;
if (sc_status != statWRITE && not_fatal) { if (sc_status != statWRITE && not_fatal) {
@ -105,13 +105,13 @@ static short lastfile;
return 0; return 0;
} /* if */ } /* if */
if (number<160){ if (number<FIRST_FATAL_ERROR) {
msg=errmsg[number-1]; msg=errmsg[number-1];
pre=prefix[0]; pre=prefix[0];
errflag=TRUE; /* set errflag (skip rest of erroneous expression) */ errflag=TRUE; /* set errflag (skip rest of erroneous expression) */
errnum++; errnum++;
} else if (number<200){ } else if (number<200){
msg=fatalmsg[number-160]; msg=fatalmsg[number-FIRST_FATAL_ERROR];
pre=prefix[1]; pre=prefix[1];
errnum++; /* a fatal error also counts as an error */ errnum++; /* a fatal error also counts as an error */
} else { } else {
@ -154,7 +154,7 @@ static short lastfile;
} /* if */ } /* if */
va_end(argptr); va_end(argptr);
if ((number>=160 && number<200) || errnum>25){ if ((number>=FIRST_FATAL_ERROR && number<200) || errnum>25){
if (strlen(errfname)==0) { if (strlen(errfname)==0) {
va_start(argptr,number); va_start(argptr,number);
pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr); pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr);
@ -175,7 +175,7 @@ static short lastfile;
if (!is_warning) if (!is_warning)
errorcount++; errorcount++;
if (errorcount>=3) if (errorcount>=3)
error(167); /* too many error/warning messages on one line */ error(FATAL_ERROR_OVERWHELMED_BY_BAD);
return 0; return 0;
} }

View File

@ -920,12 +920,12 @@ static void splat_to_binary(const char *binfname, void *bytes, size_t size)
// Note: error 161 will setjmp(), which skips destructors :( // Note: error 161 will setjmp(), which skips destructors :(
FILE *fp = fopen(binfname, "wb"); FILE *fp = fopen(binfname, "wb");
if (!fp) { if (!fp) {
error(161, binfname); error(FATAL_ERROR_WRITE, binfname);
return; return;
} }
if (fwrite(bytes, 1, size, fp) != size) { if (fwrite(bytes, 1, size, fp) != size) {
fclose(fp); fclose(fp);
error(161, binfname); error(FATAL_ERROR_WRITE, binfname);
return; return;
} }
fclose(fp); fclose(fp);

View File

@ -95,14 +95,14 @@ static void grow_stgbuffer(char **buffer, int *curmax, int requiredsize)
* over a few kBytes, there is probably a run-away expression * over a few kBytes, there is probably a run-away expression
*/ */
if (requiredsize>sSTG_MAX) if (requiredsize>sSTG_MAX)
error(163); /* staging buffer overflow (fatal error) */ error(FATAL_ERROR_OOM);
*curmax=requiredsize+sSTG_GROW; *curmax=requiredsize+sSTG_GROW;
if (*buffer!=NULL) if (*buffer!=NULL)
p=(char *)realloc(*buffer,*curmax*sizeof(char)); p=(char *)realloc(*buffer,*curmax*sizeof(char));
else else
p=(char *)malloc(*curmax*sizeof(char)); p=(char *)malloc(*curmax*sizeof(char));
if (p==NULL) if (p==NULL)
error(163); /* staging buffer overflow (fatal error) */ error(FATAL_ERROR_OOM);
*buffer=p; *buffer=p;
if (clear) if (clear)
**buffer='\0'; **buffer='\0';