On Thu, Aug 12, 1999 at 04:19:59PM +0200, Dag-Erling Smorgrav wrote:
> Ruslan Ermilov <r...@freebsd.org> writes:
> > Hmm, looking to the p5-* ports, I can't figure out what would be the
> > appropriate PATH component for /usr/local/lib/perl/*/man manpath.
> > Do you have an idea?
> 
> You can't use MANPATH_MAP for /usr/local/lib/perl/*/man, because these
> man pages correpsond to Perl modules, not to binaries. You have to use
> MANDATORY_MANPATH, or some variation thereof.
> 
DES, Mark, -hackers!

How about the following patch.  It adds an OPTIONAL_MANPATH directive,
which is equivalent to the MANDATORY_MANPATH, except an absence of the
directory is not considered an error.

Additionally, this patch fixes two other bugs:

1) The order of directives in manpath.config is honored, which is bogus.
   Run manpath (with and without -d flag) against the following config
   and see what happens:

MANPATH_MAP             /usr/local/bin  /usr/local/man
MANDATORY_MANPATH       /usr/share/man
MANDATORY_MANPATH       /usr/share/perl/man

   
2) Infinite loop when the PATH isn't set or NULL, and MANDATORY_MANPATH
   directory doesn't exist.  Run `/usr/bin/env PATH= /usr/bin/manpath'
   or, better yet, `/usr/bin/env PATH= /usr/bin/man man' against the
   following manpath.config:

MANDATORY_MANPATH       /usr/share/man
MANDATORY_MANPATH       /nonexistent


Cheers,
-- 
Ruslan Ermilov          Sysadmin and DBA of the
r...@ucb.crimea.ua      United Commercial Bank,
r...@freebsd.org                FreeBSD committer,
+380.652.247.647        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age
Index: manpath.config
===================================================================
RCS file: /usr/FreeBSD-CVS/src/gnu/usr.bin/man/manpath/manpath.config,v
retrieving revision 1.11
diff -u -c -r1.11 manpath.config
*** manpath.config      1999/07/25 19:33:06     1.11
--- manpath.config      1999/08/13 14:17:38
***************
*** 6,11 ****
--- 6,12 ----
  #
  # MANBIN                              pathname
  # MANDATORY_MANPATH                   manpath_element
+ # OPTIONAL_MANPATH                    manpath_element
  # MANPATH_MAP         path_element    manpath_element
  #
  # MANBIN is optional
***************
*** 16,24 ****
  #
  MANDATORY_MANPATH     /usr/share/man
  MANDATORY_MANPATH     /usr/share/perl/man
! #MANDATORY_MANPATH    /usr/local/man
! #MANDATORY_MANPATH    /usr/local/lib/perl5/5.00503/man
! MANDATORY_MANPATH     /usr/X11R6/man
  #
  # set up PATH to MANPATH mapping
  #
--- 17,23 ----
  #
  MANDATORY_MANPATH     /usr/share/man
  MANDATORY_MANPATH     /usr/share/perl/man
! OPTIONAL_MANPATH      /usr/local/lib/perl5/5.00503/man
  #
  # set up PATH to MANPATH mapping
  #
Index: manpath.h
===================================================================
RCS file: /usr/FreeBSD-CVS/src/gnu/usr.bin/man/manpath/manpath.h,v
retrieving revision 1.2
diff -u -c -r1.2 manpath.h
*** manpath.h   1995/05/30 05:02:06     1.2
--- manpath.h   1999/08/13 14:17:38
***************
*** 18,25 ****
  {
    char mandir[MAXPATHLEN];
    char bin[MAXPATHLEN];
!   int mandatory;
  } DIRLIST;
  
  DIRLIST list[MAXDIRS];
  
--- 18,31 ----
  {
    char mandir[MAXPATHLEN];
    char bin[MAXPATHLEN];
!   int type;
  } DIRLIST;
+ 
+ /* manpath types */
+ #define MANPATH_NONE          0
+ #define MANPATH_MANDATORY     1               /* manpath is mandatory */
+ #define MANPATH_OPTIONAL      2               /* manpath is optional */
+ #define MANPATH_MAP           3               /* maps path to manpath */
  
  DIRLIST list[MAXDIRS];
  
Index: manpath.c
===================================================================
RCS file: /usr/FreeBSD-CVS/src/gnu/usr.bin/man/manpath/manpath.c,v
retrieving revision 1.6
diff -u -c -r1.6 manpath.c
*** manpath.c   1998/07/09 12:39:08     1.6
--- manpath.c   1999/08/13 14:17:38
***************
*** 203,209 ****
        if (!strncmp ("MANBIN", bp, 6))
        continue;
  
!       if (!strncmp ("MANDATORY_MANPATH", bp, 17))
        {
          if ((p = strchr (bp, ' ')) == NULL &&
              (p = strchr (bp, '\t')) == NULL) {
--- 203,210 ----
        if (!strncmp ("MANBIN", bp, 6))
        continue;
  
!       if (!strncmp ("MANDATORY_MANPATH", bp, 17) ||
!         !strncmp ("OPTIONAL_MANPATH", bp, 16))
        {
          if ((p = strchr (bp, ' ')) == NULL &&
              (p = strchr (bp, '\t')) == NULL) {
***************
*** 211,219 ****
            return -1;
          }
  
!         bp = p;
  
!         dlp->mandatory = 1;
  
          while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
            bp++;
--- 212,220 ----
            return -1;
          }
  
!         dlp->type = *bp == 'M'? MANPATH_MANDATORY: MANPATH_OPTIONAL;
  
!         bp = p;
  
          while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
            bp++;
***************
*** 224,230 ****
          dlp->mandir[i] = '\0';
  
          if (debug)
!           fprintf (stderr, "found mandatory man directory %s\n",
                     dlp->mandir);
        }
        else if (!strncmp ("MANPATH_MAP", bp, 11))
--- 225,232 ----
          dlp->mandir[i] = '\0';
  
          if (debug)
!           fprintf (stderr, "found %s man directory %s\n",
!                    dlp->type == MANPATH_MANDATORY? "mandatory": "optional",
                     dlp->mandir);
        }
        else if (!strncmp ("MANPATH_MAP", bp, 11))
***************
*** 237,243 ****
  
          bp = p;
  
!         dlp->mandatory = 0;
  
          while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
            bp++;
--- 239,245 ----
  
          bp = p;
  
!         dlp->type = MANPATH_MAP;
  
          while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
            bp++;
***************
*** 269,282 ****
    fclose(config);
    dlp->bin[0] = '\0';
    dlp->mandir[0] = '\0';
!   dlp->mandatory = 0;
  
    return 0;
  }
  
  /*
!  * Construct the default manpath.  This picks up mandatory manpaths
!  * only.
   */
  char *
  def_path (perrs)
--- 271,284 ----
    fclose(config);
    dlp->bin[0] = '\0';
    dlp->mandir[0] = '\0';
!   dlp->type = MANPATH_NONE;
  
    return 0;
  }
  
  /*
!  * Construct the default manpath.  This picks up mandatory
!  * and optional (if they exist) manpaths only.
   */
  char *
  def_path (perrs)
***************
*** 288,298 ****
  
    len = 0;
    dlp = list;
!   while (dlp->mandatory != 0)
!     {
        len += strlen (dlp->mandir) + 1;
!       dlp++;
!     }
  
    manpathlist = (char *) malloc (len);
    if (manpathlist == NULL)
--- 290,300 ----
  
    len = 0;
    dlp = list;
!   while (dlp->type != MANPATH_NONE) {
!     if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL)
        len += strlen (dlp->mandir) + 1;
!     dlp++;
!   }
  
    manpathlist = (char *) malloc (len);
    if (manpathlist == NULL)
***************
*** 302,322 ****
  
    dlp = list;
    p = manpathlist;
!   while (dlp->mandatory != 0)
!     {
        int status;
        char *path = dlp->mandir;
  
        status = is_directory(path);
  
!       if (status < 0 && perrs)
        {
          fprintf (stderr, "Warning: couldn't stat file %s!\n", path);
        }
        else if (status == 0 && perrs)
        {
!         fprintf (stderr, "Warning: standard directory %s doesn't exist!\n",
!                  path);
        }
        else if (status == 1)
        {
--- 304,323 ----
  
    dlp = list;
    p = manpathlist;
!   while (dlp->type != MANPATH_NONE) {
!     if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL) {
        int status;
        char *path = dlp->mandir;
  
        status = is_directory(path);
  
!       if (status < 0 && perrs && dlp->type == MANPATH_MANDATORY)
        {
          fprintf (stderr, "Warning: couldn't stat file %s!\n", path);
        }
        else if (status == 0 && perrs)
        {
!         fprintf (stderr, "Warning: %s isn't a directory!\n", path);
        }
        else if (status == 1)
        {
***************
*** 324,332 ****
          memcpy (p, path, len);
          p += len;
          *p++ = ':';
-         dlp++;
        }
      }
  
    p[-1] = '\0';
  
--- 325,334 ----
          memcpy (p, path, len);
          p += len;
          *p++ = ':';
        }
      }
+     dlp++;
+   }
  
    p[-1] = '\0';
  
***************
*** 363,369 ****
  
    for (p = tmppath; ; p = end+1)
      {
!       if (end = strchr(p, ':'))
        *end = '\0';
  
        if (debug)
--- 365,371 ----
  
    for (p = tmppath; ; p = end+1)
      {
!       if ((end = strchr(p, ':')) != NULL)
        *end = '\0';
  
        if (debug)
***************
*** 416,426 ****
      fprintf (stderr, "\nadding mandatory man directories\n\n");
  
    dlp = list;
!   while (dlp->mandatory != 0)
!     {
!       add_dir_to_list (tmplist, dlp->mandir, perrs);
!       dlp++;
!     }
  
    len = 0;
    lp = tmplist;
--- 418,429 ----
      fprintf (stderr, "\nadding mandatory man directories\n\n");
  
    dlp = list;
!   while (dlp->type != MANPATH_NONE) {
!     if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL)
!       add_dir_to_list (tmplist, dlp->mandir,
!       dlp->type == MANPATH_MANDATORY? perrs: 0);
!     dlp++;
!   }
  
    len = 0;
    lp = tmplist;

Reply via email to