Any comments/OK?
On Oct 22 13:49:28, h...@stare.cz wrote:
> games/quiz.c popen()s a PAGER to display the help message.
> Throw that away and let the use pipe into a PAGER if needed.
> Then we can just pledge "stdio rpath".
>
> Jan
>
>
> Index: quiz.c
> ===================================================================
> RCS file: /cvs/src/games/quiz/quiz.c,v
> retrieving revision 1.21
> diff -u -p -u -p -r1.21 quiz.c
> --- quiz.c 29 Aug 2013 20:22:18 -0000 1.21
> +++ quiz.c 22 Oct 2015 11:42:42 -0000
> @@ -66,6 +66,9 @@ main(int argc, char *argv[])
> int ch;
> const char *indexfile;
>
> + if (pledge("stdio rpath", NULL) == -1)
> + err(1, "pledge");
> +
> indexfile = _PATH_QUIZIDX;
> while ((ch = getopt(argc, argv, "i:t")) != -1)
> switch(ch) {
> @@ -144,30 +147,21 @@ show_index(void)
> {
> QE *qp;
> const char *p, *s;
> - FILE *pf;
> - const char *pager;
>
> - if (!isatty(1))
> - pager = "/bin/cat";
> - else if (!(pager = getenv("PAGER")) || (*pager == 0))
> - pager = _PATH_PAGER;
> - if ((pf = popen(pager, "w")) == NULL)
> - err(1, "%s", pager);
> - (void)fprintf(pf, "Subjects:\n\n");
> + printf("Subjects:\n\n");
> for (qp = qlist.q_next; qp; qp = qp->q_next) {
> for (s = next_cat(qp->q_text); s; s = next_cat(s)) {
> if (!rxp_compile(s))
> errx(1, "%s", rxperr);
> if ((p = rxp_expand()))
> - (void)fprintf(pf, "%s ", p);
> + printf("%s ", p);
> }
> - (void)fprintf(pf, "\n");
> + printf("\n");
> }
> - (void)fprintf(pf, "\n%s\n%s\n%s\n",
> + printf("\n%s\n%s\n%s\n",
> "For example, \"quiz victim killer\" prints a victim's name and you reply",
> "with the killer, and \"quiz killer victim\" works the other way around.",
> "Type an empty line to get the correct answer.");
> - (void)pclose(pf);
> }
>
> void