From: Karel Zak Date: Wed, 4 Mar 2020 12:20:56 +0000 (+0100) Subject: rev: report line on error X-Git-Tag: v2.36-rc1~197 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e0e29759981430e572087dfc27334939ec47fd24;p=thirdparty%2Futil-linux.git rev: report line on error Signed-off-by: Karel Zak --- diff --git a/text-utils/rev.c b/text-utils/rev.c index ae9cae5dcd..133d813931 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -103,6 +103,7 @@ int main(int argc, char *argv[]) size_t len, bufsiz = BUFSIZ; FILE *fp = stdin; int ch, rval = EXIT_SUCCESS; + uintmax_t line; static const struct option longopts[] = { { "version", no_argument, NULL, 'V' }, @@ -144,6 +145,7 @@ int main(int argc, char *argv[]) filename = *argv++; } + line = 0; while (fgetws(buf, bufsiz, fp)) { len = wcslen(buf); @@ -168,9 +170,10 @@ int main(int argc, char *argv[]) buf[len--] = '\0'; reverse_str(buf, len); fputws(buf, stdout); + line++; } if (ferror(fp)) { - warn("%s", filename); + warn("%s: %ju", filename, line); rval = EXIT_FAILURE; } if (fp != stdin)