From db224b5b077a48e1eb4de21fbf079c377499b16d Mon Sep 17 00:00:00 2001 From: gdr-ftp Date: Sun, 29 Mar 1998 07:16:25 +0000 Subject: [PATCH] - modifications for compilation under GNO v2.0.6 base build. See the README for details of changes. --- usr.bin/man/Makefile | 106 +++++++++++ usr.bin/man/README | 57 ++++-- usr.bin/man/apropos.1 | 1 - usr.bin/man/apropos.c | 33 ++-- usr.bin/man/apropos.rez | 10 + usr.bin/man/apropos2.c | 51 ++--- usr.bin/man/catman.8 | 29 +-- usr.bin/man/catman.c | 44 ++--- usr.bin/man/catman.rez | 10 + usr.bin/man/common.c | 2 +- usr.bin/man/common.rez | 19 ++ usr.bin/man/describe.man | 50 ----- usr.bin/man/fillbuffer.c | 48 +++-- usr.bin/man/globals.c | 9 +- usr.bin/man/makefile.mk | 70 ------- usr.bin/man/makewhatis.8 | 8 +- usr.bin/man/makewhatis.c | 37 ++-- usr.bin/man/makewhatis.h | 27 --- usr.bin/man/makewhatis.rez | 10 + usr.bin/man/man.1 | 12 +- usr.bin/man/man.c | 34 ++-- usr.bin/man/man.h | 104 ++++++---- usr.bin/man/man.rez | 10 + usr.bin/man/man2.c | 197 ++++++++++--------- usr.bin/man/manpack.desc | 49 +++++ usr.bin/man/mkso.data | 8 + usr.bin/man/process.c | 15 +- usr.bin/man/util.c | 381 ++++++++++++------------------------- usr.bin/man/util.h | 37 ---- usr.bin/man/utilgs.c | 9 +- usr.bin/man/whatis.1 | 19 +- usr.bin/man/whatis.c | 28 ++- usr.bin/man/whatis.rez | 10 + 33 files changed, 745 insertions(+), 789 deletions(-) create mode 100644 usr.bin/man/Makefile delete mode 100644 usr.bin/man/apropos.1 create mode 100644 usr.bin/man/apropos.rez create mode 100644 usr.bin/man/catman.rez create mode 100644 usr.bin/man/common.rez delete mode 100644 usr.bin/man/describe.man delete mode 100644 usr.bin/man/makefile.mk delete mode 100644 usr.bin/man/makewhatis.h create mode 100644 usr.bin/man/makewhatis.rez create mode 100644 usr.bin/man/man.rez create mode 100644 usr.bin/man/manpack.desc create mode 100644 usr.bin/man/mkso.data delete mode 100644 usr.bin/man/util.h create mode 100644 usr.bin/man/whatis.rez diff --git a/usr.bin/man/Makefile b/usr.bin/man/Makefile new file mode 100644 index 0000000..984930c --- /dev/null +++ b/usr.bin/man/Makefile @@ -0,0 +1,106 @@ +# +# Devin Reade, 1998 +# +# $Id: Makefile,v 1.1 1998/03/29 07:15:38 gdr-ftp Exp $ +# + +CUSTOM_RULES = true # provide our own build rules +CUSTOM_RELEASE = true # provide our own release and install targets + +# +# Define: -DDEBUG to produce more debugging info and checks +# +# -DSTACK_CHECK to show stack usage. If you use this +# one, ensure you add -l/usr/lib/stack to your LDLIBS. +# +DEFINES += +STACK = 1280 +LDADD = -lcontrib +BINDIR = /usr/bin +SBINDIR = /usr/sbin +DESC = manpack.desc + +.INCLUDE: /src/gno/prog.mk + +RELSBIN = $(RELEASE_DIR)$(SBINDIR) + +PROGS = $(OBJ_DIR)apropos $(OBJ_DIR)catman $(OBJ_DIR)makewhatis \ + $(OBJ_DIR)man $(OBJ_DIR)whatis + +APROPOS_OBJ = apropos.o apropos2.o util.o globals.o +CATMAN_OBJ = catman.o util.o globals.o common.o +MAKEWHATIS_OBJ = makewhatis.o fillbuffer.o process.o +MAN_OBJ = man.o man2.o apropos2.o util.o globals.o common.o +WHATIS_OBJ = whatis.o apropos2.o util.o globals.o + +MAINCFLAGS = $(CFLAGS:s/ -r / /g) + +build: $(OBJ_DIR) $(LOCAL_SETUP) $(PROGS) + +$(OBJ_DIR)apropos: $(APROPOS_OBJ) apropos.r + $(CC) $(LDFLAGS) $(OBJ_DIR){$(APROPOS_OBJ)} $(LDLIBS) -o $@ + $(CATREZ) -d $@ $*.r + +$(OBJ_DIR)catman: $(CATMAN_OBJ) catman.r + $(CC) $(LDFLAGS) $(OBJ_DIR){$(CATMAN_OBJ)} $(LDLIBS) -o $@ + $(CATREZ) -d $@ $*.r + +$(OBJ_DIR)makewhatis: $(MAKEWHATIS_OBJ) makewhatis.r + $(CC) $(LDFLAGS) $(OBJ_DIR){$(MAKEWHATIS_OBJ)} $(LDLIBS) -o $@ + $(CATREZ) -d $@ $*.r + +$(OBJ_DIR)man: $(MAN_OBJ) man.r + $(CC) $(LDFLAGS) $(OBJ_DIR){$(MAN_OBJ)} $(LDLIBS) -o $@ + $(CATREZ) -d $@ $*.r + +$(OBJ_DIR)whatis: $(WHATIS_OBJ) whatis.r + $(CC) $(LDFLAGS) $(OBJ_DIR){$(WHATIS_OBJ)} $(LDLIBS) -o $@ + $(CATREZ) -d $@ $*.r + +apropos.o: apropos.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c apropos.c +catman.o: catman.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c catman.c +makewhatis.o: makewhatis.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c makewhatis.c +man.o: man.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c man.c +whatis.o: whatis.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c whatis.c + +$(OBJ_DIR):; $(INSTALL) -d $(OBJ_DIR) + +M1 = man.1 whatis.1 +M8 = catman.8 makewhatis.8 +DIRS = $(SBINDIR) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8 +RELDIRS = $(RELSBIN) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8 $(DESC_DIR) + +release: $(PROGS) $(M1) $(M8) $(DESC) + $(INSTALL) -d $(RELSBIN) $(RELBIN) $(RELMAN)/man1 $(RELMAN)/man8 + $(INSTALL) -d $(DESC_DIR) + $(INSTALL) apropos man whatis $(RELBIN) + $(INSTALL) catman makewhatis $(RELSBIN) + $(INSTALL) $(M1) $(RELMAN)/man1 + $(INSTALL) $(M8) $(RELMAN)/man8 + $(DESCU) -o $(DESC_SRC) $(DESC_SRC) $(DESC) + +install: $(PROGS) $(M1) $(M8) + $(INSTALL) -d $(SBINDIR) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8 + $(INSTALL) apropos man whatis $(BINDIR) + $(INSTALL) catman makewhatis $(SBINDIR) + $(INSTALL) $(M1) $(MANDIR)/man1 + $(INSTALL) $(M8) $(MANDIR)/man8 + +# additional dependancies +apropos.o: man.h +apropos2.o: man.h +catman.o: man.h +common.o: man.h +fillbuffer.o: man.h +globals.o: man.h +makewhatis.o: man.h +man.o: man.h +man2.o: man.h +process.o: man.h +util.o: man.h +whatis.o: man.h +apropos.r: common.rez +catman.r: common.rez +makewhatis.r: common.rez +man.r: common.rez +whatis.r: common.rez diff --git a/usr.bin/man/README b/usr.bin/man/README index be167ef..0d93431 100644 --- a/usr.bin/man/README +++ b/usr.bin/man/README @@ -1,7 +1,7 @@ -------------------------------------------- Name: manpack -Version: 3.0 -Author: Devin Reade +Version: 3.1 +Author: Devin Reade Computer: Apple IIgs Requires: GNO v2.x -------------------------------------------- @@ -10,13 +10,14 @@ Requires: GNO v2.x Description: =========== -Various programs for working with manual pages. This archive includes: +Various programs for working with manual pages. This archive includes +the following utilities. All utilities have their versions lockstepped: - apropos v3.0 locate commands by keyword - catman v1.0 format cat pages from man pages - makewhatis v1.2 create the whatis database - man v3.0 display reference manual pages - whatis v3.0 locate commands by name + apropos locate commands by keyword + catman format cat pages from man pages + makewhatis create the whatis database + man display reference manual pages + whatis locate commands by name ============ Installation: @@ -26,23 +27,26 @@ Type at the command line `dmake install`. You may wish to first verify the destination directories in "Makefile.mk". By default these are: - BINDIR = /usr/bin (apropos, catman, man, and whatis) - SBINDIR = /usr/sbin (makewhatis) + BINDIR = /usr/bin (apropos, man, and whatis) + SBINDIR = /usr/sbin (catman, and makewhatis) MANDIR = /usr/man (all manual pages) Ensure that all older versions of these programs are deleted. They may or may not be in the above directories. +If you're building a GNO release in the base builds, then use the +command `dmake release`. + ========== Legalities: ========== -These utilities are copyright 1995 by Devin Reade . +These utilities are copyright 1995-1998 by Devin Reade . They are provided as freeware, and may be distributed by Internet -archive sites, online services such as GEnie, or BBSes provided that +archive sites, online services such as Delphi, or BBSes provided that the archive remains intact. Permission is granted for distribution -with GNO/ME and Orca provided credit for this work is given along +with GNO and ORCA provided credit for this work is given along with any other attributions. Inclusion of these utilities in collections on disk, CD-ROM, or @@ -52,20 +56,27 @@ author regarding other commercial distributions. Updates to these utilities may be distributed provided that the source and this README file are included. Please follow the coding style -already in use and document your changes in this file. +already in use and document your changes in this file. Better yet, +email me with your suggested changes and I'll consider incorporating +them into the base distribution. ======= CHANGES: ======= apropos, whatis + v3.1 (28 Mar 98) + Incorporated all utilities into the GNO base build. All + versions are now lockstepped. + + Searches are no longer case sensitive. v3.0 (24 Jul 95) Complete rewrite from scratch by Devin Reade. This version makes use of MANPATH in the same way as man(1) v3.0. Similarily, it will also search - the 17/syscmnd Orca database. + the 17/syscmnd ORCA database. In the previous version, the behavior of apropos was identical to that of whatis. This version has been @@ -81,11 +92,21 @@ apropos, whatis because it shipped with man(1) v2.1. catman + v3.1 (28 Mar 98) + Incorporated all utilities into the GNO base build. All + versions are now lockstepped. v1.0 (24 Jul 95) Initial release. Written from scratch by Devin Reade. makewhatis + v3.1 (28 Mar 98) + Incorporated all utilities into the GNO base build. All + versions are now lockstepped. + + Don't use binary mode to read the files; this doesn't + give the right results with the GNO v2.0.6 stdio package + since we're doing calls to fgets() at times. v1.2 (24 Jul 95) Fixed bug where pages in "manl" ending in ".l" (that's @@ -149,6 +170,12 @@ makewhatis Initial release. Written from scratch by Devin Reade. man + v3.1 (28 Mar 98) + Incorporated all utilities into the GNO base build. All + versions are now lockstepped. + + Searches are no longer case sensitive. + v3.0 (24 Jul 95) Complete rewrite from scratch by Devin Reade. diff --git a/usr.bin/man/apropos.1 b/usr.bin/man/apropos.1 deleted file mode 100644 index c50da82..0000000 --- a/usr.bin/man/apropos.1 +++ /dev/null @@ -1 +0,0 @@ -.so man1/whatis.1 diff --git a/usr.bin/man/apropos.c b/usr.bin/man/apropos.c index c49e9f2..3e3318f 100644 --- a/usr.bin/man/apropos.c +++ b/usr.bin/man/apropos.c @@ -1,41 +1,36 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: apropos.c,v 1.2 1998/03/29 07:15:42 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "apropos___"; +#endif #include -#include #include -#include -#include "util.h" +#include +#include +#include #include "man.h" -extern int optind; -extern char *optarg; - -static char *versionstr = "3.0"; +static char *versionstr = VERSION_STR; static char *nothing = "nothing appropriate"; -extern void begin_stack_check(void); -extern int end_stack_check(void); - int main (int argc, char **argv) { char *path; int i, matches1, matches2, matches3; short V_flag, M_flag, m_flag, n_flag, err_flag; - /* make sure Gno is running */ + /* make sure GNO is running */ if (needsgno()==0) { - fprintf(stderr,"Requires Gno/ME\n"); - return 1; + errx(1, "Requires GNO\n"); } -#ifdef STACK_CHECK - begin_stack_check(); -#endif + __REPORT_STACK(); /* initialization */ V_flag = M_flag = m_flag = n_flag = err_flag = 0; @@ -101,10 +96,6 @@ int main (int argc, char **argv) { fprintf(stderr,"%s: %s\n",basename(argv[0]),nothing); } -#ifdef STACK_CHECK - fprintf(stderr,"stack usage: %d bytes\n",end_stack_check()); -#endif - if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0; return 1; } diff --git a/usr.bin/man/apropos.rez b/usr.bin/man/apropos.rez new file mode 100644 index 0000000..1d26aa7 --- /dev/null +++ b/usr.bin/man/apropos.rez @@ -0,0 +1,10 @@ +/* + * $Id: apropos.rez,v 1.1 1998/03/29 07:15:43 gdr-ftp Exp $ + */ + +#include "Types.Rez" + +#define PROG "apropos" +#define DESC "Locate commands by keyword" + +#include "common.rez" diff --git a/usr.bin/man/apropos2.c b/usr.bin/man/apropos2.c index f0bc098..331a985 100644 --- a/usr.bin/man/apropos2.c +++ b/usr.bin/man/apropos2.c @@ -1,10 +1,15 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: apropos2.c,v 1.2 1998/03/29 07:15:45 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "apropos2__"; +#pragma noroot +#endif #include #include @@ -13,7 +18,7 @@ segment "apropos2__"; #include #include #include -#include "util.h" +#include #include "man.h" /* @@ -21,7 +26,8 @@ segment "apropos2__"; * length of the command */ -static char *orcapadding (char *command) { +static char * +orcapadding (char *command) { int i; static char *two ="\t\t"; static char *one ="\t"; @@ -40,9 +46,10 @@ static char *orcapadding (char *command) { * orcacommand() modifies the buffer. */ -static char *orcacomment (char *buffer) { +static char * +orcacomment (char *buffer) { char *p; - static char *bad_line="malformed SYSCMND line\n"; + static char *bad_line = "malformed SYSCMND line\n"; p = buffer; @@ -91,7 +98,8 @@ static char *orcacomment (char *buffer) { * modifies the buffer. */ -static char *orcacommand(char *buffer) { +static char * +orcacommand(char *buffer) { char *p; p = buffer; @@ -136,12 +144,14 @@ static char *orcacommand(char *buffer) { * WARNING: Use of the MAN_F_MODE may alter the contents of argv[]. */ -int apropos(int argc, char **argv, int apropos_mode) { +int +apropos(int argc, char **argv, int apropos_mode) { char **manpath_array; char *current_path, *p, *q, *r, *keyword; FILE *fp; char dirbrk; int i, j, matches; + LC_StringArray_t sarray; #ifdef DEBUG assert ((apropos_mode == WHATIS_MODE) || @@ -193,8 +203,10 @@ int apropos(int argc, char **argv, int apropos_mode) { /* loop over keywords */ for(i=0; ilc_vec; /* * loop over all the paths in MANPATH @@ -240,31 +253,24 @@ int apropos(int argc, char **argv, int apropos_mode) { keyword = argv[j]; switch (apropos_mode) { case MAN_F_MODE: - if (strstr(linebuf,keyword)) { - printf("%s",linebuf); - matches++; - } - break; case MAN_K_MODE: - if (ncstrstr(linebuf,keyword)) { + if (strcasestr(linebuf,keyword)) { printf("%s",linebuf); matches++; } break; case WHATIS_MODE: /* avoid unnecessary strcpy's */ - if (strstr(linebuf,keyword)==NULL) break; + if (strcasestr(linebuf,keyword)==NULL) break; strcpy(linebuf2,linebuf); if ((p = strchr(linebuf2,'(')) != NULL) *p = '\0'; - if (strstr(linebuf2,keyword)) { + if (strcasestr(linebuf2,keyword)) { printf("%s",linebuf); matches++; } break; default: - fprintf(stderr,"internal error line %d of %s\n", - __LINE__,__FILE__); - exit(1); + errx(1, "internal error at %s:%d", __FILE__, __LINE__); } } } else if (ferror(fp)) { @@ -280,5 +286,6 @@ int apropos(int argc, char **argv, int apropos_mode) { current_path = manpath_array[i]; } /* endwhile loop over directories */ + LC_StringArrayDestroy(sarray); return matches; } diff --git a/usr.bin/man/catman.8 b/usr.bin/man/catman.8 index 59433f9..cb9b62e 100644 --- a/usr.bin/man/catman.8 +++ b/usr.bin/man/catman.8 @@ -1,6 +1,9 @@ -.\" Copyright (c) 1995 Devin Reade . All rights reserved. +.\" Copyright (c) 1995-1997 Devin Reade . +.\" All rights reserved. .\" -.TH CATMAN 8 "System Administration" "24 July 95" "Version 1.0" +.\" $Id: catman.8,v 1.2 1998/03/29 07:15:47 gdr-ftp Exp $ +.\" +.TH CATMAN 8 "28 March 1998" GNO "System Administration" .SH NAME catman \- format cat pages from man pages .SH SYNOPSIS @@ -74,16 +77,6 @@ on to the list of paths for which manual pages will be updated. Display version information and exit. .IP \fB-v\fR Verbose. Show processing information. -.SH BUGS -Please report any bugs to Devin Reade, . -.SH SEE ALSO -.BR apropos (1), -.BR man (1), -.BR whatis (1), -.BR gzip (1), -.BR compress (1), -.BR freeze (1), -.BR makewhatis (8). .SH WARNING .BR catman will unlink any out-of-date files in the @@ -93,3 +86,15 @@ subdirectories. The files that would be unlinked are listed when is invoked with the .BR -p option. +.SH VERSION +This manual page documents +.BR catman +version 3.1. +.SH SEE ALSO +.BR apropos (1), +.BR man (1), +.BR whatis (1), +.BR gzip (1), +.BR compress (1), +.BR freeze (1), +.BR makewhatis (8). diff --git a/usr.bin/man/catman.c b/usr.bin/man/catman.c index 921bc0a..c7f1f3a 100644 --- a/usr.bin/man/catman.c +++ b/usr.bin/man/catman.c @@ -1,37 +1,34 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: catman.c,v 1.2 1998/03/29 07:15:48 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "catman____"; +#endif #include +#include #include -#include #include #include -#include #include #include #include #include -#include #include -#include "util.h" +#include +#include #include "man.h" -#define OVERFLOW_ABORT(line,file) { \ - fprintf(stderr,overflowMsg,line,file); \ - exit(1); \ -} +#define OVERFLOW_ABORT(line,file) errx(1, overflowMsg, line, file) short v_flag, V_flag, M_flag, m_flag, p_flag, err_flag; -extern int optind; -extern char *optarg; - -static char *versionstr = "1.0"; +static const char *versionstr = VERSION_STR; /* This is of the form "man
" */ char mandir[FILENAME_MAX]; @@ -48,9 +45,6 @@ char base[FILENAME_MAX]; static char *overflowMsg = "internal buffer overflow at line %d of %s\n"; -extern void begin_stack_check(void); -extern int end_stack_check(void); - /* * catman * @@ -83,9 +77,11 @@ int catman(int argc, char **argv) { fileType *ftype; /* the file type of the man page */ struct stat statbuf1, statbuf2; char dirbrk; + LC_StringArray_t sarray; /* create array of paths to search */ - if ((manpath_array = makePathArray(manpath)) == NULL) return 1; + sarray = MakePathArray(manpath); + manpath_array = sarray->lc_vec; /* loop over paths in MANPATH */ pathIndex=0; @@ -271,20 +267,16 @@ int catman(int argc, char **argv) { } } - int main (int argc, char **argv) { char *path; int i, result1, result2; - /* make sure Gno is running */ + /* make sure GNO is running */ if (needsgno()==0) { - fprintf(stderr,"Requires Gno/ME\n"); - return 1; + errx(1, "Requires GNO\n"); } -#ifdef STACK_CHECK - begin_stack_check(); -#endif + __REPORT_STACK(); /* initialization */ v_flag = V_flag = M_flag = m_flag = p_flag = err_flag = 0; @@ -348,9 +340,5 @@ int main (int argc, char **argv) { result2 = catman(argc-optind, &argv[optind]); } -#ifdef STACK_CHECK - fprintf(stderr,"stack usage: %d bytes\n",end_stack_check()); -#endif - return (result1 || result2); } diff --git a/usr.bin/man/catman.rez b/usr.bin/man/catman.rez new file mode 100644 index 0000000..f8f7414 --- /dev/null +++ b/usr.bin/man/catman.rez @@ -0,0 +1,10 @@ +/* + * $Id: catman.rez,v 1.1 1998/03/29 07:15:50 gdr-ftp Exp $ + */ + +#include "Types.Rez" + +#define PROG "catman" +#define DESC "Preformat manual pages" + +#include "common.rez" diff --git a/usr.bin/man/common.c b/usr.bin/man/common.c index e20abe8..7caacb0 100644 --- a/usr.bin/man/common.c +++ b/usr.bin/man/common.c @@ -1,5 +1,5 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. */ diff --git a/usr.bin/man/common.rez b/usr.bin/man/common.rez new file mode 100644 index 0000000..05cf5d4 --- /dev/null +++ b/usr.bin/man/common.rez @@ -0,0 +1,19 @@ +/* + * This file is intended to be #included by the other *.rez files. + * + * $Id: common.rez,v 1.1 1998/03/29 07:15:53 gdr-ftp Exp $ + */ + +#include "/src/gno/build.tools/builddate.rez" + +resource rVersion (0x1, purgeable3, nocrossbank) { + + { 3, 1, 0, /* version */ + release, /* development|alpha|beta|final|release */ + 0 /* non-final release number */ + }, + verUS, + PROG, + DESC "\nWritten by Devin Reade for GNO\n" + BUILD_DATE +}; diff --git a/usr.bin/man/describe.man b/usr.bin/man/describe.man deleted file mode 100644 index 4954e80..0000000 --- a/usr.bin/man/describe.man +++ /dev/null @@ -1,50 +0,0 @@ -Name: apropos -Version: 3.0 (24 Jul 95) -Author: Devin Reade. -Contact: gdr@myrias.com -Where: /usr/bin -FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu - - Locate commands by keyword. Bundled with catman, makewhatis, -man, and whatis in the manpack30.shk archive. - -Name: catman -Version: 1.0 (24 Jul 95) -Author: Devin Reade. -Contact: gdr@myrias.com -Where: /usr/sbin -FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu - - Preformat manual reference pages. Bundled with apropos, makewhatis, -man, and whatis in the manpack30.shk archive. - -Name: makewhatis -Version: 1.2 (24 Jul 95) -Author: Devin Reade. -Contact: gdr@myrias.com -Where: /usr/sbin -FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu - - Create the whatis database used by man(1), apropos(1), and whatis(1). -Bundled with apropos, catman, man, and whatis in the manpack30.shk archive. - -Name: man -Version: 3.0 (24 Jul 95) -Author: Devin Reade. -Contact: gdr@myrias.com -Where: /usr/bin -FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu - - Display manual reference pages. Bundled with apropos, catman, -makewhatis, and whatis in the manpack30.shk archive. - -Name: whatis -Version: 3.0 (24 Jul 95) -Author: Devin Reade. -Contact: gdr@myrias.com -Where: /usr/bin -FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu - - Locate commands by name. Bundled with apropos, catman, -makewhatis, and man in the manpack30.shk archive. - diff --git a/usr.bin/man/fillbuffer.c b/usr.bin/man/fillbuffer.c index 3cd4b38..0492a09 100644 --- a/usr.bin/man/fillbuffer.c +++ b/usr.bin/man/fillbuffer.c @@ -1,15 +1,21 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: fillbuffer.c,v 1.4 1998/03/29 07:15:55 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "makewhatis"; +#pragma noroot +#endif #include #include #include -#include "makewhatis.h" +#include +#include "man.h" #define NAME1 "NAME" #define NAME2 "N\bNA\bAM\bME\bE" @@ -86,7 +92,7 @@ void fillbuffer (char *filename) { * open the file */ - if ((fp = fopen(filename,"rb")) == NULL) { + if ((fp = fopen(filename,"r")) == NULL) { buffer[0] = '\0'; if (v_flag) fprintf (error_fp,"Open failed for file \"%s\"\n",filename); return; @@ -141,7 +147,7 @@ void fillbuffer (char *filename) { /* we need the previous newline for the next algorithm to work */ - fseek(fp,-1L,SEEK_CUR); + ungetc('\n', fp); /* * Make p1 point to spot in buffer2 where there occurs the first @@ -188,7 +194,7 @@ void fillbuffer (char *filename) { */ if (in_comment) { - while((p1. For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: globals.c,v 1.2 1998/03/29 07:15:58 gdr-ftp Exp $ */ -#include #include "man.h" +#ifndef NULL +#define NULL 0x0L +#endif + /* * The compression suffixes and how to uncompress the files. * If you use ".l" (that's "ell") as a suffix, you will break the diff --git a/usr.bin/man/makefile.mk b/usr.bin/man/makefile.mk deleted file mode 100644 index 0f00321..0000000 --- a/usr.bin/man/makefile.mk +++ /dev/null @@ -1,70 +0,0 @@ -# -# Makefile for the man package, for use with dmake(1). -# - -# Location for executables. They should normally be /usr/sbin and /usr/bin. - -SBINDIR = /usr/sbin -BINDIR = /usr/bin - -# Location for man pages. Usually /usr/man. - -MANDIR = /usr/man - -# -# You should not have to change anything below this line -# -# Define: -DDEBUG to produce more debugging info and checks -# -# -DSTACK_CHECK to show stack usage. If you use this -# one, ensure you add -l/usr/lib/stack to your LDLIBS. -# - -STACK = -s1270 -DEFINES = -CFLAGS = $(DEFINES) $(STACK) -w -v -O -I/usr/include -LDFLAGS = -v -LDLIBS = -l/usr/lib/gnulib -l/usr/lib/stack -CP = /bin/cp -f - -build: apropos catman makewhatis man whatis - -apropos: apropos.o apropos2.o util.o utilgs.o globals.o - $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@ - -catman: catman.o util.o utilgs.o globals.o common.o - $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@ - -makewhatis: makewhatis.o fillbuffer.o process.o - $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@ - -man: man.o man2.o apropos2.o util.o utilgs.o globals.o common.o - $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@ - -whatis: whatis.o apropos2.o util.o utilgs.o globals.o - $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@ - -clobber: - $(RM) *.o *.root - -install: - $(CP) apropos man whatis $(BINDIR) - $(CP) catman makewhatis $(SBINDIR) - $(CP) apropos.1 man.1 whatis.1 $(MANDIR)/man1 - $(CP) catman.8 makewhatis.8 $(MANDIR)/man8 - -# additional dependancies - -apropos.o:: man.h util.h -apropos2.o:: man.h util.h -catman.o:: man.h util.h -common.o:: man.h util.h -fillbuffer.o:: makewhatis.h -globals.o:: man.h -makewhatis.o:: makewhatis.h -man.o:: man.h util.h -man2.o:: man.h util.h -process.o:: makewhatis.h -util.o:: util.h -utilgs.o:: util.h -whatis.o:: man.h util.h diff --git a/usr.bin/man/makewhatis.8 b/usr.bin/man/makewhatis.8 index 5200fd2..d434be8 100644 --- a/usr.bin/man/makewhatis.8 +++ b/usr.bin/man/makewhatis.8 @@ -1,4 +1,4 @@ -.TH MAKEWHATIS 8 "System Administration" "24 July 1995" "Version 1.2" +.TH MAKEWHATIS 8 "28 March 1998" GNO "System Administration" .SH NAME .B makewhatis \- generate the whatis database file @@ -22,6 +22,10 @@ .B -V ] .SH DESCRIPTION +This manual page documents +.B makewhatis +version 3.1. +.LP .B makewhatis generates the whatis database for .BR apropos (1), @@ -286,7 +290,7 @@ of the input buffer, you may see formatting infomation such as in the output. This was not fixed due to the overhead of having to check for such a condition. .LP -Please report any additional bugs to Devin Reade, . +Please report any additional bugs to Devin Reade, . .SH FILES .nf /usr/[share/]man/whatis -- the whatis database diff --git a/usr.bin/man/makewhatis.c b/usr.bin/man/makewhatis.c index 3d35b79..cb55ca4 100644 --- a/usr.bin/man/makewhatis.c +++ b/usr.bin/man/makewhatis.c @@ -1,10 +1,14 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: makewhatis.c,v 1.4 1998/03/29 07:16:01 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "makewhatis"; +#endif #include #include @@ -13,15 +17,8 @@ segment "makewhatis"; #include #include #include -#include "getopt.h" -#include - -#include "makewhatis.h" - -#ifdef STACK_CHECK - extern void begin_stack_check(void); - extern int end_stack_check(void); -#endif +#include +#include "man.h" /* * Options: @@ -55,7 +52,7 @@ char *man_subdir[] = { }; /* - * we include cat* since some Gno utility man pages aren't written in + * we include cat* since some GNO utility man pages aren't written in * either nroff or aroff source ... go figure. */ @@ -90,14 +87,12 @@ static char progdir[FILENAME_MAX]; /* the directory where makewhatis started */ FILE *output_fp; FILE *error_fp; - int main (int argc, char **argv) { - + static char tmp_file[L_tmpnam]; /* a scratch file */ char *manpath; /* the location of the man pages */ char *path; /* the current path; taken from manpath */ char *p=NULL; /* a temporary pointer */ struct dirent *file; /* the current file we have open */ - char tmp_file[L_tmpnam]; /* a scratch file */ FILE *tmp_fp; /* pointer to tmp_file */ FILE *whatis_fp; /* pointer to the current whatis database */ DIR *subdir; /* the current man subdirectory -- eg: /usr/man/man3 */ @@ -107,15 +102,13 @@ int main (int argc, char **argv) { extern int optind; extern char *optarg; - /* make sure Gno is running */ + /* make sure GNO is running */ if (needsgno()==0) { - fprintf(stderr,"Requires Gno/ME\n"); + fprintf(stderr,"Requires GNO\n"); return 1; } -#ifdef STACK_CHECK - begin_stack_check(); -#endif + __REPORT_STACK(); /* * set the defaults @@ -173,7 +166,7 @@ int main (int argc, char **argv) { case 'V': fprintf(stderr, "%s --\n\tCreate the %s database.\n\tVersion %s by Devin Reade\n\n", - argv[0],WHATIS,VERSIONSTRING); + argv[0],WHATIS,VERSION_STR); errflag++; break; default: @@ -326,9 +319,5 @@ Aborted.\n", if (output_fp != stdout) fclose(output_fp); if (error_fp != stderr) fclose(error_fp); -#ifdef STACK_CHECK - fprintf(stderr,"Makewhatis stack usage: %d bytes\n",end_stack_check()); -#endif - return 0; } diff --git a/usr.bin/man/makewhatis.h b/usr.bin/man/makewhatis.h deleted file mode 100644 index 9bf75b1..0000000 --- a/usr.bin/man/makewhatis.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 1995 by Devin Reade . For distribution - * information see the README file that is part of the manpack archive, - * or contact the author, above. - */ - -#define VERSIONSTRING "1.2" -#define ISGRAPH_FIX 1 - -/* The size of the IO buffers */ -#define BUFFERSIZE 1024 - -/* The default name for the whatis database */ -#define WHATIS "whatis" - -/* The number of characters per tab in the whatis database */ -#define TABLENGTH 8 - -#define DEFAULT_MANPATH "/usr/man" - -extern int chdir (const char *); -extern int system (const char *); - -void fillbuffer (char *filename); -void process (char *filename, char *tmp_file, FILE *whatis_fp, char *sec); - -extern short v_flag; diff --git a/usr.bin/man/makewhatis.rez b/usr.bin/man/makewhatis.rez new file mode 100644 index 0000000..9a84884 --- /dev/null +++ b/usr.bin/man/makewhatis.rez @@ -0,0 +1,10 @@ +/* + * $Id: makewhatis.rez,v 1.1 1998/03/29 07:16:04 gdr-ftp Exp $ + */ + +#include "Types.Rez" + +#define PROG "makewhatis" +#define DESC "Create the whatis(1) database." + +#include "common.rez" diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 317f2bf..283b0e3 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -3,10 +3,10 @@ .\" specifies the terms and conditions for redistribution. .\" .\" While this manual page is based on one from UCB, the included -.\" C source, makefile, and executables are copyright (c) 1995 -.\" by Devin Reade . All rights reserved. +.\" C source, makefile, and executables are copyright (c) 1995-1998 +.\" by Devin Reade . All rights reserved. .\" -.TH MAN 1 "Commands and Applications" "24 July 95" "Version 3.0" +.TH MAN 1 "28 March 1998" GNO "Commands and Applications" .SH NAME man \- display reference manual pages; find reference pages by keyword .SH SYNOPSIS @@ -33,6 +33,10 @@ man \- display reference manual pages; find reference pages by keyword .I filename \&.\|.\|. .SH DESCRIPTION +This manual page documents +.BR man +version 3.0. +.LP .B man displays information from the reference manuals. It can display complete manual pages that you select by @@ -511,7 +515,7 @@ and preprocessors is not yet implemented. Since these preprocessors do not as yet exist for GNO, this is not too much of a problem. .LP -Please report any other bugs to Devin Reade, . +Please report any other bugs to Devin Reade, . .SH HISTORY The GNO version of .BR man diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index 9bce7bc..7a07209 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,30 +1,28 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: man.c,v 1.2 1998/03/29 07:16:07 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "man_______"; +#endif #include -#include #include #include -#include #include #include #include #include -#include "util.h" +#include +#include #include "man.h" -#ifdef DEBUG - extern void begin_stack_check(void); - extern int end_stack_check(void); -#endif - char *macroPackage = "an"; /* default /usr/lib/tmac/tmac.an */ -char *versionStr = "Version 3.0 by Devin Reade"; +char *versionStr = VERSION_STR; char *pager; char *troff; char *tcat; @@ -53,15 +51,12 @@ int main (int argc, char **argv) { extern int optind; extern char *optarg; - /* make sure Gno is running */ + /* make sure GNO is running */ if (needsgno()==0) { - fprintf(stderr,"Requires Gno/ME\n"); - return 1; + err(1, "Requires GNO"); } -#ifdef STACK_CHECK - begin_stack_check(); -#endif + __REPORT_STACK(); /* * initialization @@ -86,7 +81,7 @@ int main (int argc, char **argv) { break; case 'M': M_flag++; - manpath = Xstrdup(optarg,__LINE__,__FILE__); + manpath = LC_xstrdup(optarg); break; case 'n': n_flag++; @@ -145,10 +140,5 @@ int main (int argc, char **argv) { } free(manpath); result = ((result == 0) && (i == 0)) ? 0 : 1; - -#ifdef STACK_CHECK - fprintf(stderr,"stack usage: %d bytes\n",end_stack_check()); -#endif - return result; } diff --git a/usr.bin/man/man.h b/usr.bin/man/man.h index 251f90a..41e2859 100644 --- a/usr.bin/man/man.h +++ b/usr.bin/man/man.h @@ -1,27 +1,49 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: man.h,v 1.2 1998/03/29 07:16:09 gdr-ftp Exp $ */ +#ifndef _STDIO_H_ +#include +#endif + +#ifndef _GNO_CONTRIB_H_ +#include +#endif + /* * Configuration info */ -#define WHATIS "whatis" -#define PAGER "/bin/more" -#define SYSCMND "15/syscmnd" +#define VERSION_STR "3.1" -#define AROFF "aroff" -#define NROFF "nroff" -#define TROFF "troff -t" -#define TCAT "lpr -t" -#define CAT "cat" -#define EQN "eqn" -#define REFER "refer" -#define TBL "tbl" -#define VGRIND "vgrind" +/* Defaults */ +#define WHATIS "whatis" /* basename of the whatis database */ +#define SYSCMND "15/syscmnd" /* full path of the ORCA syscmnd file */ +#define DEFAULT_MANPATH "/usr/man" /* default $MANPATH */ +/* The names of various programs */ +#define PAGER "/bin/more" +#define AROFF "aroff" +#define NROFF "nroff" +#define TROFF "troff -t" +#define TCAT "lpr -t" +#define CAT "cat" +#define EQN "eqn" +#define REFER "refer" +#define TBL "tbl" +#define VGRIND "vgrind" + +/* The number of characters per tab in the whatis database */ +#define TABLENGTH 8 + +/* The size of the IO buffers */ +#define BUFFERSIZE 2048 + +/* File types */ #define NON 0x00 #define TXT 0x04 #define BIN 0x06 @@ -34,18 +56,24 @@ #define ORCA_K_MODE 5 #define ORCA_W_MODE 6 -#define BUFFERSIZE 2048 -typedef struct Section_tag { - char *name; /* section name */ - char *suffix; /* directory suffix */ +typedef struct Section { + char *name; /* section name */ + char *suffix; /* directory suffix */ } Section; -typedef struct { - char *suffix; - char *extractor; +typedef struct compressionType { + char *suffix; + char *extractor; } compressionType; +typedef struct fileType { + unsigned int type; + unsigned long int auxtype; +} fileType, *fileTypePtr; + +fileType * getFileType (const char *file); + /* * from globals.c */ @@ -69,27 +97,19 @@ extern char *macroPackage; extern short hyphen_flag; extern short n_flag; extern short t_flag; +extern short v_flag; -/* - * from apropos2.c - */ +LC_StringArray_t MakePathArray (char *path); +int apropos(int argc, char **argv, int whole_line); +void fillbuffer (char *filename); +char * getManpath (void); +int getSuffixIndex(char *name); +char getcharraw (void); +int man (int argc, char *argv[]); +char * newerFile (char *path1, char *path2); +void process (char *filename, char *tmp_file, FILE *whatis_fp, + char *sec); +char * strcasestr (char *str, char *substr); +int whatis(int argc, char **argv); -int apropos(int argc, char **argv, int whole_line); - -/* - * from whatis2.c - */ - -int whatis(int argc, char **argv); - -/* - * from man2.c - */ -int man (int argc, char *argv[]); - - -/* - * from common.c - */ - -int getSuffixIndex(char *name); + diff --git a/usr.bin/man/man.rez b/usr.bin/man/man.rez new file mode 100644 index 0000000..425e10b --- /dev/null +++ b/usr.bin/man/man.rez @@ -0,0 +1,10 @@ +/* + * $Id: man.rez,v 1.1 1998/03/29 07:16:10 gdr-ftp Exp $ + */ + +#include "Types.Rez" + +#define PROG "man" +#define DESC "Display manual reference pages" + +#include "common.rez" diff --git a/usr.bin/man/man2.c b/usr.bin/man/man2.c index 6e08cda..63d1423 100644 --- a/usr.bin/man/man2.c +++ b/usr.bin/man/man2.c @@ -1,10 +1,15 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: man2.c,v 1.2 1998/03/29 07:16:12 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "man2______"; +#pragma noroot +#endif #include #include @@ -17,15 +22,16 @@ segment "man2______"; #include #include #include -#include "util.h" +#include +#include #include "man.h" #define MAX(a,b) ((a) > (b)) ? (a) : (b) -static char **buildManList(char *suffix, char *name); -static void display(char *list); -static char *getBaseName (char *out, char *in); -static void cleanManList(char **list); +static LC_StringArray_t buildManList(char *suffix, char *name); +static LC_StringArray_t makePathArray(const char *manpath); +static void display(char *list); +static char * getBaseName (char *out, char *in); /* * Pre: argc is the number of strings in argv. It should either be 1 or 2. @@ -49,7 +55,7 @@ static void cleanManList(char **list); */ int man(int argc, char *argv[]) { - char **manpath_array, **manpagelist; + LC_StringArray_t manpath_array, manpagelist; char *sec, *name, *current_path; Section *section; int i, j, k, abort; @@ -66,10 +72,10 @@ int man(int argc, char *argv[]) { if (t_flag) { if ((tcat = getenv("TCAT")) == NULL) { tcat = TCAT; - } else tcat = Xstrdup(tcat,__LINE__,__FILE__); + } else tcat = LC_xstrdup(tcat); if ((troff = getenv("TROFF")) == NULL) { troff = TROFF; - } else troff = Xstrdup(troff,__LINE__,__FILE__); + } else troff = LC_xstrdup(troff); } if (hyphen_flag) { pager = CAT; @@ -86,13 +92,13 @@ int man(int argc, char *argv[]) { case 2: sec = argv[0]; /* special case some section abbreviations */ - if (!strcmp(sec,"l")) { + if (!strcasecmp(sec,"l")) { sec = "local"; - } else if (!strcmp(sec,"n")) { + } else if (!strcasecmp(sec,"n")) { sec = "new"; - } else if (!strcmp(sec,"o")) { + } else if (!strcasecmp(sec,"o")) { sec = "old"; - } else if (!strcmp(sec,"p")) { + } else if (!strcasecmp(sec,"p")) { sec = "public"; } name = argv[1]; @@ -104,13 +110,15 @@ int man(int argc, char *argv[]) { } /* create array of paths to search */ - if ((manpath_array = makePathArray(manpath)) == NULL) return 1; + if ((manpath_array = makePathArray(manpath)) == NULL) { + return 1; + } /* * loop over all the paths in MANPATH */ i=0; - current_path = manpath_array[i]; + current_path = (manpath_array->lc_vec)[i]; while (!abort && current_path) { dirbrk = (strchr(current_path,':')!=NULL) ? ':' : '/'; @@ -118,7 +126,7 @@ int man(int argc, char *argv[]) { /* go to the current path in MANPATH */ if (chdir(current_path) == -1) { i++; - current_path = manpath_array[i]; + current_path = (manpath_array->lc_vec)[i]; continue; } @@ -129,9 +137,9 @@ int man(int argc, char *argv[]) { * if section number was specified and this isn't it, do * the next loop */ - if (sec && (strcmp(sec,sections[j].name) || + if (sec && (strcasecmp(sec,sections[j].name) || (!isdigit(*sec) && - strncmp(sec,sections[j].name,strlen(sec))))) continue; + strncasecmp(sec,sections[j].name,strlen(sec))))) continue; section_found++; /* @@ -140,11 +148,11 @@ int man(int argc, char *argv[]) { */ manpagelist = buildManList(sections[j].suffix,name); - if (!manpagelist) continue; + if (manpagelist->lc_used == 0) continue; page_found++; - for (k=0; !abort && manpagelist[k]; k++) { - display(manpagelist[k]); + for (k=0; !abort && k < manpagelist->lc_used; k++) { + display((manpagelist->lc_vec)[k]); if (!hyphen_flag && !t_flag) { fprintf(stderr, "type q to quit, or any other key for next man page: "); @@ -160,11 +168,11 @@ int man(int argc, char *argv[]) { } } - cleanManList(manpagelist); + LC_StringArrayDestroy(manpagelist); } /* done looping over sections */ i++; - current_path = manpath_array[i]; + current_path = (manpath_array->lc_vec)[i]; } /* done looping over paths */ @@ -189,19 +197,20 @@ int man(int argc, char *argv[]) { static const char *manstr="man"; static const char *catstr="cat"; -static char **buildManList(char *suffix, char *name) { +static LC_StringArray_t +buildManList(char *suffix, char *name) { static char buffer1[FILENAME_MAX]; static char buffer2[FILENAME_MAX]; DIR *directory; struct dirent *entry; - char **list1, **list2, **list3; + LC_StringArray_t list1, list2; size_t len; - int total1, total2, i, j, k; - char *p, *fn; + int i, j, k; + char *p, *fn, *L1, *L2; /* initialization */ - list1 = list2 = list3 = NULL; - total1 = total2 = 0; + list1 = LC_StringArrayNew(); + list2 = LC_StringArrayNew(); #ifdef DEBUG /* sanity check on arguments */ @@ -221,19 +230,19 @@ static char **buildManList(char *suffix, char *name) { /* skip if no match */ len = strlen(name); - if (strncmp(entry->d_name,name,len) || + if (strncasecmp(entry->d_name,name,len) || (entry->d_name[len] != '.')) continue; if (strlen(manstr) + strlen(suffix) + strlen(entry->d_name) + strlen(suffix) + 1 >= FILENAME_MAX) { - fprintf(stderr,"internal error: buffer overflow at line %d of %s\n", - __LINE__,__FILE__); + errx(1, "internal error: buffer overflow at line %s:%d\n", + __FILE__, __LINE__); } sprintf(buffer1,"%s%s:%s",manstr,suffix,entry->d_name); /* look for "links" to aroff files. (what a kludge) */ if ((buffer1[3] != 'l') && - (strcmp(".l",&buffer1[strlen(buffer1)-2])==0)) { + (strcasecmp(".l",&buffer1[strlen(buffer1)-2])==0)) { FILE *linkptr; char *tp; @@ -253,14 +262,12 @@ static char **buildManList(char *suffix, char *name) { fclose(linkptr); if (access(buffer2,R_OK) == 0) { - list1 = addToStringArray(list1, buffer2); - total1++; + LC_StringArrayAdd(list1, buffer2); } } } else { /* not a .l "link"; a normal file */ - list1 = addToStringArray(list1, buffer1); - total1++; + LC_StringArrayAdd(list1, buffer1); } } closedir(directory); @@ -277,7 +284,7 @@ static char **buildManList(char *suffix, char *name) { /* skip if no match */ len = strlen(name); - if (strncmp(entry->d_name,name,len) || + if (strncasecmp(entry->d_name,name,len) || (entry->d_name[len] != '.')) continue; if (strlen(catstr) + strlen(suffix) + strlen(entry->d_name) + @@ -286,8 +293,7 @@ static char **buildManList(char *suffix, char *name) { __LINE__,__FILE__); } sprintf(buffer1,"%s%s:%s",catstr,suffix,entry->d_name); - list2 = addToStringArray(list2, buffer1); - total2++; + LC_StringArrayAdd(list2, buffer1); } closedir(directory); } @@ -297,40 +303,34 @@ static char **buildManList(char *suffix, char *name) { * eliminate files common to both lists */ len = strlen(suffix); - for(i=0; ilc_used; i++) { + L1 = (list1->lc_vec)[i]; + for (j=0; j< list2->lc_used; j++) { + L2 = (list2->lc_vec)[j]; - getBaseName(buffer1,list1[i]); - getBaseName(buffer2,list2[j]); + getBaseName(buffer1, L1); + getBaseName(buffer2, L2); #ifdef DEBUG if ((strlen(buffer1) < len + 5) || (strlen(buffer2) < len + 5)) { - fprintf(stderr,"internal error at line %d of %s\n",__LINE__, - __FILE__); - exit(1); + err(1, "internal error at line %d of %s\n", __LINE__, __FILE__); } #endif /* match after the respective "manXX/" and "catXX/" */ - if ( strcmp(&buffer1[len+4],&buffer2[len+4]) == 0 ) { + if (strcasecmp(&buffer1[len+4],&buffer2[len+4]) == 0 ) { - p = newerFile(list1[i],list2[j]); - if (p == list1[i]) { - free(list2[j]); - list2[j] = NULL; - } else if (p == list2[j]) { - free(list1[i]); - list1[i] = NULL; - break; + p = newerFile(L1,L2); + if (p == L1) { + LC_StringArrayDelete(list2, L2); + --j; + } else if (p == (list2->lc_vec)[j]) { + LC_StringArrayDelete(list1, L1); + --i; + break; } else { - fprintf(stderr,"internal error at line %d of %s\n\t%s\n\t%s\n", - __LINE__,__FILE__, - (list1[i]) ? list1[i] : "(NULL)", - (list2[j]) ? list2[j] : "(NULL)"); - perror("newerFile failed"); - exit(1); + err(1, "internal error at %s:%d (newerFile failed)", + __FILE__, __LINE__); } } /* endif */ } /* endfor */ @@ -339,41 +339,12 @@ static char **buildManList(char *suffix, char *name) { /* * combine the two lists */ - for (i=0;ilc_used; + for (i=0; ilc_vec)[i]); } - for (j=0;j is a list of colon-delimited path names + * Post: returns a StringArray pointer where each string is an + * element of + */ + +static LC_StringArray_t +makePathArray(const char *manpath) { + LC_StringArray_t result; + char *pathcopy, *p; + + result = LC_StringArrayNew(); + pathcopy = LC_xstrdup(manpath); + p = strtok(pathcopy, ":"); + while (p != NULL) { + LC_StringArrayAdd(result, p); + p = strtok(NULL, ":"); + } + free(pathcopy); + return result; +} diff --git a/usr.bin/man/manpack.desc b/usr.bin/man/manpack.desc new file mode 100644 index 0000000..e81f124 --- /dev/null +++ b/usr.bin/man/manpack.desc @@ -0,0 +1,49 @@ +Name: apropos +Version: 3.1 (28 March 1998) +Author: Devin Reade. +Contact: gdr@trenco.gno.org +Where: /usr/bin +FTP: ftp.gno.org + +Locate commands by keyword. +Bundled with catman, makewhatis, man, and whatis in the manpack archive. + +Name: catman +Version: 3.1 (28 March 1998) +Author: Devin Reade. +Contact: gdr@trenco.gno.org +Where: /usr/sbin +FTP: ftp.gno.org + +Preformat manual reference pages. +Bundled with apropos, makewhatis, man, and whatis in the manpack archive. + +Name: makewhatis +Version: 3.1 (28 March 1998) +Author: Devin Reade. +Contact: gdr@trenco.gno.org +Where: /usr/sbin +FTP: ftp.gno.org + +Create the whatis database used by man(1), apropos(1), and whatis(1). +Bundled with apropos, catman, man, and whatis in the manpack archive. + +Name: man +Version: 3.1 (28 March 1998) +Author: Devin Reade. +Contact: gdr@trenco.gno.org +Where: /usr/bin +FTP: ftp.gno.org + +Display manual reference pages. +Bundled with apropos, catman, makewhatis, and whatis in the manpack archive. + +Name: whatis +Version: 3.1 (28 March 1998) +Author: Devin Reade. +Contact: gdr@trenco.gno.org +Where: /usr/bin +FTP: ftp.gno.org + +Locate commands by name. +Bundled with apropos, catman, makewhatis, and man in the manpack archive. diff --git a/usr.bin/man/mkso.data b/usr.bin/man/mkso.data new file mode 100644 index 0000000..bd51986 --- /dev/null +++ b/usr.bin/man/mkso.data @@ -0,0 +1,8 @@ +# 0 +# 1 The first column is the "real" man page; the second is the .so link. +# 2 All paths should be relative to the /usr/man directory. This list +# 3 should be kept sorted. +# 4 +# 5 $Id: mkso.data,v 1.1 1998/03/29 07:16:16 gdr-ftp Exp $ +# 6 +man1/whatis.1 man1/apropos.1 diff --git a/usr.bin/man/process.c b/usr.bin/man/process.c index b94d6ea..83d87b2 100644 --- a/usr.bin/man/process.c +++ b/usr.bin/man/process.c @@ -1,10 +1,15 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: process.c,v 1.4 1998/03/29 07:16:17 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "makewhatis"; +#pragma noroot +#endif #include #include @@ -13,8 +18,8 @@ segment "makewhatis"; #include #include #include - -#include "makewhatis.h" +#include +#include "man.h" /* These are the compression types */ #define NO_COMPRESS 0 @@ -59,7 +64,9 @@ void process (char *filename, char *tmp_file, FILE *whatis_fp, char *sec) { char *name; /* points to the file basename */ short compression; /* the compression type (if nec) */ - if (v_flag>=2) fprintf(output_fp,"Working on file %s/%s ...\n",sec,filename); + if (v_flag>=2) { + fprintf(output_fp,"Working on sec %s file %s ...\n", sec, filename); + } /* * get the file basename diff --git a/usr.bin/man/util.c b/usr.bin/man/util.c index f455dcb..26a4989 100644 --- a/usr.bin/man/util.c +++ b/usr.bin/man/util.c @@ -1,22 +1,31 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: util.c,v 1.2 1998/03/29 07:16:19 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "util______"; +#pragma noroot +#endif +#define __USE_DYNAMIC_GSSTRING__ + +#include #include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include #include -#include -#include "util.h" +#include +#include +#include +#include +#include +#include "man.h" /* * getManpath -- return a malloc'd copy of the MANPATH. If MANPATH @@ -33,147 +42,14 @@ char *getManpath(void) { if (manpath == NULL) manpath = getenv("MANDIR"); if (manpath == NULL) manpath = DEFAULT_MANPATH; - return Xstrdup(manpath,__LINE__,__FILE__); -} - -/* - * Xstrdup - a safe strdup; it will handle error conditions and exit - * one occurs - * - * line and file are arbitrary, but are expected to be the - * values of __LINE__ and __FILE__ respectively. - */ - -char *Xstrdup(char *oldstr, int line, char *file) { - char *newstr; - - if ((newstr = malloc(strlen(oldstr)+1)) == NULL) { - fprintf(stderr,"Xstrdup failed at line %d in file %s: %s\n",line, - file,strerror(errno)); - exit(1); - } - strcpy(newstr,oldstr); - return newstr; -} - -/* - * Xmalloc - a safe malloc; it will handle error conditions and exit - * if one occurs. - * - * line and file are arbitrary, but are expected to be the - * values of __LINE__ and __FILE__ respectively. - */ - -void *Xmalloc(size_t size, int line, char *file) { - char *p; - - if ((p = malloc(size)) == NULL) { - fprintf(stderr,"Xmalloc failed at line %d in file %s: %s\n",line, - file,strerror(errno)); - exit(1); - } - return ((void *) p); + return LC_xstrdup(manpath); } -/* - * Xrealloc - a safe realloc; it will handle error conditions and exit - * if one occurs. - * - * line and file are arbitrary, but are expected to be the - * values of __LINE__ and __FILE__ respectively. - */ - -void *Xrealloc(void *oldptr, size_t size, int line, char *file) { - char *p; - - if ((p = realloc(oldptr, size)) == NULL) { - fprintf(stderr,"Xrealloc failed at line %d in file %s: %s\n",line, - file,strerror(errno)); - exit(1); - } - return ((void *) p); -} - /* - * addToStringArray -- add a string to a NULL-terminated array of strings. - * If oldArray is NULL, then a new array is created, - * otherwise oldArray is expanded. - * - * WARNING: | Because of the allocation scheme used, any oldArray - * | passed to this routine _must_ be the return value - * | of a previous call to this routine. This does not - * | imply that only one array can be expanded by this - * | routine (any number may be expanded). - * - * The value of macro SLOTS_QUANTUM defined below is - * the number of array slots allocated at one time. The - * size of the string array is always a multiple of this - * value. - * - * Returns a pointer to an array that contains the old - * strings with the new one appended. The array is - * NULL-terminated. - */ - -#define SLOTS_QUANTUM 10 - -char **addToStringArray(char **oldArray, char *string) { - - char **result; - int slotsAlloced, slotsUsed; - - if (oldArray == NULL) { - - /* - * This is a new array; do the brute force approach - */ - - result = Xmalloc(SLOTS_QUANTUM * sizeof(char *), __LINE__, __FILE__); - result[0] = Xstrdup(string,__LINE__,__FILE__); - result[1] = NULL; - - } else { - - /* - * adding to and, if necessary, expanding an old array - */ - - /* determine slotsUsed and slotsAlloced */ - for (slotsUsed=0; oldArray[slotsUsed]; slotsUsed++); - - if (slotsUsed % SLOTS_QUANTUM == SLOTS_QUANTUM-1) { /* space for NULL */ - slotsAlloced = slotsUsed+1; - } else { - slotsAlloced = ((slotsUsed / SLOTS_QUANTUM) + 1) * SLOTS_QUANTUM; - } - -#ifdef DEBUG - assert(slotsUsed < slotsAlloced); -#endif - - /* expand number of slots if necessary */ - if (slotsUsed+1 < slotsAlloced) { - /* there are enough slots; add it to this array */ - result = oldArray; - } else { - /* we need more slots; expand the array */ - slotsAlloced += SLOTS_QUANTUM; - result = Xrealloc(oldArray, slotsAlloced * sizeof(char *), - __LINE__, __FILE__); - } - - /* add the string to the array */ - result[slotsUsed++] = Xstrdup(string, __LINE__, __FILE__); - result[slotsUsed] = NULL; - } - return result; -} - -/* - * makePathArray -- parse a path list and break it into a NULL-terminated - * array of paths. The original path is left unchanged. + * MakePathArray -- parse a path list and break it into a StringArray_t. + * The original path is left unchanged. * * The delimiter between paths may either be a ' ' or a ':'. * The delimiter is assumed to be a ':' if contains @@ -181,70 +57,42 @@ char **addToStringArray(char **oldArray, char *string) { * otherwise the delimiter is assumed to be a ' '. */ -char **makePathArray(char *path) { +LC_StringArray_t +MakePathArray(char *path) { + LC_StringArray_t result; + char *delim, *p, *q; - char *delim, *p, *q, **result; + /* set the delimiter */ + if ((strchr(path,' ')==NULL) && + strchr(path,':') && + strchr(path,'/')) { + delim = ":"; + } else { + delim = " "; + } - /* set the delimiter */ - if ( strchr(path,' ')==NULL && - strchr(path,':') && - strchr(path,'/')) { - delim = ":"; - } else { - delim = " "; - } + /* build the array */ +#ifndef __ORCAC__ + /* ORCA/C's strtok implementation doesn't modify the provided buffer */ + p = LC_xstrdup(path); +#else + p = path; +#endif + result = LC_StringArrayNew(); + q = strtok(p,delim); + while (q != NULL) { + LC_StringArrayAdd(result, q); + q = strtok(NULL,delim); + } - /* build the array */ - p = Xstrdup(path, __LINE__, __FILE__); - q = strtok(p,delim); - result = NULL; - while (q) { - result = addToStringArray(result, q); - q = strtok(NULL,delim); - } - - free(p); - return result; -} - - -/* - * ncstrcmp -- A case insensitive ("no-case") strcmp - */ - -int ncstrcmp(char *a, char *b) { - - while (*a && *b) { - if (*a == *b) { - a++; b++; - continue; - } - return ((int) *b - *a); - } - if (!*a && !*b) return 0; - return ((int) *b - *a); +#ifndef __ORCAC__ + free(p); +#endif + return result; } /* - * ncstrncmp -- A case insensitive ("no-case") strncmp - */ - -int ncstrncmp (char *a, char *b, unsigned int count) { - unsigned int i=0; - - for (i=0; i record2.st_mtime) ? path1 : path2; -} + /* one or both don't exist? */ + if (e1 && e2) { + return NULL; + } + if (e1) { + return path2; + } + if (e2) { + return path1; + } + /* both exist */ + return (sbuf1.st_mtime > sbuf2.st_mtime) ? path1 : path2; +} /* * getcharraw() - return the next character from stdin without waiting @@ -326,7 +188,8 @@ char *newerFile(char *path1, char *path2) { #define FAILED_CHAR '\0'; -char getcharraw(void) { +char +getcharraw(void) { short oldmode; struct sgttyb s; int count; @@ -348,39 +211,37 @@ char getcharraw(void) { } /* - * basename -- return a pointer to the base filename (all leading - * pathname components removed) of . _must_ - * point to a NULL-terminated string. + * getFileType -- Get the file type and auxillary file type of a file. + * On success it returns a pointer to an internal buffer + * containing the file type and aux type. On failure + * it returns NULL and sets errno. */ -char *basename (char *path) { - char *p, dirsep; +fileType *getFileType (char *file) { - dirsep = (strchr(path,':')) ? ':' : '/'; - if ((p = strrchr(path,dirsep)) != NULL) { - return p+1; - } else { - return path; + static FileInfoRecGS record; + static fileType result; + int i; + + /* set the parameters */ + record.pCount = 4; + if ((record.pathname = __C2GSMALLOC(file)) == NULL) { + return NULL; } -} -/* - * dirname -- return a pointer to a string consisting of the directory - * component of . This returns a pointer to an internal - * buffer, so the next call to dirname() will overwrite this - * buffer. must be a NULL-terminated string. - */ - -char *dirname (const char *path) { - static char buffer[FILENAME_MAX]; - char *p, dirsep; - - strcpy(buffer,path); - - dirsep = (strchr(buffer,':')) ? ':' : '/'; - if ((p = strrchr(buffer,dirsep)) != NULL) { - *p = '\0'; + /* get the info */ + GetFileInfoGS(&record); + i = _toolErr; + GIfree(record.pathname); + if (i) { + errno = _mapErr(i); + return NULL; } - return buffer; + + /* set the return value */ + result.type = record.fileType; + result.auxtype = record.auxType; + + return &result; } - + diff --git a/usr.bin/man/util.h b/usr.bin/man/util.h deleted file mode 100644 index 0efb0b8..0000000 --- a/usr.bin/man/util.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 1995 by Devin Reade . For distribution - * information see the README file that is part of the manpack archive, - * or contact the author, above. - */ - -/* - * from util.c - */ - -#define DEFAULT_MANPATH "/usr/man" - -char *getManpath(void); -char *Xstrdup(char *oldstr, int line, char *file); -void *Xmalloc(size_t size, int line, char *file); -void *Xrealloc(void *oldptr, size_t size, int line, char *file); -char **addToStringArray(char **oldArray, char *string); -char **makePathArray(char *path); -int ncstrcmp(char *a, char *b); -int ncstrncmp (char *a, char *b, unsigned int count); -char *ncstrstr(char *str, char *substr); -char *newerFile(char *path1, char *path2); -char getcharraw(void); -char *basename (char *path); -char *dirname (const char *path); - - -/* - * from utilgs.c - */ - -typedef struct { - unsigned int type; - unsigned long int auxtype; -} fileType, fileTypePtr; - -fileType *getFileType (char *file); diff --git a/usr.bin/man/utilgs.c b/usr.bin/man/utilgs.c index 8d6a069..55717ec 100644 --- a/usr.bin/man/utilgs.c +++ b/usr.bin/man/utilgs.c @@ -1,5 +1,5 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. */ @@ -17,8 +17,10 @@ segment "utilgs____"; extern GSString255Ptr __C2GSMALLOC(char *); extern int _mapErr(int); +#if 0 /* we should be able to use the GNO v2.0.6 libraries for this */ + /* - * access -- a replacement for the standard Gno one; this one will actually + * access -- a replacement for the standard GNO one; this one will actually * return 0 when testing X_OK on a directory. * * This one still has a bug in it: If the file is a shell command or sys @@ -52,7 +54,7 @@ int access(char *name, int mode) { /* - * chdir -- Replacement for the one normally shipping with Gno. + * chdir -- Replacement for the one normally shipping with GNO. * Returns -1 and sets errno on failure, instead of always * returning zero. */ @@ -92,6 +94,7 @@ int chdir (const char *pathname) { return 0; } +#endif /* 0 */ /* * getFileType -- Get the file type and auxillary file type of a file. diff --git a/usr.bin/man/whatis.1 b/usr.bin/man/whatis.1 index fdf00d3..abb5465 100644 --- a/usr.bin/man/whatis.1 +++ b/usr.bin/man/whatis.1 @@ -4,10 +4,10 @@ .\" specifies the terms and conditions for redistribution. .\" .\" While this manual page is based on one from UCB, the included -.\" C source, makefile, and executables are copyright (c) 1995 -.\" by Devin Reade . All rights reserved. +.\" C source, makefile, and executables are copyright (c) 1995-1998 +.\" by Devin Reade . All rights reserved. .\" -.TH WHATIS 1 "Commands and Applications" "24 July 95" "Version 3.0" +.TH WHATIS 1 "28 March 1998" GNO "Commands and Applications" .SH NAME whatis, apropos \- locate commands by name or keyword lookup .SH SYNOPSIS @@ -39,8 +39,7 @@ while shows which manual pages contain instances of any of the given .IR keyword (s) in their title line. -Each word is considered separately and, for -.BR apropos , +Each word is considered separately and, for the GNO implementation, the case of letters is ignored. Words which are part of other words are considered; when looking for .IR compile , @@ -55,6 +54,8 @@ If a line output by either of these commands starts with .fi you can enter +.BI man name +or .BI man " section name" to get its documentation. .SH OPTIONS @@ -167,14 +168,18 @@ flag, in turn, overrides this value.) See the description of the .B \-M flag for syntax details. +.SH VERSION +This manual page documents +.BR apropos +and +.BR whatis +versions 3.1. .SH FILES .\" .IP \fB/usr/\fR[\fBshare/\fR]\fBman/whatis\fR .BR /usr/ [ share/ ] man/whatis " \-" The .BR whatis (1) database. -.SH BUGS -Please report any bugs to Devin Reade, . .SH SEE ALSO .BR man (1), .BR whereis (1), diff --git a/usr.bin/man/whatis.c b/usr.bin/man/whatis.c index 25ca07a..d48a47d 100644 --- a/usr.bin/man/whatis.c +++ b/usr.bin/man/whatis.c @@ -1,41 +1,39 @@ /* - * Copyright 1995 by Devin Reade . For distribution + * Copyright 1995-1998 by Devin Reade . For distribution * information see the README file that is part of the manpack archive, * or contact the author, above. + * + * $Id: whatis.c,v 1.2 1998/03/29 07:16:24 gdr-ftp Exp $ */ +#ifdef __ORCAC__ segment "apropos___"; +#endif #include -#include #include -#include -#include "util.h" +#include +#include #include "man.h" extern int optind; extern char *optarg; -static char *versionstr = "3.0"; +static char *versionstr = VERSION_STR; static char *nothing = "nothing appropriate"; -extern void begin_stack_check(void); -extern int end_stack_check(void); - int main (int argc, char **argv) { char *path; int i, matches1, matches2, matches3; short V_flag, M_flag, m_flag, n_flag, err_flag; - /* make sure Gno is running */ + /* make sure GNO is running */ if (needsgno()==0) { - fprintf(stderr,"Requires Gno/ME\n"); + fprintf(stderr,"Requires GNO\n"); return 1; } -#ifdef STACK_CHECK - begin_stack_check(); -#endif + __REPORT_STACK(); /* initialization */ V_flag = M_flag = m_flag = n_flag = err_flag = 0; @@ -101,10 +99,6 @@ int main (int argc, char **argv) { fprintf(stderr,"%s: %s\n",basename(argv[0]),nothing); } -#ifdef STACK_CHECK - fprintf(stderr,"stack usage: %d bytes\n",end_stack_check()); -#endif - if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0; return 1; } diff --git a/usr.bin/man/whatis.rez b/usr.bin/man/whatis.rez new file mode 100644 index 0000000..76905ec --- /dev/null +++ b/usr.bin/man/whatis.rez @@ -0,0 +1,10 @@ +/* + * $Id: whatis.rez,v 1.1 1998/03/29 07:16:25 gdr-ftp Exp $ + */ + +#include "Types.Rez" + +#define PROG "whatis" +#define DESC "Locate commands by name." + +#include "common.rez"