diff --color -Naur pmars-0.9.4/src/asm.c pmars-patched/src/asm.c --- pmars-0.9.4/src/asm.c 2022-06-27 11:39:33.000000000 -0700 +++ pmars-patched/src/asm.c 2023-03-03 19:27:28.816936753 -0800 @@ -2180,7 +2180,7 @@ break; } buf[i] = 0; - if (buf[i - 1] == '\\' && commentfound == FALSE) { /* line continued */ + if (i > 0 && buf[i - 1] == '\\' && commentfound == FALSE) { /* line continued */ conLine = TRUE; buf[--i] = 0; /* reset */ } else diff --color -Naur pmars-0.9.4/src/cdb.c pmars-patched/src/cdb.c --- pmars-0.9.4/src/cdb.c 2022-06-17 16:25:46.000000000 -0700 +++ pmars-patched/src/cdb.c 2023-03-03 18:01:37.314188011 -0800 @@ -1564,7 +1564,7 @@ (warriorsLeft ? warriorsLeft : 1)); substitute(buf[bi1], "CYCLE", outs, buf[bi2]); SWITCHBI; - sprintf(outs, "%d", round); + sprintf(outs, "%d", round_num); substitute(buf[bi1], "ROUND", outs, buf[bi2]); SWITCHBI; @@ -1875,7 +1875,7 @@ #endif int nFuture, nPast, count, taskHalf = (coreSize <= 10000 ? 7 : 5); - sprintf(outs, roundOfCycle, round, rounds, + sprintf(outs, roundOfCycle, round_num, rounds, (cycle + (warriorsLeft ? warriorsLeft : 1) - 1) / (warriorsLeft ? warriorsLeft : 1)); cdb_fputs(outs, COND); diff --color -Naur pmars-0.9.4/src/clparse.c pmars-patched/src/clparse.c --- pmars-0.9.4/src/clparse.c 2022-06-17 16:28:33.000000000 -0700 +++ pmars-patched/src/clparse.c 2023-03-03 17:55:57.573844265 -0800 @@ -64,7 +64,7 @@ /* externalized strings */ extern char *credits_screen1, *credits_screen2, *credits_screen3, *usage_screen, - *optionsAre, *readingStdin, *readOptionsFromFile, *standardInput, + *optionsAre, *errTooManyOptions, *readingStdin, *readOptionsFromFile, *standardInput, *errorIsLocatedIn, *unknownOption, *badArgumentForSwitch, *optionMustBeInTheRange, *tooManyParameters, *cannotOpenParameterFile, *optRounds, *optEnterDebugger, *optDisabledInServerVersion, *optCoreSize, *optBrief, *optCycles, *optVerboseAssembly, *optProcesses, @@ -111,6 +111,10 @@ static char *describe[] = {"#", "#", "#", " ", "$"}; #define record(pword,pdtype,pstorage,pmin,pmax,pdef,pdescription)\ + if (optI >= OPTNUM) { \ + fprintf(stderr, errTooManyOptions); \ + exit(1); \ + } \ options[optI].word = pword; \ options[optI].dtype = pdtype; \ options[optI].storage = (pointer_t) pstorage; \ @@ -465,7 +469,7 @@ * command line parameters and options * ********************************************************************/ -#define OPTNUM 21 /* don't forget to increase when adding new +#define OPTNUM 22 /* don't forget to increase when adding new * options */ static clp_opt_t options[OPTNUM]; int optI = 0; /* used by record() macro */ diff --color -Naur pmars-0.9.4/src/curdisp.c pmars-patched/src/curdisp.c --- pmars-0.9.4/src/curdisp.c 2000-12-24 04:51:48.000000000 -0800 +++ pmars-patched/src/curdisp.c 2023-03-03 17:58:09.141965557 -0800 @@ -156,7 +156,7 @@ wstandend(corewin); if (!--refreshCounter) { refreshCounter = refreshInterval; - update_statusline(round); + update_statusline(round_num); wrefresh(corewin); } } @@ -278,8 +278,8 @@ } void -update_statusline(round) - int round; +update_statusline(round_num) + int round_num; { switch (warriors) { case 1: @@ -287,12 +287,12 @@ break; case 2: sprintf(statusLine, preStatusLine, warrior[0].tasks, warrior[1].tasks, - cycle >> 1, round, warrior[0].score[0], warrior[0].score[2], + cycle >> 1, round_num, warrior[0].score[0], warrior[0].score[2], warrior[0].score[1]); break; default: sprintf(statusLine, preStatusLine, warriorsLeft, cycle / warriorsLeft, - round); + round_num); } mvwaddstr(corewin2, 0, 0, statusLine); wrefresh(corewin2); @@ -542,7 +542,7 @@ text_display_close() { if (displayLevel) { - update_statusline(round - 1); + update_statusline(round_num - 1); wstandout(corewin); mvwaddstr(corewin, 0, 0, pressAnyKey); wrefresh(corewin); diff --color -Naur pmars-0.9.4/src/global.h pmars-patched/src/global.h --- pmars-0.9.4/src/global.h 2022-07-04 11:55:37.000000000 -0700 +++ pmars-patched/src/global.h 2023-03-03 19:33:38.533020177 -0800 @@ -283,7 +283,7 @@ int instLen; /* Length of instBank */ int offset; /* Offset value specified by 'ORG' or 'END'. * 0 is default */ - short score[MAXWARRIOR * 2 - 1]; + int score[MAXWARRIOR * 2 - 1]; char *name; /* warrior name */ char *version; diff --color -Naur pmars-0.9.4/src/Makefile.clang pmars-patched/src/Makefile.clang --- pmars-0.9.4/src/Makefile.clang 1969-12-31 16:00:00.000000000 -0800 +++ pmars-patched/src/Makefile.clang 2023-03-03 20:05:50.916098839 -0800 @@ -0,0 +1,53 @@ +# makefile for compilation with clang +CC = clang # req. for linux +# Configuration options: +# +# No. Name Incompatible with Description +# (1) -DSERVER 2 disables cdb debugger (koth server +# version) +# (2) -DGRAPHX 1 enables platform specific core +# graphics +# (3) -DKEYPRESS only for curses display on SysV: +# enter cdb upon keypress (use if +# Ctrl-C doesn't work) +# (4) -DEXT94 ICWS'94 + SEQ,SNE,NOP,*,{,} +# (5) -DSMALLMEM 16-bit addresses, less memory +# (6) -DXWINGRAPHX 1 X-Windows graphics (UNIX) +# (7) -DPERMUTATE enables -P switch +# (9) -DRWLIMIT enables read/write limits + +# -- Default options +CFLAGS = -DEXT94 -DPERMUTATE -DRWLIMIT +# -- Use this instead for additional optimizations +# CFLAGS = -O3 -flto -DEXT94 -DPERMUTATE -DRWLIMIT +# -- Use this instead to enable sanitizers +# CFLAGS = -O1 -g -DEXT94 -DPERMUTATE -DRWLIMIT -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer +# LDFLAGS = -fsanitize=address -fsanitize=undefined # enable this one for adsan + +.SUFFIXES: .o .c .c~ .man .doc .6 +MAINFILE = pmars + +HEADER = global.h config.h asm.h sim.h +OBJ1 = pmars.o asm.o eval.o disasm.o cdb.o sim.o pos.o +OBJ2 = clparse.o global.o token.o +OBJ3 = str_eng.o + +all: flags $(MAINFILE) + +flags: + @echo Making $(MAINFILE) with compiler flags $(CFLAGS) + +$(MAINFILE): $(OBJ1) $(OBJ2) $(OBJ3) + +token.o asm.o disasm.o: asm.h + +sim.o cdb.o pos.o disasm.o: sim.h + +sim.o: curdisp.c uidisp.c lnxdisp.c xwindisp.c + +xwindisp.c: xwindisp.h pmarsicn.h + +lnxdisp.c: lnxdisp.h + +clean: + rm -f $(OBJ1) $(OBJ2) $(OBJ3) core \ No newline at end of file diff --color -Naur pmars-0.9.4/src/sim.c pmars-patched/src/sim.c --- pmars-0.9.4/src/sim.c 2022-06-17 16:28:33.000000000 -0700 +++ pmars-patched/src/sim.c 2023-03-03 18:02:37.406257575 -0800 @@ -173,7 +173,7 @@ mem_struct FAR *memory; long cycle; -int round; +int round_num; char alloc_p = 0; /* indicate whether memory has been allocated */ int warriorsLeft; /* number of warriors still left in core */ @@ -328,7 +328,7 @@ #endif display_init(); - round = 1; + round_num = 1; do { /* each round */ #if defined(DOS16) && !defined(SERVER) && !defined(DOSTXTGRAPHX) && !defined(DOSGRXGRAPHX) && !defined(DJGPP) fputc('\r', stdout); /* enable interruption by Ctrl-C */ @@ -1421,13 +1421,13 @@ #ifndef SERVER if (debugState == BREAK) { if (warriorsLeft == 1 && warriors != 1) - sprintf(outs, warriorTerminatedEndOfRound, W - warrior, W->name, round); + sprintf(outs, warriorTerminatedEndOfRound, W - warrior, W->name, round_num); else - sprintf(outs, endOfRound, round); + sprintf(outs, endOfRound, round_num); debugState = cdb(outs); } #endif - } while (++round <= rounds); + } while (++round_num <= rounds); display_close(); #ifdef PERMUTATE diff --color -Naur pmars-0.9.4/src/sim.h pmars-patched/src/sim.h --- pmars-0.9.4/src/sim.h 2000-08-20 06:29:44.000000000 -0700 +++ pmars-patched/src/sim.h 2023-03-03 18:00:16.050097429 -0800 @@ -89,7 +89,7 @@ #define FAR #endif -extern int round; +extern int round_num; extern long cycle; extern ADDR_T progCnt; /* program counter */ extern warrior_struct *W; /* indicate which warrior is running */ diff --color -Naur pmars-0.9.4/src/str_eng.c pmars-patched/src/str_eng.c --- pmars-0.9.4/src/str_eng.c 2022-06-17 16:28:33.000000000 -0700 +++ pmars-patched/src/str_eng.c 2023-03-03 17:24:02.836330936 -0800 @@ -368,6 +368,7 @@ char *optionsAre = "Options:\n"; +char *errTooManyOptions = "Error: Too many options\n Consider increasing OPTNUM in clparse.c\n"; #ifdef VMS char *readingStdin = "[Reading from sys$input until Ctrl-Z or \"$\"]\n"; #else