diff --git a/src/toolsrc/codegen.c b/src/toolsrc/codegen.c index df3c404..1a6cf1b 100755 --- a/src/toolsrc/codegen.c +++ b/src/toolsrc/codegen.c @@ -1,3 +1,4 @@ +#include #include #include #include "tokens.h" @@ -258,10 +259,10 @@ int fixup_new(int tag, int type, int size) #define INIT 16 #define SYSFLAGS 32 static int outflags = 0; -static char *DB = ".BYTE"; -static char *DW = ".WORD"; -static char *DS = ".RES"; -static char LBL = ':'; +static const char *DB = ".BYTE"; +static const char *DW = ".WORD"; +static const char *DS = ".RES"; +static char LBL = (char) ':'; char *supper(char *s) { static char su[80]; @@ -467,7 +468,7 @@ int emit_data(int vartype, int consttype, long constval, int constsize) else if (consttype & STRING_TYPE) { datasize = constsize; - str = (char *)constval; + str = (char *)(uintptr_t)constval; printf("\t%s\t$%02X\n", DB, --constsize); while (constsize-- > 0) { @@ -518,7 +519,7 @@ int emit_data(int vartype, int consttype, long constval, int constsize) } return (datasize); } -void emit_def(char *name, int is_bytecode) +void emit_def(const char *name, int is_bytecode) { if (!(outflags & MODULE)) { diff --git a/src/toolsrc/codegen.h b/src/toolsrc/codegen.h index fb12ca0..d05d11c 100755 --- a/src/toolsrc/codegen.h +++ b/src/toolsrc/codegen.h @@ -12,7 +12,7 @@ void emit_idlocal(char *name, int value); void emit_idglobal(int value, int size, char *name); void emit_idfunc(int tag, int type, char *name); void emit_idconst(char *name, int value); -void emit_def(char *name, int is_bytecode); +void emit_def(const char *name, int is_bytecode); int emit_data(int vartype, int consttype, long constval, int constsize); void emit_codetag(int tag); void emit_const(int cval); diff --git a/src/toolsrc/lex.c b/src/toolsrc/lex.c index 39390c1..b62f999 100755 --- a/src/toolsrc/lex.c +++ b/src/toolsrc/lex.c @@ -8,6 +8,7 @@ * governing permissions and limitations under the License. */ +#include #include #include #include @@ -15,7 +16,7 @@ #include "tokens.h" #include "symbols.h" -char *statement, *tokenstr, *scanpos = ""; +char *statement, *tokenstr, *scanpos = (char*) ""; t_token scantoken, prevtoken; int tokenlen; long constval; @@ -65,7 +66,7 @@ t_token keywords[] = { EOL_TOKEN }; -void parse_error(char *errormsg) +void parse_error(const char *errormsg) { char *error_carrot = statement; @@ -229,7 +230,7 @@ t_token scan(void) * String constant. */ scantoken = STRING_TOKEN; - constval = (long)++scanpos; + constval = (long)(uintptr_t)(++scanpos); while (*scanpos && *scanpos != '\"') { if (*scanpos == '\\') @@ -418,7 +419,7 @@ int next_line(void) if (inputfile == NULL) { // First-time init inputfile = stdin; - filename = ""; + filename = (char*) ""; } if (*scanpos == ';') { @@ -470,8 +471,8 @@ int next_line(void) outer_inputfile = inputfile; outer_filename = filename; outer_lineno = lineno; - new_filename = malloc(tokenlen-1); - strncpy(new_filename, (char*)constval, tokenlen-2); + new_filename = (char*) malloc(tokenlen-1); + strncpy(new_filename, (char*)(uintptr_t)constval, tokenlen-2); new_filename[tokenlen-2] = 0; inputfile = fopen(new_filename, "r"); if (inputfile == NULL) { diff --git a/src/toolsrc/lex.h b/src/toolsrc/lex.h index 5bfbda7..cf12a95 100755 --- a/src/toolsrc/lex.h +++ b/src/toolsrc/lex.h @@ -3,7 +3,7 @@ extern t_token scantoken, prevtoken; extern int tokenlen; extern long constval; extern char inputline[]; -void parse_error(char *errormsg); +void parse_error(const char *errormsg); int next_line(void); void scan_rewind(char *backptr); int scan_lookahead(void);