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 int FAST_FUNC print_numbered_lines(struct number_state *ns, const char *filename)
13 FILE *fp = fopen_or_warn_stdin(filename);
21 while ((line = xmalloc_fgetline(fp)) != NULL) {
23 || (ns->nonempty && line[0])
25 printf("%*u%s%s\n", ns->width, N, ns->sep, line);
27 } else if (ns->empty_str)
28 fputs(ns->empty_str, stdout);