Don't fclose() the output in the backend
commitd0fbb7f0ab355fd4e73d1aab215a2aa387b615c3
authorH. Peter Anvin <hpa@zytor.com>
Sun, 12 Jul 2009 19:11:52 +0000 (12 12:11 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 12 Jul 2009 19:15:35 +0000 (12 12:15 -0700)
tree636f3b611b9fc5d630c547c9cbd65028f7ae360b
parent323fcff32bd5d48a690e14a72c980892924c05ab
Don't fclose() the output in the backend

We fopen() the output file in common code but fclose() it in the
backend.  This is bad for a variety of reasons:

1. it is generally an awkward interface to change ownership.
2. we should use ferror() to test for write errors, and that is
   better done in common code.
3. it requires more code.
4. we still need to fclose() in common code during error handing.

Thus, move the fclose() of the output out of the backends, and add
fflush() so we can test ferror() on output.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 files changed:
nasm.c
output/outaout.c
output/outas86.c
output/outbin.c
output/outcoff.c
output/outdbg.c
output/outelf32.c
output/outelf64.c
output/outieee.c
output/outmacho32.c
output/outmacho64.c
output/outrdf.c
output/outrdf2.c