commit 895443883937da997e5bfdb26ae91f28472506bd
Author: Joshua R. Elsasser <joshua@elsasser.org>
Date: Sat Sep 26 17:07:54 2009 +0000
Fix fgetln() in libbsd to actually return the length of the string.
diff --git a/src/libs/bsd/fgetln.c b/src/libs/bsd/fgetln.c
index 0d6dd4b..65b3194 100644
a
|
b
|
fgetln(FILE *stream, size_t *_length)
|
34 | 34 | |
35 | 35 | line = sBuffer; |
36 | 36 | left = sBufferSize; |
| 37 | if (_length != NULL) |
| 38 | *_length = 0; |
37 | 39 | |
38 | 40 | for (;;) { |
39 | 41 | line = fgets(line, left, stream); |
… |
… |
fgetln(FILE *stream, size_t *_length)
|
44 | 46 | } |
45 | 47 | |
46 | 48 | length = strlen(line); |
| 49 | if (_length != NULL) |
| 50 | *_length += length; |
47 | 51 | if (line[length - 1] != '\n' && length == sBufferSize - 1) { |
48 | 52 | // more data is following, enlarge buffer |
49 | 53 | char *newBuffer = realloc(sBuffer, sBufferSize + LINE_LENGTH); |