fileio: rework read_one_line_file() on top of read_line()

This commit is contained in:
Lennart Poettering 2017-09-22 18:01:32 +02:00
parent 189912440f
commit f4b51a2d09
1 changed files with 2 additions and 16 deletions

View File

@ -30,6 +30,7 @@
#include "alloc-util.h"
#include "ctype.h"
#include "def.h"
#include "env-util.h"
#include "escape.h"
#include "fd-util.h"
@ -177,7 +178,6 @@ fail:
int read_one_line_file(const char *fn, char **line) {
_cleanup_fclose_ FILE *f = NULL;
char t[LINE_MAX], *c;
assert(fn);
assert(line);
@ -186,21 +186,7 @@ int read_one_line_file(const char *fn, char **line) {
if (!f)
return -errno;
if (!fgets(t, sizeof(t), f)) {
if (ferror(f))
return errno > 0 ? -errno : -EIO;
t[0] = 0;
}
c = strdup(t);
if (!c)
return -ENOMEM;
truncate_nl(c);
*line = c;
return 0;
return read_line(f, LONG_LINE_MAX, line);
}
int verify_file(const char *fn, const char *blob, bool accept_extra_nl) {