1 /* vi: set sw=4 ts=4: */
3 * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com>
5 * Licensed under GPLv2, see file LICENSE in this source tree.
7 //kbuild:lib-y += print_numbered_lines.o
11 void FAST_FUNC print_numbered_lines(struct number_state *ns, const char *filename)
13 FILE *fp = fopen_or_warn_stdin(filename);
14 unsigned N = ns->start;
17 while ((line = xmalloc_fgetline(fp)) != NULL) {
19 || (ns->nonempty && line[0])
21 printf("%*u%s%s\n", ns->width, N, ns->sep, line);
23 } else if (ns->empty_str)
24 fputs(ns->empty_str, stdout);