aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c21
-rw-r--r--lib/pending.h3
2 files changed, 7 insertions, 17 deletions
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);