aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-11-17 01:42:17 -0600
committerRob Landley <rob@landley.net>2020-11-17 01:42:17 -0600
commit6e81203998b8142e58dbd53f35e605e80028bdb9 (patch)
tree82fa569b42edba1ecbfb82cc647ce0d3854ecef1 /lib
parent1866f9255eb3b1f3a6f4be1dd60461a050599d98 (diff)
downloadtoybox-6e81203998b8142e58dbd53f35e605e80028bdb9.tar.gz
That last sh.c change had a lib/ change I forgot to check in.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h2
-rw-r--r--lib/xwrap.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/lib.h b/lib/lib.h
index 192fb7d2..150133b6 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -188,7 +188,7 @@ void xsignal_flags(int signal, void *handler, int flags);
void xsignal(int signal, void *handler);
time_t xvali_date(struct tm *tm, char *str);
void xparsedate(char *str, time_t *t, unsigned *nano, int endian);
-char *xgetline(FILE *fp, int *len);
+char *xgetline(FILE *fp);
time_t xmktime(struct tm *tm, int utc);
// lib.c
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 26fcb8df..22f00f2b 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -1072,18 +1072,18 @@ void xparsedate(char *str, time_t *t, unsigned *nano, int endian)
free(oldtz);
}
-char *xgetline(FILE *fp, int *len)
+// Return line of text from file. Strips trailing newline (if any).
+char *xgetline(FILE *fp)
{
char *new = 0;
- size_t linelen = 0;
+ size_t len = 0;
long ll;
errno = 0;
- if (1>(ll = getline(&new, &linelen, fp))) {
+ if (1>(ll = getline(&new, &len, fp))) {
if (errno && errno != EINTR) perror_msg("getline");
new = 0;
} else if (new[ll-1] == '\n') new[--ll] = 0;
- if (len) *len = ll;
return new;
}