Subject: man bug fix
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Christos Zoulas <christos@deshaw.com>
List: current-users
Date: 05/19/1994 14:21:06
Explained in the patch....

christos

*** src/usr.bin/man/man.c.dist	Sun Apr 17 06:23:28 1994
--- src/usr.bin/man/man.c	Thu May 19 14:14:13 1994
***************
*** 484,489 ****
--- 484,490 ----
  	ENTRY *ep;
  	TAG *intmpp;
  	int fd;
+ 	char *p;
  	char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[sizeof(_PATH_TMP)];
  
  	/* Let the user know this may take awhile. */
***************
*** 492,503 ****
  		warnx("Formatting manual page...");
  	}
  
  	/* Add a remove-when-done list. */
  	if ((intmpp = getlist("_intmp")) == NULL)
  		intmpp = addlist("_intmp");
  
  	/* Move to the printf(3) format string. */
! 	for (; *fmt && isspace(*fmt); ++fmt);
  
  	/*
  	 * Get a temporary file and build a version of the file
--- 493,520 ----
  		warnx("Formatting manual page...");
  	}
  
+ 	/*
+ 	 * Historically man chdir'd to the root of the man tree. 
+ 	 * This was used in man pages that contained relative ".so"
+ 	 * directives (including other man pages for command aliases etc.)
+ 	 * It even went one step farther, by examining the first line
+ 	 * of the man page and parsing the .so filename so it would
+ 	 * make hard(?) links to the cat'ted man pages for space savings.
+ 	 * (We don't do that here, but we could).
+ 	 */
+ 	strcpy(buf, *pathp);
+ 	if ((p = strrchr(buf, '/')) != NULL) {
+ 		strcpy(++p, "..");
+ 		chdir(buf);
+ 	}
+ 
  	/* Add a remove-when-done list. */
  	if ((intmpp = getlist("_intmp")) == NULL)
  		intmpp = addlist("_intmp");
  
  	/* Move to the printf(3) format string. */
! 	for (; *fmt && isspace(*fmt); ++fmt)
! 		continue;
  
  	/*
  	 * Get a temporary file and build a version of the file

------------------------------------------------------------------------------