diff options
author | Chet Ramey <chet.ramey@case.edu> | 2016-09-15 16:59:08 -0400 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2016-09-15 16:59:08 -0400 |
commit | a0c0a00fc419b7bc08202a79134fcd5bc0427071 (patch) | |
tree | cfde1549b35d73504bb539008de4b00e44e8f8fb /lib/sh/zgetline.c | |
parent | 30a978b7d808c067219c95be88c4979b6a7aa251 (diff) | |
download | bash-a0c0a00fc419b7bc08202a79134fcd5bc0427071.tar.gz |
Bash-4.4 distribution sources and documentationbash-4.4
Diffstat (limited to 'lib/sh/zgetline.c')
-rw-r--r-- | lib/sh/zgetline.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/sh/zgetline.c b/lib/sh/zgetline.c index 9cef9752..a686ba3d 100644 --- a/lib/sh/zgetline.c +++ b/lib/sh/zgetline.c @@ -48,9 +48,12 @@ typedef ssize_t creadfunc_t __P((int, char *)); /* Derived from GNU libc's getline. The behavior is almost the same as getline. See man getline. The differences are - (1) using file descriptor instead of FILE *, - (2) the order of arguments; the file descriptor comes the first, and - (3) the addition of third argument, UNBUFFERED_READ; this argument + (1) using file descriptor instead of FILE *; + (2) the order of arguments: the file descriptor comes first; + (3) the addition of a fourth argument, DELIM; sets the delimiter to + be something other than newline if desired. If setting DELIM, + the next argument should be 1; and + (4) the addition of a fifth argument, UNBUFFERED_READ; this argument controls whether get_line uses buffering or not to get a byte data from FD. get_line uses zreadc if UNBUFFERED_READ is zero; and uses zread if UNBUFFERED_READ is non-zero. @@ -58,10 +61,11 @@ typedef ssize_t creadfunc_t __P((int, char *)); Returns number of bytes read or -1 on error. */ ssize_t -zgetline (fd, lineptr, n, unbuffered_read) +zgetline (fd, lineptr, n, delim, unbuffered_read) int fd; char **lineptr; size_t *n; + int delim; int unbuffered_read; { int nr, retval; @@ -110,7 +114,7 @@ zgetline (fd, lineptr, n, unbuffered_read) line[nr] = c; nr++; - if (c == '\n') + if (c == delim) { line[nr] = '\0'; break; |