=================================================================== RCS file: /cvs/mandoc/catman.c,v retrieving revision 1.24 retrieving revision 1.26 diff -u -p -r1.24 -r1.26 --- mandoc/catman.c 2025/06/29 20:47:01 1.24 +++ mandoc/catman.c 2025/06/29 23:51:40 1.26 @@ -1,7 +1,7 @@ -/* $Id: catman.c,v 1.24 2025/06/29 20:47:01 schwarze Exp $ */ +/* $Id: catman.c,v 1.26 2025/06/29 23:51:40 schwarze Exp $ */ /* + * Copyright (c) 2017, 2025 Ingo Schwarze * Copyright (c) 2017 Michael Stapelberg - * Copyright (c) 2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -41,6 +41,8 @@ #include #include +int verbose_flag = 0; + int process_manpage(int, int, const char *); int process_tree(int, int); void run_mandocd(int, const char *, const char *) @@ -224,7 +226,7 @@ process_tree(int srv_fd, int dstdir_fd) badfiles++; break; default: - warnx("%s: not a regular file", path); + warnx("file %s: not a regular file", path); fflush(stderr); badfiles++; break; @@ -234,6 +236,9 @@ process_tree(int srv_fd, int dstdir_fd) warn("FATAL: fts_read"); fts_close(ftsp); + if (verbose_flag) + warnx("processed %d files in %d directories", + goodfiles, gooddirs); if (baddirs > 0) warnx("skipped %d %s due to errors", baddirs, baddirs == 1 ? "directory" : "directories"); @@ -258,7 +263,7 @@ main(int argc, char **argv) defos = NULL; outtype = "ascii"; - while ((opt = getopt(argc, argv, "I:T:")) != -1) { + while ((opt = getopt(argc, argv, "I:T:v")) != -1) { switch (opt) { case 'I': defos = optarg; @@ -266,6 +271,9 @@ main(int argc, char **argv) case 'T': outtype = optarg; break; + case 'v': + verbose_flag = 1; + break; default: usage(); } @@ -275,8 +283,20 @@ main(int argc, char **argv) argc -= optind; argv += optind; } - if (argc != 2) + if (argc != 2) { + switch (argc) { + case 0: + warnx("missing arguments: srcdir and dstdir"); + break; + case 1: + warnx("missing argument: dstdir"); + break; + default: + warnx("too many arguments: %s", argv[2]); + break; + } usage(); + } if (socketpair(AF_LOCAL, SOCK_STREAM, AF_UNSPEC, srv_fds) == -1) err(1, "socketpair");