X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=as%2Fz80%2Fasmain.c;h=50ccb2b22e55cee6ccd5279f8a959521134bcd00;hb=249f657e4e40a413e0875886670ac1958a72cdde;hp=a6463ff2059def9af8182ef47eb338bb256831a5;hpb=3e0a6bcb0f1a6f6bbcf9269f536b827f2c885295;p=fw%2Fsdcc diff --git a/as/z80/asmain.c b/as/z80/asmain.c index a6463ff2..50ccb2b2 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -135,7 +135,7 @@ * VOID diag() assubr.c * VOID err() assubr.c * int fprintf() c-library - * int getline() aslex.c + * int as_getline() aslex.c * VOID list() aslist.c * VOID lstsym() aslist.c * VOID minit() ___mch.c @@ -160,6 +160,21 @@ main(int argc, char **argv) register int c, i; struct area *ap; + /* Check to make sure there are the right number of filenames */ + /* before openning any of them */ +#ifdef SDK + inpfil = -2; +#else /* SDK */ + inpfil = -1; +#endif /* SDK */ + for (i=1; i &afn[FILSPC-4]) // truncate filename, if it's too long + p2 = &afn[FILSPC-4]; *p2++ = FSEPX; - if (*p3 == 0) { - if (c == FSEPX) { - p3 = p1; - } else { - p3 = dsft; - } + + // choose a file-extension + if (*p3 == 0) { // extension supplied? + p3 = strrchr (fn, FSEPX); // no: extension in fn? + if (p3) + ++p3; + else + p3 = dsft; // no: default extension } - while ((c = *p3++) != 0) { + + while ((c = *p3++) != 0) { // strncpy if (p2 < &afn[FILSPC-1]) *p2++ = c; } *p2++ = 0; + if ((fp = fopen(afn, wf?"w":"r")) == NULL) { fprintf(stderr, "%s: cannot %s.\n", afn, wf?"create":"open"); asexit(1);