hush: fix read builtin to not read ahead past eol and to not use

insane amounts of stack. Testsuite updated.
This commit is contained in:
Denis Vlasenko
2007-06-13 06:47:47 +00:00
parent f5f75c5e82
commit d67cef2425
10 changed files with 68 additions and 31 deletions

View File

@ -400,7 +400,11 @@ extern ssize_t safe_read(int fd, void *buf, size_t count);
extern ssize_t full_read(int fd, void *buf, size_t count);
extern void xread(int fd, void *buf, size_t count);
extern unsigned char xread_char(int fd);
// Read one line a-la fgets. Uses one read(), works only on seekable streams
extern char *reads(int fd, char *buf, size_t count);
// Read one line a-la fgets. Reads byte-by-byte.
// Useful when it is important to not read ahead.
extern char *xmalloc_reads(int fd, char *pfx);
extern ssize_t read_close(int fd, void *buf, size_t count);
extern ssize_t open_read_close(const char *filename, void *buf, size_t count);
extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);