From kd@frankfurt.netsurf.de Thu Nov 25 13:48:52 1999
Return-Path: <kd@frankfurt.netsurf.de>
Received: from beach.frankfurt.netsurf.de (beach.frankfurt.netsurf.de [194.64.181.2])
	by hub.freebsd.org (Postfix) with ESMTP id 56C0A14F0B
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 1999 13:48:47 -0800 (PST)
	(envelope-from kd@frankfurt.netsurf.de)
Received: from p75.home (deck-216.frankfurt.netsurf.de [194.64.181.248])
	by beach.frankfurt.netsurf.de (8.8.5/8.8.5) with ESMTP id WAA17037
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 1999 22:48:43 +0100 (MET)
Received: from p75.home (p75.home [192.168.3.40])
	by p75.home (8.9.3/8.9.3) with ESMTP id WAA11591
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Nov 1999 22:55:42 +0100 (CET)
	(envelope-from kd@frankfurt.netsurf.de)
Message-Id: <Pine.BSF.4.10.9911252251590.11582-100000@p75.home>
Date: Thu, 25 Nov 1999 22:55:42 +0100 (CET)
From: Karl Dietz <kd@frankfurt.netsurf.de>
Reply-To: Karl.Dietz@frankfurt.netsurf.de
To: FreeBSD-gnats-submit@freebsd.org
In-Reply-To: <199911252135.WAA11339@p75.home>
Subject: add -I option to gnu groff and gnu soelim

>Number:         15091
>Category:       gnu
>Synopsis:       add -I option to gnu groff and gnu soelim
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 25 13:50:00 PST 1999
>Closed-Date:    Wed Jan 12 05:47:18 PST 2000
>Last-Modified:  Wed Jan 12 05:49:41 PST 2000
>Originator:     Karl Dietz
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
>Environment:



>Description:

	GNU groff does not know about a -I parameter to add
	include search paths.

	Peter Miller made a patch to add the -I and uses it in
	his programs.

	I maintain a prog by PM (ports/net/dnsutl) and got a
	request to add man pages to the port.

	The patch is for groff-1.11 but did apply cleanly to
	FreeBSD's groff-1.10.

	The original patch is at http://www.canb.aaug.org.au/~millerp/

	Patch by Peter Miller <millerp@canb.auug.org.au>
	

>How-To-Repeat:

	
	try to install man pages from ports/net/dnsutl/work/...

>Fix:
	
	
	apply this patch (or the one at Peter's page)


Index: src/contrib/groff/groff/groff.cc
===================================================================
RCS file: /home/ncvs/src/contrib/groff/groff/groff.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 groff.cc
--- groff.cc	1996/09/07 16:18:01	1.1.1.1
+++ groff.cc	1999/11/02 18:57:49
@@ -113,7 +113,7 @@
     command_prefix = PROG_PREFIX;
   commands[TROFF_INDEX].set_name(command_prefix, "troff");
   while ((opt = getopt(argc, argv,
-		       "itpeRsSzavVhblCENXZF:m:T:f:w:W:M:d:r:n:o:P:L:"))
+		       "abCd:eEf:F:hiI:lL:m:M:n:No:pP:r:RsStT:vVw:W:XzZ"))
 	 != EOF) {
     char buf[3];
     buf[0] = '-';
@@ -122,6 +122,10 @@
     switch (opt) {
     case 'i':
       iflag = 1;
+      break;
+    case 'I':
+      commands[SOELIM_INDEX].set_name(command_prefix, "soelim");
+      commands[SOELIM_INDEX].append_arg(buf, optarg);
       break;
     case 't':
       commands[TBL_INDEX].set_name(command_prefix, "tbl");
Index: src/contrib/groff/groff/groff.man
===================================================================
RCS file: /home/ncvs/src/contrib/groff/groff/groff.man,v
retrieving revision 1.2.4.1
diff -u -r1.2.4.1 groff.man
--- groff.man	1999/03/18 00:03:56	1.2.4.1
+++ groff.man	1999/11/02 18:58:06
@@ -48,6 +48,9 @@
 .BI \-F dir
 ]
 [
+.BI \-I dir
+]
+[
 .BI \-T dev
 ]
 [
@@ -150,6 +153,13 @@
 .TP
 .B \-s
 Preprocess with @g@soelim.
+.TP
+.BI \-I dir
+This option is as described in
+.BR @g@soelim (@MAN1EXT@) .
+This option implies the
+.B \-s
+option.
 .TP
 .B \-R
 Preprocess with @g@refer.
Index: src/contrib/groff/soelim/soelim.cc
===================================================================
RCS file: /home/ncvs/src/contrib/groff/soelim/soelim.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 soelim.cc
--- soelim.cc	1996/09/07 16:18:11	1.1.1.1
+++ soelim.cc	1999/11/02 18:58:14
@@ -29,23 +29,38 @@
 #include "error.h"
 #include "stringclass.h"
 
+static int include_list_length;
+static char **include_list;
+
 int compatible_flag = 0;
 
 extern int interpret_lf_args(const char *);
 
 int do_file(const char *filename);
 
+
+static void
+include_path_append(char *path)
+{
+	++include_list_length;
+	size_t nbytes = include_list_length * sizeof(include_list[0]);
+	include_list = (char **)realloc((void *)include_list, nbytes);
+	include_list[include_list_length - 1] = path;
+}
+
+
 void usage()
 {
-  fprintf(stderr, "usage: %s [ -vC ] [ files ]\n", program_name);
+  fprintf(stderr, "usage: %s [ -vCI: ] [ files ]\n", program_name);
   exit(1);
 }
 
 int main(int argc, char **argv)
 {
   program_name = argv[0];
+  include_path_append(".");
   int opt;
-  while ((opt = getopt(argc, argv, "vC")) != EOF)
+  while ((opt = getopt(argc, argv, "CI:v")) != EOF)
     switch (opt) {
     case 'v':
       {
@@ -57,6 +72,9 @@
     case 'C':
       compatible_flag = 1;
       break;
+    case 'I':
+      include_path_append(optarg);
+      break;
     case '?':
       usage();
       break;
@@ -125,17 +143,49 @@
 int do_file(const char *filename)
 {
   FILE *fp;
-  if (strcmp(filename, "-") == 0)
+  string whole_filename;
+  if (strcmp(filename, "-") == 0) {
     fp = stdin;
-  else {
+    whole_filename = filename;
+    whole_filename += '\0';
+  }
+  else if (filename[0] == '/') {
+    whole_filename = filename;
+    whole_filename += '\0';
     errno = 0;
     fp = fopen(filename, "r");
     if (fp == 0) {
       error("can't open `%1': %2", filename, strerror(errno));
       return 0;
     }
+  }
+  else {
+    size_t j;
+    for (j = 0; j < include_list_length; ++j)
+    {
+      char *path = include_list[j];
+      if (0 == strcmp(path, "."))
+      	whole_filename = filename;
+      else
+        whole_filename = string(path) + "/" + filename;
+      whole_filename += '\0';
+      errno = 0;
+      fp = fopen(whole_filename.contents(), "r");
+      if (fp != 0)
+      	break;
+      if (errno != ENOENT) {
+        error("can't open `%1': %2", whole_filename.contents(), strerror(errno));
+        return 0;
+      }
+    }
+    if (j >= include_list_length)
+    {
+      errno = ENOENT;
+      error("can't open `%1': %2", filename, strerror(errno));
+      return 0;
+    }
   }
-  current_filename = filename;
+  current_filename = whole_filename.contents();
   current_lineno = 1;
   set_location();
   enum { START, MIDDLE, HAD_DOT, HAD_s, HAD_so, HAD_l, HAD_lf } state = START;
Index: src/contrib/groff/soelim/soelim.man
===================================================================
RCS file: /home/ncvs/src/contrib/groff/soelim/soelim.man,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 soelim.man
--- soelim.man	1996/09/07 16:18:11	1.1.1.1
+++ soelim.man	1999/11/02 18:58:20
@@ -25,6 +25,9 @@
 .B \-Cv
 ]
 [
+.BI \-I dir
+]
+[
 .IR files \|.\|.\|.\|
 ]
 .SH DESCRIPTION
@@ -52,6 +55,16 @@
 Recognize
 .B .so
 even when followed by a character other than space or newline.
+.TP
+.BI \-I dir
+This option may be used to specify a directory to search for
+files (both those on the command line and those named in
+.B \&.so
+lines).
+The current directory is always searched first.
+This option may be specified more than once,
+the directories will be searched in the order specified.
+No directory search is performed for files specified using an absolute path.
 .TP
 .B \-v
 Print the version number.


>Release-Note:
>Audit-Trail:

From: Alexey Zelkin <phantom@cris.net>
To: Karl.Dietz@frankfurt.netsurf.de
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/15091: add -I option to gnu groff and gnu soelim
Date: Fri, 26 Nov 1999 23:17:06 +0300

 hi,
 
 On Thu, Nov 25, 1999 at 10:55:42PM +0100, Karl Dietz wrote:
  
 > >Number:         15091
 > >Category:       gnu
 > >Synopsis:       add -I option to gnu groff and gnu soelim
 
 > 	GNU groff does not know about a -I parameter to add
 > 	include search paths.
 Why ?
 
 > 
 > 	Peter Miller made a patch to add the -I and uses it in
 > 	his programs.
 You have to submit this patch to official groff maintainer and
 then next release out we'll import such change.
 
 > 
 > 	I maintain a prog by PM (ports/net/dnsutl) and got a
 > 	request to add man pages to the port.
 > 
 > 	The patch is for groff-1.11 but did apply cleanly to
 > 	FreeBSD's groff-1.10.
 We have groff-1.11 imported.
 
 -- 
 /* Alexey Zelkin                       && phantom@cris.net    */
 /* Tavric National University          && phantom@crimea.edu  */
 /* http://www.ccssu.crimea.ua/~phantom && phantom@FreeBSD.org */
 

From: Karl Dietz <kd@frankfurt.netsurf.de>
To: Alexey Zelkin <phantom@cris.net>
Cc: millerp@canb.aaug.org.au, FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/15091: add -I option to gnu groff and gnu soelim
Date: Sun, 28 Nov 1999 21:29:27 +0100 (CET)

 On Fri, 26 Nov 1999, Alexey Zelkin wrote:
 
 > > >Number:         15091
 > > >Category:       gnu
 > > >Synopsis:       add -I option to gnu groff and gnu soelim
 > 
 > > 	GNU groff does not know about a -I parameter to add
 > > 	include search paths.
 > Why ?
 
 I don't know why it's not supported. But if you mean
 "what do you need it for" to have a search path to common
 include (e.g. COPYRIGHT, etc.)
 
 > > 
 > > 	Peter Miller made a patch to add the -I and uses it in
 > > 	his programs.
 > You have to submit this patch to official groff maintainer and
 > then next release out we'll import such change.
 
 at the time this patch was prepared, there was no GNU groff maintainer.
 And GNU groff had not been updated to 1.11 quite a long time. (IIRC)
 
 
 I will talk to the original author to submit it to GNU groff.
 
 Regards,
          Karl
 
 

From: Karl Dietz <kd@frankfurt.netsurf.de>
To: Karl.Dietz@frankfurt.netsurf.de
Cc: Alexey Zelkin <phantom@cris.net>,
	FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: gnu/15091: add -I option to gnu groff and gnu soelim
Date: Tue, 30 Nov 1999 22:11:43 +0100 (CET)

 Hi Alexey,
 
 > > You have to submit this patch to official groff maintainer and
 > > then next release out we'll import such change.
 > 
 > at the time this patch was prepared, there was no GNU groff maintainer.
 > And GNU groff had not been updated to 1.11 quite a long time. (IIRC)
 > 
 > I will talk to the original author to submit it to GNU groff.
 
 I contacted the author. He said the patch has been accepted by groff
 maintainer, but not yet included.
 
 So this PR should either be changed to "please import new groff
 as soon as there is one" or closed.
 
 Regards,
          Karl
 
 
State-Changed-From-To: open->closed 
State-Changed-By: asmodai 
State-Changed-When: Wed Jan 12 05:47:18 PST 2000 
State-Changed-Why:  
The attached patch made it in groff 1.15.  This version got imported into 
CURRENT.  A MFC is scheduled in the near future when everything is considered 
to have not broken everything. 

This PR can be closed since I keep another PR open for the MFC and I made 
a note for myself about our soelim versus gsoelim in the groff package. 
>Unformatted:
