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
c7bfb646
Commit
c7bfb646
authored
Nov 02, 1993
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(safe_read): New function.
(process_aux_info_file, edit_file): Use safe_read. From-SVN: r5977
parent
500c9e81
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
22 deletions
+44
-22
gcc/protoize.c
+44
-22
No files found.
gcc/protoize.c
View file @
c7bfb646
...
@@ -732,6 +732,48 @@ outer:
...
@@ -732,6 +732,48 @@ outer:
return
0
;
return
0
;
}
}
/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
retrying if necessary. Return the actual number of bytes read. */
static
int
safe_read
(
desc
,
ptr
,
len
)
int
desc
;
char
*
ptr
;
int
len
;
{
int
left
=
len
;
while
(
left
>
0
)
{
int
nchars
=
read
(
fileno
(
stdout
),
ptr
,
left
);
if
(
nchars
<
0
)
return
nchars
;
if
(
nchars
==
0
)
break
;
ptr
+=
nchars
;
left
-=
nchars
;
}
return
len
-
left
;
}
/* 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
;
}
}
/* Get setup to recover in case the edit we are about to do goes awry. */
/* Get setup to recover in case the edit we are about to do goes awry. */
void
void
...
@@ -2228,7 +2270,7 @@ start_over: ;
...
@@ -2228,7 +2270,7 @@ start_over: ;
/* Read the aux_info file into memory. */
/* Read the aux_info file into memory. */
if
(
read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
aux_info_size
)
if
(
safe_
read
(
aux_info_file
,
aux_info_base
,
aux_info_size
)
!=
aux_info_size
)
{
{
fprintf
(
stderr
,
"%s: error reading aux info file `%s': %s
\n
"
,
fprintf
(
stderr
,
"%s: error reading aux info file `%s': %s
\n
"
,
pname
,
shortpath
(
NULL
,
aux_info_filename
),
pname
,
shortpath
(
NULL
,
aux_info_filename
),
...
@@ -4033,26 +4075,6 @@ scan_for_missed_items (file_p)
...
@@ -4033,26 +4075,6 @@ 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
/* 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
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
virgin copy there, make another cleaned in-core copy of the original file
...
@@ -4166,7 +4188,7 @@ edit_file (hp)
...
@@ -4166,7 +4188,7 @@ edit_file (hp)
in one swell fwoop. Then figure out where the end of the text is and
in one swell fwoop. Then figure out where the end of the text is and
make sure that it ends with a newline followed by a null. */
make sure that it ends with a newline followed by a null. */
if
(
read
(
input_file
,
new_orig_text_base
,
orig_size
)
!=
orig_size
)
if
(
safe_
read
(
input_file
,
new_orig_text_base
,
orig_size
)
!=
orig_size
)
{
{
close
(
input_file
);
close
(
input_file
);
fprintf
(
stderr
,
"
\n
%s: error reading input file `%s': %s
\n
"
,
fprintf
(
stderr
,
"
\n
%s: error reading input file `%s': %s
\n
"
,
...
...
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