From owner-freebsd-arch Thu Feb 15 11:14:24 2001 Delivered-To: freebsd-arch@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 85DAC37B503; Thu, 15 Feb 2001 11:14:07 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.0/8.11.0) id f1FJE4c45426; Thu, 15 Feb 2001 21:14:04 +0200 (EET) (envelope-from ru) Date: Thu, 15 Feb 2001 21:14:04 +0200 From: Ruslan Ermilov To: arch@FreeBSD.org Subject: [Call for *quick* review] architecture-specific manpages Message-ID: <20010215211404.A44780@sunbay.com> Mail-Followup-To: arch@FreeBSD.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MGYHOYXEY6WxJCY8" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline [Bcc'ed to -developers] Hi! The attached patch implements one nice feature of original BSD man(1), to look into the machine-specific subdirectory, specifically: : As some manual pages are intended only for specific architectures, : man searches any subdirectories, with the same name as the current : architecture, in every directory which it searches. Machine specific : areas are checked before general areas. The current machine type may : be overridden by setting the environment variable MACHINE to the name : of a specific architecture. This would eliminate the need to MLINK every arch-specific file to the parent directory, and would allow us to have both architecture-specific and generic manpages with the same name in the same section. Comments? -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p Index: man.c =================================================================== RCS file: /home/ncvs/src/gnu/usr.bin/man/man/man.c,v retrieving revision 1.44 diff -u -p -r1.44 man.c --- man.c 2001/02/15 19:01:41 1.44 +++ man.c 2001/02/15 19:02:10 @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #ifdef __FreeBSD__ @@ -74,6 +74,7 @@ extern int do_system_command (); char *prognam; static char *pager; +static char *machine; static char *manp; static char *manpathlist[MAXDIRS]; static char *section; @@ -495,6 +496,12 @@ man_getopt (argc, argv) if (debug) fprintf (stderr, "\nusing %s as pager\n", pager); + if ((machine = getenv ("MACHINE")) == NULL) + machine = MACHINE; + + if (debug) + fprintf (stderr, "\nusing %s architecture\n", machine); + if (manp == NULL) { if ((manp = manpath (0)) == NULL) @@ -662,6 +669,15 @@ convert_name (name, to_cat) *t1 = '\0'; t2 = strrchr (to_name, '/'); *t1 = '/'; + + /* Skip architecture part (if present). */ + if (t2 != NULL && (t1 - t2 < 5 || *(t2 + 1) != 'm' || *(t2 + 3) != 'n')) + { + t1 = t2; + *t1 = '\0'; + t2 = strrchr (to_name, '/'); + *t1 = '/'; + } } if (t2 == NULL) @@ -1469,6 +1485,22 @@ try_section (path, section, name, glob) register int cat; register char **names; register char **np; + static int arch_search; + char buf[FILENAME_MAX]; + + if (!arch_search) + { + snprintf(buf, sizeof(buf), "%s/man%s/%s", path, section, machine); + if (is_directory (buf) == 1) + { + snprintf(buf, sizeof(buf), "%s/%s", machine, name); + arch_search++; + found = try_section (path, section, buf, glob); + arch_search--; + if (found && !findall) /* only do this architecture... */ + return found; + } + } if (debug) { --MGYHOYXEY6WxJCY8-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message