Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4b2b445f
Commit
4b2b445f
authored
Nov 29, 2000
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #102469: Use glibc's getline() extension when reading unbounded lines
parent
78a14423
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
Objects/fileobject.c
Objects/fileobject.c
+30
-3
No files found.
Objects/fileobject.c
View file @
4b2b445f
...
...
@@ -645,13 +645,40 @@ file_readinto(PyFileObject *f, PyObject *args)
static
PyObject
*
get_line
(
PyFileObject
*
f
,
int
n
)
{
register
FILE
*
fp
;
register
FILE
*
fp
=
f
->
f_fp
;
register
int
c
;
register
char
*
buf
,
*
end
;
char
*
buf
,
*
end
;
size_t
n1
,
n2
;
PyObject
*
v
;
fp
=
f
->
f_fp
;
#ifdef HAVE_GETLINE
/* Use GNU libc extension getline() for arbitrary-sized lines */
if
(
n
==
0
)
{
size_t
size
=
0
;
buf
=
NULL
;
Py_BEGIN_ALLOW_THREADS
n1
=
getline
(
&
buf
,
&
size
,
fp
);
Py_END_ALLOW_THREADS
if
(
n1
==
-
1
)
{
clearerr
(
fp
);
if
(
PyErr_CheckSignals
())
{
return
NULL
;
}
if
(
n
<
0
&&
feof
(
fp
))
{
PyErr_SetString
(
PyExc_EOFError
,
"EOF when reading a line"
);
return
NULL
;
}
return
PyString_FromStringAndSize
(
NULL
,
0
);
}
/* No error */
v
=
PyString_FromStringAndSize
(
buf
,
n1
);
free
(
buf
);
return
v
;
}
#endif
n2
=
n
>
0
?
n
:
100
;
v
=
PyString_FromStringAndSize
((
char
*
)
NULL
,
n2
);
if
(
v
==
NULL
)
...
...
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