1
0
mirror of https://github.com/pfusik/xasm.git synced 2024-06-07 11:29:32 +00:00

Allow stdout for the listing and label table.

This commit is contained in:
Piotr Fusik 2022-12-08 09:27:19 +01:00
parent 83d2f8ff1d
commit 30c96357bc
2 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,6 @@
// xasm 3.2.0 by Piotr Fusik <fox@scene.pl> // xasm 3.2.0 by Piotr Fusik <fox@scene.pl>
// http://xasm.atari.org // http://xasm.atari.org
// Can be compiled with DMD v2.097.0. // Can be compiled with DMD v2.101.0.
// Poetic License: // Poetic License:
// //
@ -1085,6 +1085,8 @@ File openInputFile(string filename) {
} }
File openOutputFile(string filename, string msg) { File openOutputFile(string filename, string msg) {
if (filename == "-")
return stdout;
if (!getOption('q')) if (!getOption('q'))
messageStream.writeln(msg); messageStream.writeln(msg);
try { try {
@ -1184,11 +1186,8 @@ void objectByte(ubyte b) {
} else { } else {
assert(pass2); assert(pass2);
if (!optionObject) return; if (!optionObject) return;
if (!objectStream.isOpen) { if (!objectStream.isOpen)
objectStream = objectFilename == "-" objectStream = openOutputFile(objectFilename, "Writing object file...");
? stdout
: openOutputFile(objectFilename, "Writing object file...");
}
try { try {
objectStream.write(cast(char) b); objectStream.write(cast(char) b);
} catch (Exception e) { } catch (Exception e) {
@ -3007,8 +3006,10 @@ int main(string[] args) {
core.stdc.stdio.remove(toStringz(objectFilename)); core.stdc.stdio.remove(toStringz(objectFilename));
} }
} }
listingStream.close(); if (listingStream != stdout)
objectStream.close(); listingStream.close();
if (objectStream != stdout)
objectStream.close();
if (exitCode <= 1) { if (exitCode <= 1) {
if (!getOption('q')) { if (!getOption('q')) {
messageStream.writefln("%d lines of source assembled", totalLines); messageStream.writefln("%d lines of source assembled", totalLines);

View File

@ -38,6 +38,7 @@ The listing file should exclude included files.
*-l* '[LISTING_FILE]':: *-l* '[LISTING_FILE]'::
Generates a listing file. Generates a listing file.
Using '-' as 'LISTING_FILE' makes *xasm* write to standard output.
If 'LISTING_FILE' is omitted, the listing filename If 'LISTING_FILE' is omitted, the listing filename
is 'SOURCE_FILE' with the extension changed to `.lst`. is 'SOURCE_FILE' with the extension changed to `.lst`.
@ -47,7 +48,7 @@ First line of the rule lists 'OBJECT_FILE' as the target of the rule
and all source files (including the ones specified with `icl` and `ins`) as dependencies. and all source files (including the ones specified with `icl` and `ins`) as dependencies.
The second line contains the command line with 'OBJECT_FILE' The second line contains the command line with 'OBJECT_FILE'
replaced by the *make* macro `$@` and 'SOURCE_FILE' replaced by the macro `$<`. replaced by the *make* macro `$@` and 'SOURCE_FILE' replaced by the macro `$<`.
Dollars in the command line are doubled. Dollar signs in the command line are doubled.
Your *make* or shell may require further escaping. Your *make* or shell may require further escaping.
*-o* 'OBJECT_FILE':: *-o* 'OBJECT_FILE'::
@ -64,6 +65,7 @@ Quiet mode. Prevents *xasm* from printing its banner and compilation summary.
*-t* '[LABEL_FILE]':: *-t* '[LABEL_FILE]'::
Generates a label table. Generates a label table.
Using '-' as 'LABEL_FILE' makes *xasm* write to standard output.
If 'LABEL_FILE' is omitted then the table is appended at the end of the listing. If 'LABEL_FILE' is omitted then the table is appended at the end of the listing.
[[new_unlabels]]*-u*:: [[new_unlabels]]*-u*::