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
bb7de822
Commit
bb7de822
authored
Nov 03, 1993
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(safe_read): New function.
(main, finclude, check_precompiled): Use safe_read. From-SVN: r5982
parent
309ffab6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
23 deletions
+45
-23
gcc/cccp.c
+45
-23
No files found.
gcc/cccp.c
View file @
bb7de822
...
@@ -980,6 +980,46 @@ static int deps_column;
...
@@ -980,6 +980,46 @@ static int deps_column;
so don't look for #include "foo" the source-file directory. */
so don't look for #include "foo" the source-file directory. */
static
int
ignore_srcdir
;
static
int
ignore_srcdir
;
/* 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
(
desc
,
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
)
int
desc
;
char
*
ptr
;
int
len
;
{
while
(
len
>
0
)
{
int
written
=
write
(
desc
,
ptr
,
len
);
if
(
written
<
0
)
pfatal_with_name
(
out_fname
);
ptr
+=
written
;
len
-=
written
;
}
}
int
int
main
(
argc
,
argv
)
main
(
argc
,
argv
)
int
argc
;
int
argc
;
...
@@ -1880,7 +1920,7 @@ main (argc, argv)
...
@@ -1880,7 +1920,7 @@ main (argc, argv)
fp
->
buf
=
(
U_CHAR
*
)
xmalloc
(
bsize
+
2
);
fp
->
buf
=
(
U_CHAR
*
)
xmalloc
(
bsize
+
2
);
bufp
=
fp
->
buf
;
bufp
=
fp
->
buf
;
for
(;;)
{
for
(;;)
{
cnt
=
read
(
f
,
bufp
,
bsize
-
size
);
cnt
=
safe_
read
(
f
,
bufp
,
bsize
-
size
);
if
(
cnt
<
0
)
goto
perror
;
/* error! */
if
(
cnt
<
0
)
goto
perror
;
/* error! */
if
(
cnt
==
0
)
break
;
/* End of file */
if
(
cnt
==
0
)
break
;
/* End of file */
size
+=
cnt
;
size
+=
cnt
;
...
@@ -1900,7 +1940,7 @@ main (argc, argv)
...
@@ -1900,7 +1940,7 @@ main (argc, argv)
fp
->
buf
=
(
U_CHAR
*
)
xmalloc
(
st_size
+
2
);
fp
->
buf
=
(
U_CHAR
*
)
xmalloc
(
st_size
+
2
);
while
(
st_size
>
0
)
{
while
(
st_size
>
0
)
{
i
=
read
(
f
,
fp
->
buf
+
fp
->
length
,
st_size
);
i
=
safe_
read
(
f
,
fp
->
buf
+
fp
->
length
,
st_size
);
if
(
i
<=
0
)
{
if
(
i
<=
0
)
{
if
(
i
==
0
)
break
;
if
(
i
==
0
)
break
;
goto
perror
;
goto
perror
;
...
@@ -4279,7 +4319,7 @@ finclude (f, fname, op, system_header_p, dirptr)
...
@@ -4279,7 +4319,7 @@ finclude (f, fname, op, system_header_p, dirptr)
/* Read the file contents, knowing that st_size is an upper bound
/* Read the file contents, knowing that st_size is an upper bound
on the number of bytes we can read. */
on the number of bytes we can read. */
while
(
st_size
>
0
)
{
while
(
st_size
>
0
)
{
i
=
read
(
f
,
fp
->
buf
+
fp
->
length
,
st_size
);
i
=
safe_
read
(
f
,
fp
->
buf
+
fp
->
length
,
st_size
);
if
(
i
<=
0
)
{
if
(
i
<=
0
)
{
if
(
i
==
0
)
break
;
if
(
i
==
0
)
break
;
goto
nope
;
goto
nope
;
...
@@ -4307,7 +4347,7 @@ finclude (f, fname, op, system_header_p, dirptr)
...
@@ -4307,7 +4347,7 @@ finclude (f, fname, op, system_header_p, dirptr)
bufp
=
basep
;
bufp
=
basep
;
for
(;;)
{
for
(;;)
{
i
=
read
(
f
,
bufp
,
bsize
-
st_size
);
i
=
safe_
read
(
f
,
bufp
,
bsize
-
st_size
);
if
(
i
<
0
)
if
(
i
<
0
)
goto
nope
;
/* error! */
goto
nope
;
/* error! */
if
(
i
==
0
)
if
(
i
==
0
)
...
@@ -4521,7 +4561,7 @@ check_precompiled (pcf, fname, limit)
...
@@ -4521,7 +4561,7 @@ check_precompiled (pcf, fname, limit)
buf
=
xmalloc
(
st_size
+
2
);
buf
=
xmalloc
(
st_size
+
2
);
while
(
st_size
>
0
)
while
(
st_size
>
0
)
{
{
i
=
read
(
pcf
,
buf
+
length
,
st_size
);
i
=
safe_
read
(
pcf
,
buf
+
length
,
st_size
);
if
(
i
<
0
)
if
(
i
<
0
)
goto
nope
;
goto
nope
;
if
(
i
==
0
)
if
(
i
==
0
)
...
@@ -4746,24 +4786,6 @@ pcstring_used (hp)
...
@@ -4746,24 +4786,6 @@ pcstring_used (hp)
delete_macro
(
hp
);
delete_macro
(
hp
);
}
}
/* 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
)
int
desc
;
char
*
ptr
;
int
len
;
{
while
(
len
>
0
)
{
int
written
=
write
(
fileno
(
stdout
),
ptr
,
len
);
if
(
written
<
0
)
pfatal_with_name
(
out_fname
);
ptr
+=
written
;
len
-=
written
;
}
}
/* Write the output, interspersing precompiled strings in their */
/* Write the output, interspersing precompiled strings in their */
/* appropriate places. */
/* appropriate places. */
static
void
static
void
...
...
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