diff options
author | Rob Landley <rob@landley.net> | 2005-01-24 07:00:02 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-01-24 07:00:02 +0000 |
commit | c0dedd05e81ac03a1793abd8cbfacf8c546e976f (patch) | |
tree | cd761995a05504c6d068ba33ddc62e86f9342e4c /libbb/get_line_from_file.c | |
parent | f4bb212d6ccc1a14724ba56fa57c3bc3ca66cf22 (diff) | |
download | busybox-w32-c0dedd05e81ac03a1793abd8cbfacf8c546e976f.tar.gz busybox-w32-c0dedd05e81ac03a1793abd8cbfacf8c546e976f.tar.bz2 busybox-w32-c0dedd05e81ac03a1793abd8cbfacf8c546e976f.zip |
Sort rewrite to be SUSv3 compliant. New config option, updated help, and
a couple of infrastructure bits.
Diffstat (limited to 'libbb/get_line_from_file.c')
-rw-r--r-- | libbb/get_line_from_file.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 6d12b21c4..a27edc3bd 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -44,7 +44,8 @@ static char *private_get_line_from_file(FILE *file, int c) | |||
44 | linebuf = xrealloc(linebuf, linebufsz += GROWBY); | 44 | linebuf = xrealloc(linebuf, linebufsz += GROWBY); |
45 | } | 45 | } |
46 | linebuf[idx++] = (char)ch; | 46 | linebuf[idx++] = (char)ch; |
47 | if (ch == '\n' || ch == '\0') { | 47 | if (!ch) return linebuf; |
48 | if (c<2 && ch == '\n') { | ||
48 | if (c) { | 49 | if (c) { |
49 | --idx; | 50 | --idx; |
50 | } | 51 | } |
@@ -71,6 +72,11 @@ extern char *bb_get_chomped_line_from_file(FILE *file) | |||
71 | return private_get_line_from_file(file, 1); | 72 | return private_get_line_from_file(file, 1); |
72 | } | 73 | } |
73 | 74 | ||
75 | extern char *bb_get_chunk_from_file(FILE *file) | ||
76 | { | ||
77 | return private_get_line_from_file(file, 2); | ||
78 | } | ||
79 | |||
74 | 80 | ||
75 | /* END CODE */ | 81 | /* END CODE */ |
76 | /* | 82 | /* |