From 5a1964ecbd3d7a66c626e2bb5edd7780b99f5aa9 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 19 Dec 2003 15:23:41 +0000 Subject: Fix calls to as_perror() so that the errno system message will be printed. Fix as_perror() so that errno is not corrupted. --- gas/output-file.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'gas/output-file.c') diff --git a/gas/output-file.c b/gas/output-file.c index 304e90447bd..4c376b4dcc4 100644 --- a/gas/output-file.c +++ b/gas/output-file.c @@ -1,5 +1,5 @@ /* output-file.c - Deal with the output file - Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2001 + Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2001, 2003 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -84,10 +84,9 @@ output_file_close (char *filename) #ifndef BFD_ASSEMBLER void -output_file_append (where, length, filename) - char *where ATTRIBUTE_UNUSED; - long length ATTRIBUTE_UNUSED; - char *filename ATTRIBUTE_UNUSED; +output_file_append (char *where ATTRIBUTE_UNUSED, + long length ATTRIBUTE_UNUSED, + char *filename ATTRIBUTE_UNUSED) { abort (); } @@ -98,8 +97,7 @@ output_file_append (where, length, filename) static FILE *stdoutput; void -output_file_create (name) - char *name; +output_file_create (char *name) { if (name[0] == '-' && name[1] == '\0') { @@ -110,17 +108,22 @@ output_file_create (name) stdoutput = fopen (name, FOPEN_WB); if (stdoutput == NULL) { +#ifdef BFD_ASSEMBLER + bfd_set_error (bfd_error_system_call); +#endif as_perror (_("FATAL: can't create %s"), name); exit (EXIT_FAILURE); } } void -output_file_close (filename) - char *filename; +output_file_close (char *filename) { if (EOF == fclose (stdoutput)) { +#ifdef BFD_ASSEMBLER + bfd_set_error (bfd_error_system_call); +#endif as_perror (_("FATAL: can't close %s"), filename); exit (EXIT_FAILURE); } @@ -130,18 +133,17 @@ output_file_close (filename) } void -output_file_append (where, length, filename) - char * where; - long length; - char * filename; +output_file_append (char * where, long length, char * filename) { for (; length; length--, where++) { (void) putc (*where, stdoutput); if (ferror (stdoutput)) - /* if ( EOF == (putc( *where, stdoutput )) ) */ { +#ifdef BFD_ASSEMBLER + bfd_set_error (bfd_error_system_call); +#endif as_perror (_("Failed to emit an object byte"), filename); as_fatal (_("can't continue")); } -- cgit v1.2.1