From 30cb3aa0e33daa20d6adb0825979f79e615c9c47 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 10 Aug 2019 09:44:58 -0700 Subject: sort: move off get_rawline. This was the last user of get_rawline, which lets us remove it. --- lib/lib.c | 21 ++++++--------------- lib/pending.h | 3 +-- 2 files changed, 7 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index 53962a59..282e16d3 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -699,8 +699,7 @@ void loopfiles_lines(char **argv, void (*function)(char **pline, long len)) } // Slow, but small. - -char *get_rawline(int fd, long *plen, char end) +char *get_line(int fd) { char c, *buf = NULL; long len = 0; @@ -708,20 +707,12 @@ char *get_rawline(int fd, long *plen, char end) for (;;) { if (1>read(fd, &c, 1)) break; if (!(len & 63)) buf=xrealloc(buf, len+65); - if ((buf[len++]=c) == end) break; + if ((buf[len++]=c) == '\n') break; + } + if (buf) { + buf[len]=0; + if (buf[--len]=='\n') buf[len]=0; } - if (buf) buf[len]=0; - if (plen) *plen = len; - - return buf; -} - -char *get_line(int fd) -{ - long len; - char *buf = get_rawline(fd, &len, '\n'); - - if (buf && buf[--len]=='\n') buf[len]=0; return buf; } diff --git a/lib/pending.h b/lib/pending.h index fbcc47c8..3c563947 100644 --- a/lib/pending.h +++ b/lib/pending.h @@ -6,8 +6,7 @@ int read_password(char * buff, int buflen, char* mesg); int update_password(char *filename, char* username, char* encrypted); // lib.c -// These should be switched to posix-2008 getline() and getdelim() -char *get_rawline(int fd, long *plen, char end); +// This should be switched to posix-2008 getline() char *get_line(int fd); -- cgit v1.2.3