From owner-freebsd-bugs Thu Nov 25 13:50: 8 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id C489014DCB for ; Thu, 25 Nov 1999 13:50:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id NAA51339; Thu, 25 Nov 1999 13:50:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from beach.frankfurt.netsurf.de (beach.frankfurt.netsurf.de [194.64.181.2]) by hub.freebsd.org (Postfix) with ESMTP id 56C0A14F0B for ; 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 ; 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 ; Thu, 25 Nov 1999 22:55:42 +0100 (CET) (envelope-from kd@frankfurt.netsurf.de) Message-Id: Date: Thu, 25 Nov 1999 22:55:42 +0100 (CET) From: Karl Dietz Reply-To: Karl.Dietz@frankfurt.netsurf.de To: FreeBSD-gnats-submit@freebsd.org In-Reply-To: <199911252135.WAA11339@p75.home> Subject: gnu/15091: add -I option to gnu groff and gnu soelim Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Nov 25 13:50:00 PST 1999 >Closed-Date: >Last-Modified: >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 >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message