Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb apropos.c: fix pager functionality



details:   https://anonhg.NetBSD.org/src/rev/54d56be70b14
branches:  trunk
changeset: 366171:54d56be70b14
user:      gutteridge <gutteridge%NetBSD.org@localhost>
date:      Tue May 17 00:21:22 2022 +0000

description:
apropos.c: fix pager functionality

Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.

diffstat:

 usr.sbin/makemandb/apropos.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (45 lines):

diff -r 04e5b411f70a -r 54d56be70b14 usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c      Tue May 17 00:02:57 2022 +0000
+++ b/usr.sbin/makemandb/apropos.c      Tue May 17 00:21:22 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $     */
+/*     $NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $  */
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $");
 
 #include <err.h>
 #include <stdio.h>
@@ -157,6 +157,7 @@
        char *query = NULL;     // the user query
        char *errmsg = NULL;
        char *str;
+       int pc = 0;
        int rc = 0;
        size_t i;
        int s;
@@ -249,6 +250,8 @@
        if (aflags.format == APROPOS_HTML)
                fprintf(cbdata.out, "</table>\n</body>\n</html>\n");
 
+       if (aflags.pager)
+               pc = pclose(cbdata.out);
        free(query);
 
        if (aflags.sections) {
@@ -264,6 +267,9 @@
                exit(EXIT_FAILURE);
        }
 
+       if (pc == -1)
+               err(EXIT_FAILURE, "pclose error");
+
        if (rc < 0) {
                /* Something wrong with the database. Exit */
                exit(EXIT_FAILURE);



Home | Main Index | Thread Index | Old Index