Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Feb 2001 21:14:04 +0200
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        arch@FreeBSD.org
Subject:   [Call for *quick* review] architecture-specific manpages
Message-ID:  <20010215211404.A44780@sunbay.com>

next in thread | raw e-mail | index | archive | help

--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 <sys/file.h>
 #include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/param.h>
 #include <ctype.h>
 #include <errno.h>
 #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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010215211404.A44780>