summaryrefslogtreecommitdiff
path: root/libbb/get_line_from_file.c
diff options
context:
space:
mode:
authorRob Landley2005-01-24 07:00:02 +0000
committerRob Landley2005-01-24 07:00:02 +0000
commitc0dedd05e81ac03a1793abd8cbfacf8c546e976f (patch)
treecd761995a05504c6d068ba33ddc62e86f9342e4c /libbb/get_line_from_file.c
parentf4bb212d6ccc1a14724ba56fa57c3bc3ca66cf22 (diff)
downloadbusybox-c0dedd05e81ac03a1793abd8cbfacf8c546e976f.zip
busybox-c0dedd05e81ac03a1793abd8cbfacf8c546e976f.tar.gz
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.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c
index 6d12b21..a27edc3 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)
linebuf = xrealloc(linebuf, linebufsz += GROWBY);
}
linebuf[idx++] = (char)ch;
- if (ch == '\n' || ch == '\0') {
+ if (!ch) return linebuf;
+ if (c<2 && ch == '\n') {
if (c) {
--idx;
}
@@ -71,6 +72,11 @@ extern char *bb_get_chomped_line_from_file(FILE *file)
return private_get_line_from_file(file, 1);
}
+extern char *bb_get_chunk_from_file(FILE *file)
+{
+ return private_get_line_from_file(file, 2);
+}
+
/* END CODE */
/*