aboutsummaryrefslogtreecommitdiff
path: root/gcc/cccp.c
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-03-16 02:44:04 +0000
committerRichard Stallman <rms@gnu.org>1993-03-16 02:44:04 +0000
commitd50c1d49cfa0861e9f1119390ee9a1de131500e2 (patch)
tree73ff2aa147663a353236ae1764e157e91a2f7dca /gcc/cccp.c
parentec241c19a4c26c936bb2c4f812d476b5d3b2d8e0 (diff)
downloadgcc-d50c1d49cfa0861e9f1119390ee9a1de131500e2.zip
gcc-d50c1d49cfa0861e9f1119390ee9a1de131500e2.tar.gz
gcc-d50c1d49cfa0861e9f1119390ee9a1de131500e2.tar.bz2
(write_output): Test value of `write'; report errors.
(out_fname): Var now file-scope. From-SVN: r3752
Diffstat (limited to 'gcc/cccp.c')
-rw-r--r--gcc/cccp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 3dcbf2a..a1b25f8 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -917,6 +917,9 @@ static U_CHAR is_space[256];
static int errors = 0; /* Error counter for exit code */
+/* Name of output file, for error messages. */
+static char *out_fname;
+
/* Zero means dollar signs are punctuation.
-$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise.
This must be 0 for correct processing of this ANSI C program:
@@ -972,7 +975,7 @@ main (argc, argv)
{
int st_mode;
long st_size;
- char *in_fname, *out_fname;
+ char *in_fname;
char *p;
int f, i;
FILE_BUF *fp;
@@ -4683,10 +4686,10 @@ write_output ()
line_command_len *= 2);
sprintf (line_command, "\n# %d \"%s\"\n",
next_string->lineno, next_string->filename);
- write (fileno (stdout), line_command,
- strlen (line_command));
- write (fileno (stdout),
- next_string->contents, next_string->len);
+ if (write (fileno (stdout), line_command, strlen (line_command)) < 0)
+ perror_with_name (out_fname);
+ if (write (fileno (stdout), next_string->contents, next_string->len) < 0)
+ perror_with_name (out_fname);
}
next_string = next_string->chain;
}
@@ -4696,7 +4699,8 @@ write_output ()
- (cur_buf_loc - outbuf.buf))
: outbuf.bufp - cur_buf_loc);
- write (fileno (stdout), cur_buf_loc, len);
+ if (write (fileno (stdout), cur_buf_loc, len) < len)
+ perror_with_name (out_fname);
cur_buf_loc += len;
}
}