Index: files/src__man.conf.in.diff
===================================================================
--- files/src__man.conf.in.diff	(revision 0)
+++ files/src__man.conf.in.diff	(revision 0)
@@ -0,0 +1,26 @@
+--- src/man.conf.in.orig	2005-08-20 16:26:06.000000000 -0700
++++ src/man.conf.in	2007-01-12 16:53:47.000000000 -0800
+@@ -36,11 +36,9 @@
+ #
+ # Every automatically generated MANPATH includes these fields
+ #
+-MANPATH	/usr/man
+ MANPATH	/usr/share/man
+-MANPATH	/usr/local/man
+ MANPATH	/usr/local/share/man
+-MANPATH	/usr/X11R6/man
++MANPATH	/usr/X11/man
+ #
+ # Uncomment if you want to include one of these by default
+ #
+@@ -64,8 +62,8 @@
+ MANPATH_MAP	/usr/sbin		/usr/share/man
+ MANPATH_MAP	/usr/local/bin		/usr/local/share/man
+ MANPATH_MAP	/usr/local/sbin		/usr/local/share/man
+-MANPATH_MAP	/usr/X11R6/bin		/usr/X11R6/man
+-MANPATH_MAP	/usr/bin/X11		/usr/X11R6/man
++MANPATH_MAP	/usr/X11/bin		/usr/X11/man
++MANPATH_MAP	/usr/bin/X11		/usr/X11/man
+ MANPATH_MAP	/usr/bin/mh		/usr/share/man
+ #
+ # NOAUTOPATH keeps man from automatically adding directories that look like
Index: files/src__manpath.c.diff
===================================================================
--- files/src__manpath.c.diff	(revision 0)
+++ files/src__manpath.c.diff	(revision 0)
@@ -0,0 +1,17 @@
+--- src/manpath.c.orig	Sun Nov 14 15:25:42 2004
++++ src/manpath.c	Sun Nov 14 15:34:32 2004
+@@ -137,6 +137,14 @@
+ 	  len += 3;
+      }
+ 
++#if defined(__APPLE__)
++     /* Try to use share/man (3545105). */
++     strcpy (t + len, "/share/man");
++
++     if (is_directory (t) == 1)
++	  return t;
++#endif
++
+      /* look for the situation with packagedir/bin and packagedir/man */
+      strcpy (t + len, "/man");
+ 
Index: files/PR3857969.diff
===================================================================
--- files/PR3857969.diff	(revision 0)
+++ files/PR3857969.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/man.c.orig	2004-12-01 12:37:16.000000000 -0800
++++ src/man.c	2004-12-01 12:30:59.000000000 -0800
+@@ -1228,7 +1228,7 @@
+ 
+ int
+ main (int argc, char **argv) {
+-     int status = 0;
++     int status = 1;
+      char *nextarg;
+      char *tmp;
+      char *section = 0;
Index: files/configure.diff
===================================================================
--- files/configure.diff	(revision 0)
+++ files/configure.diff	(revision 0)
@@ -0,0 +1,22 @@
+--- configure.orig	Sat Oct 23 06:24:51 2004
++++ configure	Sat Oct 23 06:37:44 2004
+@@ -474,17 +474,12 @@
+     troff="troff -mandoc"
+     echo "Warning: could not find groff"
+   else
+-    if test $Fnroff = "missing"
+-    then
+-      nroff="$Fgroff -Tlatin1 -mandoc"
+-    else
+-      nroff="$Fnroff -Tlatin1 -mandoc"
+-    fi
++    nroff="$Fgroff -P-c -Wall -mtty-char -Tascii -mandoc"
+     troff="$Fgroff -Tps -mandoc"
+     jnroff="$Fgroff -Tnippon -mandocj"
+   fi
+   eqn="$Fgeqn -Tps"
+-  neqn="$Fgeqn -Tlatin1"
++  neqn="$Fgeqn -Tascii"
+   jneqn="$Fgeqn -Tnippon"
+   tbl="$Fgtbl"
+   col="$Fcol"
Index: files/PR4121764.diff
===================================================================
--- files/PR4121764.diff	(revision 0)
+++ files/PR4121764.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- man/en/whatis.man.orig	2006-06-02 12:25:41.000000000 -0700
++++ man/en/whatis.man	2006-06-02 12:25:59.000000000 -0700
+@@ -24,7 +24,7 @@
+ of system commands for keywords and displays the result on the
+ standard output.  Only complete word matches are displayed.
+ 
+-The whatis database is created using the command @makewhatis@.
++The whatis database is created using the command /usr/libexec/makewhatis.
+ .SH AUTHOR
+ John W. Eaton was the original author of
+ .BR "man" .
Index: files/PR4302566.diff
===================================================================
--- files/PR4302566.diff	(revision 0)
+++ files/PR4302566.diff	(revision 0)
@@ -0,0 +1,58 @@
+--- src/man.c.orig	2006-06-02 12:52:27.000000000 -0700
++++ src/man.c	2006-06-02 15:11:32.000000000 -0700
+@@ -335,7 +335,7 @@
+      if (expander && *expander) {
+ 	  char *command;
+ 
+-	  command = my_xsprintf ("%s %S", expander, name);
++	  command = my_xsprintf ("%s '%Q'", expander, name);
+ 	  fp = my_popen (command, "r");
+ 	  if (fp == NULL) {
+ 	       perror("popen");
+@@ -604,10 +604,10 @@
+ 
+      if (expander && *expander) {
+ 	  if (converter && *converter)
+-	     command = my_xsprintf("%s%s '%S' | %s%s",
++	     command = my_xsprintf("%s%s '%Q' | %s%s",
+ 				   bufh, expander, file, converter, buft);
+ 	  else
+-	     command = my_xsprintf("%s%s '%S'%s",
++	     command = my_xsprintf("%s%s '%Q'%s",
+ 				   bufh, expander, file, buft);
+      } else if (ll || pl) {
+ 	  const char *cat = getval("CAT");
+@@ -615,10 +615,10 @@
+ 		  cat = "cat";
+ 
+ 	  if (converter && *converter)
+-	      command = my_xsprintf("%s%s '%S' | %s%s",
++	      command = my_xsprintf("%s%s '%Q' | %s%s",
+ 				    bufh, cat, file, converter, buft);
+ 	  else
+-	      command = my_xsprintf("%s%s '%S'%s",
++	      command = my_xsprintf("%s%s '%Q'%s",
+ 				    bufh, cat, file, buft);
+      }
+ 
+@@ -641,7 +641,7 @@
+      }
+ 
+      if (expander && *expander) {
+-	  char *cmd = my_xsprintf ("%s %S", expander, file);
++	  char *cmd = my_xsprintf ("%s '%Q'", expander, file);
+ 	  fp = my_popen (cmd, "r");
+ 	  if (fp == NULL) {
+ 	       perror("popen");
+@@ -826,9 +826,9 @@
+      if (roff_command == NULL)
+ 	  return 0;
+      if (do_troff)
+-	  command = my_xsprintf ("(cd \"%S\" && %s)", path, roff_command);
++	  command = my_xsprintf ("(cd '%Q' && %s)", path, roff_command);
+      else
+-	  command = my_xsprintf ("(cd \"%S\" && %s | (%s || true))", path,
++	  command = my_xsprintf ("(cd '%Q' && %s | (%s || true))", path,
+ 		   roff_command, pager);
+ 
+      return !do_system_command (command, 0);
Index: files/PR4062483.diff
===================================================================
--- files/PR4062483.diff	(revision 0)
+++ files/PR4062483.diff	(revision 0)
@@ -0,0 +1,12 @@
+--- src/man.c.orig	2006-06-02 12:52:27.000000000 -0700
++++ src/man.c	2006-06-02 13:16:28.000000000 -0700
+@@ -407,6 +407,9 @@
+      if (strlen(name) + strlen(beg) + 1 >= BUFSIZ)
+ 	  return 0;		/* very long names, ignore */
+ 
++     if (beg[0] == '/') {
++	  strcpy(name, beg);
++     } else
+      if (!index(beg, '/')) {
+ 	  /* strange.. try same directory as the .so file */
+ 	  strcat(name, "/");
Index: files/PR4006198.diff
===================================================================
--- files/PR4006198.diff	(revision 0)
+++ files/PR4006198.diff	(revision 0)
@@ -0,0 +1,12 @@
+--- src/man.c.orig	2006-06-02 12:52:27.000000000 -0700
++++ src/man.c	2006-06-12 17:08:25.000000000 -0700
+@@ -380,6 +380,9 @@
+ 	  return (NULL);
+      }
+ 
++     if (!isascii(buf[0]))
++	  return (NULL);
++
+      if (strncmp(buf, ".so", 3))
+ 	  return (my_strdup(name));
+ 
Index: files/PR4670363.diff
===================================================================
--- files/PR4670363.diff	(revision 0)
+++ files/PR4670363.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/apropos.sh.orig	2006-08-07 13:10:29.000000000 -0700
++++ src/apropos.sh	2006-08-07 13:10:36.000000000 -0700
+@@ -22,7 +22,7 @@
+ aproposgrepopt1='i'
+ aproposgrepopt2=''
+ whatisgrepopt1='iw'
+-whatisgrepopt2='^'
++whatisgrepopt2=''
+ grepopt1=$%apropos_or_whatis%grepopt1
+ grepopt2=$%apropos_or_whatis%grepopt2
+ 
Index: files/src__man-getopt.c.diff
===================================================================
--- files/src__man-getopt.c.diff	(revision 0)
+++ files/src__man-getopt.c.diff	(revision 0)
@@ -0,0 +1,23 @@
+--- src/man-getopt.c.orig	Sat Oct 23 05:38:46 2004
++++ src/man-getopt.c	Sat Oct 23 06:17:04 2004
+@@ -39,7 +39,7 @@
+      exit(1);
+ }
+ 
+-static char short_opts[] = "B:C:H:xM:P:S:acdDfFhkKm:p:s:tvVwW?";
++static char short_opts[] = "B:C:H:xM:P:S:acdDfFhkKm:p:s:tvVwW?Lq";
+ 
+ #ifndef NOGETOPT
+ #undef _GNU_SOURCE
+@@ -167,6 +167,11 @@
+ 		    fatal (INCOMPAT, "-w", "-t");
+ 	       print_where++;
+ 	       break;
++	  /* Silently ignore manpath -q and -L (3825529). */
++	  case 'L':
++	  case 'q':
++	       if (!strncmp(progname, "manpath", 7))
++		    break;
+ 	  case 'h':
+ 	  case '?':
+ 	  default:
Index: files/src__man.c.diff
===================================================================
--- files/src__man.c.diff	(revision 0)
+++ files/src__man.c.diff	(revision 0)
@@ -0,0 +1,13 @@
+--- src/man.c.orig	Sun Aug 22 20:18:06 2004
++++ src/man.c	Sun Nov 14 15:53:53 2004
+@@ -150,6 +153,10 @@
+ static char *
+ setpl(void) {
+      char *pl;
++
++     /* Short-circuit bogus behavior (3828722). */
++     return NULL;
++
+      if (do_troff)
+ 	  return NULL;
+      if (preformat)
Index: files/PR4076593.diff
===================================================================
--- files/PR4076593.diff	(revision 0)
+++ files/PR4076593.diff	(revision 0)
@@ -0,0 +1,10 @@
+--- src/apropos.sh.orig	2006-09-20 15:40:51.000000000 -0700
++++ src/apropos.sh	2006-09-20 15:45:59.000000000 -0700
+@@ -83,6 +83,6 @@
+     fi
+ 
+     shift
+-done
++done | ${PAGER:-more -E}
+ 
+ exit
Index: files/PR3845474.diff
===================================================================
--- files/PR3845474.diff	(revision 0)
+++ files/PR3845474.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/man.c.orig	2006-06-02 12:52:27.000000000 -0700
++++ src/man.c	2006-06-02 15:15:54.000000000 -0700
+@@ -828,7 +828,7 @@
+      if (do_troff)
+ 	  command = my_xsprintf ("(cd \"%S\" && %s)", path, roff_command);
+      else
+-	  command = my_xsprintf ("(cd \"%S\" && %s | %s)", path,
++	  command = my_xsprintf ("(cd \"%S\" && %s | (%s || true))", path,
+ 		   roff_command, pager);
+ 
+      return !do_system_command (command, 0);
Index: files/src__util.c.diff
===================================================================
--- files/src__util.c.diff	(revision 0)
+++ files/src__util.c.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/util.c.orig	Sun Nov 14 15:48:13 2004
++++ src/util.c	Sun Nov 14 15:48:22 2004
+@@ -273,7 +273,7 @@
+ 			case 'S': /* check and turn into 's' */
+ 				ss = va_arg(p, char *);
+ 				if (!is_shell_safe(ss, (s[1] == 'Q')))
+-					return NOT_SAFE;
++					return my_strdup(NOT_SAFE);
+ 				len += strlen(ss);
+ 				s[1] = 's';
+ 				break;
Index: files/PR3939085.diff
===================================================================
--- files/PR3939085.diff	(revision 0)
+++ files/PR3939085.diff	(revision 0)
@@ -0,0 +1,26 @@
+--- src/manfile.c.orig	2006-06-01 17:16:00.000000000 -0700
++++ src/manfile.c	2006-06-01 17:37:31.000000000 -0700
+@@ -147,10 +147,14 @@
+ static char **
+ glob_for_file (const char *dir, const char *sec, const char *name, int type) {
+      char **names;
++     char shortsec[2];
+ 
+      if (debug >= 2)
+ 	 gripe(CALLTRACE2, dir, sec, name, type);
+ 
++     shortsec[0] = sec[0];
++     shortsec[1] = '\0';
++
+      if (standards & DO_IRIX) {
+ 	  /* try first without `sec' extension */
+ 	  /* maybe this should be done only for cat pages? */
+@@ -158,7 +162,7 @@
+      }
+ 
+      /* try /usr/X11R6/man/man3x/XSetFont.3x */
+-     names = glob_for_file_ext (dir, sec, name, sec, type);
++     names = glob_for_file_ext (dir, shortsec, name, sec, type);
+ 
+      if (!names)
+ 	  return 0;		/* out-of-memory or error */
Index: Portfile
===================================================================
--- Portfile	(revision 55374)
+++ Portfile	(working copy)
@@ -4,6 +4,7 @@
 
 name			man
 version			1.6f
+revision		1
 categories		sysutils
 platforms		darwin
 maintainers		mww
@@ -19,16 +20,24 @@
                 patch-configure-prepath \
 				patch-gencat-genlib.c \
 				patch-man2html_Makefile.in \
-				configure.diff
-patch_sites		http://www.opensource.apple.com/darwinsource/10.4.8.ppc/man-4/patches/
+				configure.diff \
+				PR3845474.diff \
+				PR3857969.diff \
+				PR3939085.diff \
+				PR4006198.diff \
+				PR4062483.diff \
+				PR4076593.diff \
+				PR4302566.diff \
+				PR4670363.diff \
+				src__man-getopt.c.diff \
+				src__man.c.diff \
+				src__manpath.c.diff \
+				src__util.c.diff \
+				src__man.conf.in.diff
 
-checksums		${distfiles} md5 67aaaa6df35215e812fd7d89472c44b6 \
-				${distfiles} sha1 c97012607ed9d75a6eee7e66d257a99a8ed86918 \
-				${distfiles} rmd160 8680bb94bff9b86fb9d061f58d9acb08c934531e \
-				\
-				configure.diff md5 9b9b0c22f7249391dfafe905ac8837ab \
-				configure.diff sha1 1754a380d8b1b1e1a5c5ebb66fbda69adfdb4aae \
-				configure.diff rmd160 5a3a5bdc0c5f0653393b5078a9f275bd7df8c59c
+checksums		md5 67aaaa6df35215e812fd7d89472c44b6 \
+				sha1 c97012607ed9d75a6eee7e66d257a99a8ed86918 \
+				rmd160 8680bb94bff9b86fb9d061f58d9acb08c934531e
 
 configure.args	--mandir=${prefix}/share/man \
 				-compatibility_mode_for_colored_groff \
@@ -47,3 +56,7 @@
 variant man_all_lang {
 	configure.args-append +lang all
 }
+
+platform darwin 8 {
+    patchfiles-delete   src__man.conf.in.diff
+}
