Skip to content

Commit

Permalink
Make #pragma option also update builtin constants
Browse files Browse the repository at this point in the history
If you used #pragma option -d3 or #pragma option -Z the corresponding
constants (debug and __compat respectively) were not updated; now the
are.

Fixes #253.
  • Loading branch information
Zeex committed Apr 22, 2018
1 parent 8927443 commit 70da4e1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ static int toggle_option(const char *optptr, int option)
{
switch (*option_value(optptr)) {
case '\0':
option=!option;
option=TRUE;
break;
case '-':
option=FALSE;
Expand Down Expand Up @@ -1064,7 +1064,8 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
if (chdir(ptr)==-1)
; /* silently ignore chdir() errors */
break;
case 'd':
case 'd': {
int debug;
switch (*option_value(ptr)) {
case '0':
sc_debug=0;
Expand All @@ -1083,7 +1084,14 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
default:
about();
} /* switch */
debug=0;
if ((sc_debug & (sCHKBOUNDS | sSYMBOLIC))==(sCHKBOUNDS | sSYMBOLIC))
debug=2;
else if ((sc_debug & sCHKBOUNDS)==sCHKBOUNDS)
debug=1;
add_builtin_constant("debug",debug,sGLOBAL,0);
break;
} /* case */
case 'e':
if (ename)
strlcpy(ename,option_value(ptr),_MAX_PATH); /* set name of error file */
Expand Down Expand Up @@ -1207,9 +1215,16 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam
about();
} /* if */
break;
case 'Z':
case 'Z': {
symbol *sym;
pc_compat=toggle_option(ptr,pc_compat);
sym=findconst("__compat",NULL);
if (sym!=NULL) {
assert(sym!=NULL);
sym->addr=pc_compat;
} /* if */
break;
} /* case */
case '\\': /* use \ instead for escape characters */
sc_ctrlchar='\\';
break;
Expand Down

0 comments on commit 70da4e1

Please sign in to comment.