Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
fa0cd3ff
Commit
fa0cd3ff
authored
31 years ago
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(edit_file): Use safe_write.
(safe_write): New subroutine. From-SVN: r5972
parent
83a4b97f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
gcc/protoize.c
+22
-7
No files found.
gcc/protoize.c
View file @
fa0cd3ff
...
...
@@ -4033,6 +4033,26 @@ scan_for_missed_items (file_p)
}
}
/* Write LEN bytes at PTR to descriptor DESC,
retrying if necessary, and treating any real error as fatal. */
static
void
safe_write
(
desc
,
ptr
,
len
,
out_fname
)
int
desc
;
char
*
ptr
;
int
len
;
char
*
out_fname
;
{
while
(
len
>
0
)
{
int
written
=
write
(
fileno
(
stdout
),
ptr
,
len
);
if
(
written
<
0
)
fprintf
(
stderr
,
"%s: error writing file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
out_fname
),
sys_errlist
[
errno
]);
ptr
+=
written
;
len
-=
written
;
}
}
/* Do all editing operations for a single source file (either a "base" file
or an "include" file). To do this we read the file into memory, keep a
virgin copy there, make another cleaned in-core copy of the original file
...
...
@@ -4190,9 +4210,7 @@ edit_file (hp)
/* Write the clean file. */
if (write (clean_file, new_clean_text_base, clean_size) != clean_size)
fprintf (stderr, "%s: error writing file `%s': %s\n",
pname, shortpath (NULL, clean_filename), sys_errlist[errno]);
safe_write (clean_file, new_clean_text_base, clean_size, clean_filename);
close (clean_file);
}
...
...
@@ -4326,10 +4344,7 @@ edit_file (hp)
{
unsigned
int
out_size
=
(
repl_write_ptr
+
1
)
-
repl_text_base
;
if
(
write
(
output_file
,
repl_text_base
,
out_size
)
!=
out_size
)
fprintf
(
stderr
,
"%s: error writing file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
convert_filename
),
sys_errlist
[
errno
]);
safe_write
(
output_file
,
repl_text_base
,
out_size
,
convert_filename
);
}
close
(
output_file
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment