diff --git a/Makefile b/Makefile index c188b89..982ca8d 100644 --- a/Makefile +++ b/Makefile @@ -39,3 +39,25 @@ util.o: util.c util.h rad50.o: rad50.c rad50.h dumpobj.o: dumpobj.c rad50.h util.h rad50.o: rad50.c rad50.h + +# Since the only tests we have so far are for crashes, +# just try to assemble. Later, we will need expected/actual tests. + +# Test that all options requiring a value bail out if it's not present. +argtests: macro11 + @ for OPT in -e -d -m -p -o -l -ysl ; do \ + ./macro11 foo.mac $$OPT 2> /dev/null; \ + if (( $$? == 1 )); then echo PASS; else echo FAIL; fi; \ + echo " $$OPT missing value"; \ + ./macro11 foo.mac $$OPT -v 2> /dev/null; \ + if (( $$? == 1 )); then echo PASS; else echo FAIL; fi; \ + echo " $$OPT fol. by option"; \ + done + @ ./macro11 foo.mac $$OPT -x -v 2> /dev/null; \ + if (( $$? == 1 )); then echo PASS; else echo FAIL; fi; \ + echo " -x must be the last option" + +tests: macro11 argtests + @ ACTUAL=`./macro11 tests/test-undef.mac 2>&1`; \ + if [ "tests/test-undef.mac:1: ***ERROR MACRO .TTYOU not found" == "$$ACTUAL" ]; then echo PASS; else echo FAIL; fi; \ + echo " test-undef.mac" diff --git a/assemble.c b/assemble.c index bb9cd42..67f0052 100644 --- a/assemble.c +++ b/assemble.c @@ -226,7 +226,7 @@ static int assemble( if (!pass) { /* This may work better in pass 2 - something in RT-11 monitor needs the symbol to apear to be - defined even if I can't resolve it's value. */ + defined even if I can't resolve its value. */ sym = add_sym(label, 0, SYMBOLFLAG_UNDEFINED, &absolute_section, &symbol_st); } else sym = NULL; @@ -547,10 +547,12 @@ static int assemble( buffer_free(macbuf); } else { strncpy(macfile, label, sizeof(macfile)); - strncat(macfile, ".MAC", sizeof(macfile) - strlen(macfile)); + strncat(macfile, ".MAC", sizeof(macfile) - strlen(macfile) - 1); my_searchenv(macfile, "MCALL", hitfile, sizeof(hitfile)); if (hitfile[0]) macstr = new_file_stream(hitfile); + else + macstr = NULL; } if (macstr != NULL) { diff --git a/assemble_aux.c b/assemble_aux.c index 2457129..dc6b9d0 100644 --- a/assemble_aux.c +++ b/assemble_aux.c @@ -219,6 +219,7 @@ void implicit_gbl( break; case EX_LIT: case EX_SYM: + case EX_TEMP_SYM: // Impossible on this pass return; case EX_ADD: case EX_SUB: diff --git a/dumpobj.c b/dumpobj.c index 221fbe4..8399d6e 100644 --- a/dumpobj.c +++ b/dumpobj.c @@ -598,7 +598,7 @@ void got_isd( char *cp, int len) { - printf("ISD len=%o\n"); + printf("ISD len=%o\n", len); } void got_endmod( diff --git a/listing.c b/listing.c index 0a88292..609494b 100644 --- a/listing.c +++ b/listing.c @@ -60,7 +60,7 @@ void list_source( if (!binline) binline = memcheck(malloc(sizeof(LSTFORMAT) + 16)); - sprintf(binline, "%*s%*d", SIZEOF_MEMBER(LSTFORMAT, flag), "", SIZEOF_MEMBER(LSTFORMAT, line_number), + sprintf(binline, "%*s%*d", (int)SIZEOF_MEMBER(LSTFORMAT, flag), "", (int)SIZEOF_MEMBER(LSTFORMAT, line_number), str->line); } } @@ -87,21 +87,18 @@ static void list_fit( STREAM *str, unsigned addr) { - int len = strlen(binline); size_t col1 = offsetof(LSTFORMAT, source); size_t col2 = offsetof(LSTFORMAT, pc); if (strlen(binline) >= col1) { - int offset = offsetof(LSTFORMAT, pc); - list_flush(); listline[0] = 0; binline[0] = 0; - sprintf(binline, "%*s %6.6o", offsetof(LSTFORMAT, pc), "", addr); + sprintf(binline, "%*s %6.6o", (int)offsetof(LSTFORMAT, pc), "", addr); padto(binline, offsetof(LSTFORMAT, words)); } else if (strlen(binline) <= col2) { - sprintf(binline, "%*s%*d %6.6o", SIZEOF_MEMBER(LSTFORMAT, flag), "", - SIZEOF_MEMBER(LSTFORMAT, line_number), str->line, addr); + sprintf(binline, "%*s%*d %6.6o", (int)SIZEOF_MEMBER(LSTFORMAT, flag), "", + (int)SIZEOF_MEMBER(LSTFORMAT, line_number), str->line, addr); padto(binline, offsetof(LSTFORMAT, words)); } } @@ -115,8 +112,8 @@ void list_value( if (dolist()) { /* Print the value and go */ binline[0] = 0; - sprintf(binline, "%*s%*d %6.6o", SIZEOF_MEMBER(LSTFORMAT, flag), "", - SIZEOF_MEMBER(LSTFORMAT, line_number), str->line, word & 0177777); + sprintf(binline, "%*s%*d %6.6o", (int)SIZEOF_MEMBER(LSTFORMAT, flag), "", + (int)SIZEOF_MEMBER(LSTFORMAT, line_number), str->line, word & 0177777); } } diff --git a/macro11.c b/macro11.c index dca93f6..30bf8f7 100644 --- a/macro11.c +++ b/macro11.c @@ -108,7 +108,7 @@ static void print_help( printf("-e enable