mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-18 17:08:20 +00:00
Merge pull request #1 from qu1j0t3/master
Fix clang warnings and a couple of typos.
This commit is contained in:
commit
e35df877f9
22
Makefile
22
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"
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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(
|
||||
|
||||
15
listing.c
15
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
49
macro11.c
49
macro11.c
@ -108,7 +108,7 @@ static void print_help(
|
||||
printf("-e enable <option> (see below)\n");
|
||||
printf("-h print this help\n");
|
||||
printf("-l gives the listing file name (.LST)\n");
|
||||
printf(" -l without file name enables listing to stdout.\n");
|
||||
printf(" -l - enables listing to stdout.\n");
|
||||
printf("-m load RT-11 compatible macro library from which\n");
|
||||
printf(" .MCALLed macros can be found.\n");
|
||||
printf(" Multiple allowed.\n");
|
||||
@ -138,6 +138,10 @@ static void print_help(
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void usage(char *message) {
|
||||
fputs(message, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(
|
||||
int argc,
|
||||
@ -146,9 +150,7 @@ int main(
|
||||
char *fnames[32];
|
||||
int nr_files = 0;
|
||||
FILE *obj = NULL;
|
||||
static char line[1024];
|
||||
TEXT_RLD tr;
|
||||
char *macname = NULL;
|
||||
char *objname = NULL;
|
||||
char *lstname = NULL;
|
||||
int arg;
|
||||
@ -174,10 +176,16 @@ int main(
|
||||
/* Followed by options to enable */
|
||||
/* Since /SHOW and /ENABL option names don't overlap,
|
||||
I consolidate. */
|
||||
if(arg >= argc-1 || !isalpha(*argv[arg+1])) {
|
||||
usage("-e must be followed by an option to enable\n");
|
||||
}
|
||||
upcase(argv[++arg]);
|
||||
enable_tf(argv[arg], 1);
|
||||
} else if (!stricmp(cp, "d")) {
|
||||
/* Followed by an option to disable */
|
||||
if(arg >= argc-1 || !isalpha(*argv[arg+1])) {
|
||||
usage("-d must be followed by an option to disable\n");
|
||||
}
|
||||
upcase(argv[++arg]);
|
||||
enable_tf(argv[arg], 0);
|
||||
} else if (!stricmp(cp, "m")) {
|
||||
@ -185,6 +193,9 @@ int main(
|
||||
/* This option gives the name of an RT-11 compatible
|
||||
macro library from which .MCALLed macros can be
|
||||
found. */
|
||||
if(arg >= argc-1 || *argv[arg+1] == '-') {
|
||||
usage("-m must be followed by a macro library file name\n");
|
||||
}
|
||||
arg++;
|
||||
mlbs[nr_mlbs] = mlb_open(argv[arg]);
|
||||
if (mlbs[nr_mlbs] == NULL) {
|
||||
@ -199,6 +210,10 @@ int main(
|
||||
char *env = getenv("MCALL");
|
||||
char *temp;
|
||||
|
||||
if(arg >= argc-1 || *argv[arg+1] == '-') {
|
||||
usage("-p must be followed by a macro search directory\n");
|
||||
}
|
||||
|
||||
if (env == NULL)
|
||||
env = "";
|
||||
|
||||
@ -212,11 +227,17 @@ int main(
|
||||
}
|
||||
} else if (!stricmp(cp, "o")) {
|
||||
/* The -o option gives the object file name (.OBJ) */
|
||||
if(arg >= argc-1 || *argv[arg+1] == '-') {
|
||||
usage("-o must be followed by the object file name\n");
|
||||
}
|
||||
++arg;
|
||||
objname = argv[arg];
|
||||
} else if (!stricmp(cp, "l")) {
|
||||
/* The option -l gives the listing file name (.LST) */
|
||||
/* -l - enables listing to stdout. */
|
||||
if(arg >= argc-1 || *argv[arg+1] == '-') {
|
||||
usage("-l must be followed by the listing file name (- for standard output)\n");
|
||||
}
|
||||
lstname = argv[++arg];
|
||||
if (strcmp(lstname, "-") == 0)
|
||||
lstfile = stdout;
|
||||
@ -230,25 +251,31 @@ int main(
|
||||
must be the last command line option. */
|
||||
int i;
|
||||
|
||||
if(arg != argc-1) {
|
||||
usage("-x must be the last option\n");
|
||||
}
|
||||
for (i = 0; i < nr_mlbs; i++)
|
||||
mlb_extract(mlbs[i]);
|
||||
return EXIT_SUCCESS;
|
||||
} else if (!stricmp(cp, "ysl")) {
|
||||
/* set symbol_len */
|
||||
char *s = argv[++arg];
|
||||
char *endp;
|
||||
int sl = strtol(s, &endp, 10);
|
||||
if (arg >= argc-1) {
|
||||
usage("-s must be followed by a number\n");
|
||||
} else {
|
||||
char *s = argv[++arg];
|
||||
char *endp;
|
||||
int sl = strtol(s, &endp, 10);
|
||||
|
||||
if (*endp || sl < SYMMAX_DEFAULT || sl > SYMMAX_MAX) {
|
||||
print_help();
|
||||
exit(EXIT_FAILURE);
|
||||
if (*endp || sl < SYMMAX_DEFAULT || sl > SYMMAX_MAX) {
|
||||
usage("-s must be followed by a number\n");
|
||||
}
|
||||
symbol_len = sl;
|
||||
}
|
||||
symbol_len = sl;
|
||||
} else if (!stricmp(cp, "yus")) {
|
||||
/* allow underscores */
|
||||
symbol_allow_underscores = 1;
|
||||
} else {
|
||||
fprintf(stderr, "Unknown argument %s\n", argv[arg]);
|
||||
fprintf(stderr, "Unknown option %s\n", argv[arg]);
|
||||
print_help();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
7
macros.c
7
macros.c
@ -197,7 +197,8 @@ MACRO *defmacro(
|
||||
|
||||
while (!EOL(*cp)) {
|
||||
arg = new_arg();
|
||||
if (arg->locsym = (*cp == '?')) /* special argument flag? */
|
||||
arg->locsym = *cp == '?';
|
||||
if (arg->locsym) /* special argument flag? */
|
||||
cp++;
|
||||
arg->label = get_symbol(cp, &cp, NULL);
|
||||
if (arg->label == NULL) {
|
||||
@ -335,8 +336,8 @@ BUFFER *subst_args(
|
||||
if (issym(*in)) {
|
||||
label = get_symbol(in, &next, NULL);
|
||||
if (label) {
|
||||
if (arg = find_arg(args, label)) {
|
||||
/* An apostrophy may appear before or after the symbol. */
|
||||
if ((arg = find_arg(args, label))) {
|
||||
/* An apostrophe may appear before or after the symbol. */
|
||||
/* In either case, remove it from the expansion. */
|
||||
|
||||
if (in > begin && in[-1] == '\'')
|
||||
|
||||
4
parse.c
4
parse.c
@ -322,7 +322,7 @@ int parse_float(
|
||||
}
|
||||
}
|
||||
|
||||
flt[0] = (unsigned) (sign | (exp << 7) | (ufrac >> 48) & 0x7F);
|
||||
flt[0] = (unsigned) (sign | (exp << 7) | ((ufrac >> 48) & 0x7F));
|
||||
if (size > 1) {
|
||||
flt[1] = (unsigned) ((ufrac >> 32) & 0xffff);
|
||||
if (size > 2) {
|
||||
@ -509,7 +509,7 @@ char *get_symbol(
|
||||
if (symcp[len - 1] == '$') {
|
||||
char *newsym = memcheck(malloc(32)); /* Overkill */
|
||||
|
||||
sprintf(newsym, "%d$%d", strtol(symcp, NULL, 10), lsb);
|
||||
sprintf(newsym, "%ld$%d", strtol(symcp, NULL, 10), lsb);
|
||||
free(symcp);
|
||||
symcp = newsym;
|
||||
if (islocal)
|
||||
|
||||
1
tests/test-undef.mac
Normal file
1
tests/test-undef.mac
Normal file
@ -0,0 +1 @@
|
||||
.MCALL .TTYOUT
|
||||
Loading…
x
Reference in New Issue
Block a user