Patch by Joshua R. Elsasser: (ticket #4647)
Fix fgetln() in libbsd to actually return the length of the string. Thanks a bunch! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33315 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e82b494112
commit
df3a6fbd86
@ -34,6 +34,8 @@ fgetln(FILE *stream, size_t *_length)
|
||||
|
||||
line = sBuffer;
|
||||
left = sBufferSize;
|
||||
if (_length != NULL)
|
||||
*_length = 0;
|
||||
|
||||
for (;;) {
|
||||
line = fgets(line, left, stream);
|
||||
@ -44,6 +46,8 @@ fgetln(FILE *stream, size_t *_length)
|
||||
}
|
||||
|
||||
length = strlen(line);
|
||||
if (_length != NULL)
|
||||
*_length += length;
|
||||
if (line[length - 1] != '\n' && length == sBufferSize - 1) {
|
||||
// more data is following, enlarge buffer
|
||||
char *newBuffer = realloc(sBuffer, sBufferSize + LINE_LENGTH);
|
||||
|
Loading…
x
Reference in New Issue
Block a user