summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rn.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/rn.c b/src/rn.c
index 11c8b45..be4fed9 100644
--- a/src/rn.c
+++ b/src/rn.c
@@ -5,7 +5,6 @@
#include <unistd.h>
#include "util/versie.h"
-#include "io/lines.h"
static void usage(FILE *f) {
fprintf(f,
@@ -48,21 +47,16 @@ static char** parse_options(int argc, char **argv, bool *perFile) {
static void process(const char *fname, FILE *file, bool perFile, size_t *n) {
if (perFile) *n = 1;
- struct file_lines fl;
- if (!file_lines_open("rn", fname, file, &fl)) exit(1);
-
- while (true) {
- struct string_view sv;
- if (!file_lines_read(&fl, &sv)) break;
-
- printf("%6lu ", *n);
- fwrite(sv.s, 1, sv.len, stdout);
- printf("\n");
+ char *line = NULL;
+ size_t linen = 0;
+ ssize_t nread = 0;
+ while ((nread = getline(&line, &linen, file)) != -1) {
+ printf("%6lu %s", *n, line);
*n += 1;
}
- file_lines_close(&fl);
+ free(line);
}
int entry_rn(int argc, char **argv) {