Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Aug 1999 18:00:20 +0300
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Dag-Erling Smorgrav <des@flood.ping.uio.no>, Mark Murray <markm@freebsd.org>
Cc:        FreeBSD Hackers <hackers@freebsd.org>
Subject:   [Review please] (was: Re: cvs commit: src/gnu/usr.bin/man/manpath manpath.config)
Message-ID:  <19990813180020.A23485@relay.ucb.crimea.ua>
In-Reply-To: <xzp907ht71s.fsf@flood.ping.uio.no>; from Dag-Erling Smorgrav on Thu, Aug 12, 1999 at 04:19:59PM %2B0200
References:  <199908111732.KAA91686@freefall.freebsd.org> <xzpvhalto0u.fsf@flood.ping.uio.no> <xzpu2q5tno3.fsf@flood.ping.uio.no> <19990812120825.A87115@relay.ucb.crimea.ua> <xzpoggdtl6w.fsf@flood.ping.uio.no> <19990812124106.B87115@relay.ucb.crimea.ua> <xzpk8r1tjsq.fsf@flood.ping.uio.no> <19990812162007.H87115@relay.ucb.crimea.ua> <xzp907ht71s.fsf@flood.ping.uio.no>

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

--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii

On Thu, Aug 12, 1999 at 04:19:59PM +0200, Dag-Erling Smorgrav wrote:
> Ruslan Ermilov <ru@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
ru@ucb.crimea.ua	United Commercial Bank,
ru@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

--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p

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;

--OgqxwSJOaUobr8KG--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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