Source-Changes-HG archive

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

[src/netbsd-8]: src/usr.bin/man Pull up following revision(s) (requested by g...



details:   https://anonhg.NetBSD.org/src/rev/4dfac47cbc2c
branches:  netbsd-8
changeset: 363459:4dfac47cbc2c
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 13 09:54:01 2022 +0000

description:
Pull up following revision(s) (requested by gutteridge in ticket #1737):

        usr.bin/man/man.c: revision 1.69
        usr.bin/man/man.c: revision 1.70
        usr.bin/man/man.c: revision 1.72

man.c: fix -m option so it works as documented

Refactoring work in man.c r. 1.40 from twelve years ago introduced a
regression where input from the -m option was appended rather than
prepended to the search paths. Problem reported by C. Chapman on
netbsd-users.

man: fix type mismatch between enum and int (since yesterday)
No binary change.

man: remove unused global variable 'instype' (since yesterday)
No functional change.

diffstat:

 usr.bin/man/man.c |  25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diffs (91 lines):

diff -r f0b68c6b4dc8 -r 4dfac47cbc2c usr.bin/man/man.c
--- a/usr.bin/man/man.c Thu Feb 24 10:08:40 2022 +0000
+++ b/usr.bin/man/man.c Sun Mar 13 09:54:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $ */
+/*     $NetBSD: man.c,v 1.66.2.1 2022/03/13 09:54:01 martin Exp $      */
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)man.c      8.17 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: man.c,v 1.66 2017/05/02 14:19:23 abhinav Exp $");
+__RCSID("$NetBSD: man.c,v 1.66.2.1 2022/03/13 09:54:01 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,6 +69,11 @@
 #define MAN_DEBUG 0            /* debug path output */
 #endif
 
+enum inserttype {
+       INS_TAIL,
+       INS_HEAD
+};
+
 /*
  * manstate: structure collecting the current global state so we can 
  * easily identify it and pass it to helper functions in one arg.
@@ -117,7 +122,8 @@
 static int      manual(char *, struct manstate *, glob_t *);
 static void     onsig(int) __dead;
 static void     usage(void) __dead;
-static void     addpath(struct manstate *, const char *, size_t, const char *);
+static void     addpath(struct manstate *, const char *, size_t, const char *,
+                    enum inserttype);
 static const char *getclass(const char *);
 static void printmanpath(struct manstate *);
 
@@ -328,7 +334,7 @@
                        if (len < 1)
                                continue;
                        TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q)
-                               addpath(&m, p, len, esubd->s);
+                               addpath(&m, p, len, esubd->s, INS_TAIL);
                }
 
        } else {
@@ -336,12 +342,12 @@
                TAILQ_FOREACH(epath, &m.defaultpath->entrylist, q) {
                        /* handle trailing "/" magic here ... */
                        if (abs_section && epath->s[epath->len - 1] != '/') {
-                               addpath(&m, "", 1, epath->s);
+                               addpath(&m, "", 1, epath->s, INS_TAIL);
                                continue;
                        }
 
                        TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q)
-                               addpath(&m, epath->s, epath->len, esubd->s);
+                               addpath(&m, epath->s, epath->len, esubd->s, INS_TAIL);
                }
 
        }
@@ -359,7 +365,7 @@
                        if (len < 1)
                                continue;
                        TAILQ_FOREACH(esubd, &m.subdirs->entrylist, q)
-                               addpath(&m, p, len, esubd->s);
+                               addpath(&m, p, len, esubd->s, INS_HEAD); /* Add to front */
                }
 
        }
@@ -1011,14 +1017,15 @@
 }
 
 static void
-addpath(struct manstate *m, const char *dir, size_t len, const char *sub)
+addpath(struct manstate *m, const char *dir, size_t len, const char *sub,
+       enum inserttype ishead)
 {
        char buf[2 * MAXPATHLEN + 1];
        (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,%s%s%s}",
             dir, (dir[len - 1] == '/') ? "" : "/", sub, m->machine,
             m->machclass ? "/" : "", m->machclass ? m->machclass : "",
             m->machclass ? "," : "");
-       if (addentry(m->mymanpath, buf, 0) < 0)
+       if (addentry(m->mymanpath, buf, (int)ishead) < 0)
                errx(EXIT_FAILURE, "malloc failed");
 }
 



Home | Main Index | Thread Index | Old Index