mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-07 17:46:58 +08:00
listing: make it possible to flush the listing output after every line
Add the -Lw option to flush the list file after every line output. This is handy for debugging if nasm hangs. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
4b58ec1b8f
commit
0741eb6004
@ -148,6 +148,8 @@ static void list_cleanup(void)
|
||||
|
||||
static void list_init(const char *fname)
|
||||
{
|
||||
enum file_flags flags = NF_TEXT;
|
||||
|
||||
if (listfp)
|
||||
list_cleanup();
|
||||
|
||||
@ -156,7 +158,10 @@ static void list_init(const char *fname)
|
||||
return;
|
||||
}
|
||||
|
||||
listfp = nasm_open_write(fname, NF_TEXT);
|
||||
if (list_option('w'))
|
||||
flags |= NF_IOLBF;
|
||||
|
||||
listfp = nasm_open_write(fname, flags);
|
||||
if (!listfp) {
|
||||
nasm_nonfatal("unable to open listing file `%s'", fname);
|
||||
return;
|
||||
|
@ -2067,6 +2067,7 @@ static void help(FILE *out)
|
||||
" -Lm show multi-line macro calls with expanded parmeters\n"
|
||||
" -Lp output a list file every pass, in case of errors\n"
|
||||
" -Ls show all single-line macro definitions\n"
|
||||
" -Lw flush the output after every line\n"
|
||||
" -L+ enable all listing options (very verbose!)\n"
|
||||
"\n"
|
||||
" -Oflags... optimize opcodes, immediates and branch offsets\n"
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2018 The NASM Authors - All Rights Reserved
|
||||
* Copyright 1996-2019 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
* the specific copyright holders.
|
||||
*
|
||||
@ -355,8 +355,12 @@ enum file_flags {
|
||||
NF_TEXT = 0x00000001, /* Text file */
|
||||
NF_NONFATAL = 0x00000000, /* Don't die on open failure (default) */
|
||||
NF_FATAL = 0x00000002, /* Die on open failure */
|
||||
NF_FORMAP = 0x00000004 /* Intended to use nasm_map_file() */
|
||||
NF_FORMAP = 0x00000004, /* Intended to use nasm_map_file() */
|
||||
NF_IONBF = 0x00000010, /* Force unbuffered stdio */
|
||||
NF_IOLBF = 0x00000020, /* Force line buffered stdio */
|
||||
NF_IOFBF = 0000000030 /* Force fully buffered stdio */
|
||||
};
|
||||
#define NF_BUF_MASK 0x30
|
||||
|
||||
FILE *nasm_open_read(const char *filename, enum file_flags flags);
|
||||
FILE *nasm_open_write(const char *filename, enum file_flags flags);
|
||||
|
@ -210,6 +210,20 @@ FILE *nasm_open_write(const char *filename, enum file_flags flags)
|
||||
nasm_fatalf(ERR_NOFILE, "unable to open output file: `%s': %s",
|
||||
filename, strerror(errno));
|
||||
|
||||
switch (flags & NF_BUF_MASK) {
|
||||
case NF_IONBF:
|
||||
setvbuf(f, NULL, _IONBF, 0);
|
||||
break;
|
||||
case NF_IOLBF:
|
||||
setvbuf(f, NULL, _IOLBF, 0);
|
||||
break;
|
||||
case NF_IOFBF:
|
||||
setvbuf(f, NULL, _IOFBF, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user