[comp.sys.sequent] newmakewhatis

nelson@ecsvax.UUCP (jim nelson) (08/15/89)

As promised, here's my "newmakewhatis" to look in *.Z files in
/usr/man.  It's rough and crude and certainly doesn't represent
my best, but, as I said, the price is right; it seems to work
remarkably well, missing only those man-pages which are not
in "standard" format.  You should create separate directory into
which you save this file, then ushar (or sh) it there.  It will
make its new version of whatis in that directory.  You'll have
to move it manually over the top of /usr/lib/whatis.  There are
a lot of things that are "so obvious they don't need explaining..."
---jim
Jim Nelson, UNC-Wilmington/CS Dept.(919) 395-3300 
Wilmington NC 28403
usenet/bitnet: nelson@ecsvax
nelson@ecsvax.uncecs.edu or nelson@ecsvax.bitnet or {...,mcnc}!ecsvax!nelson
------ cut here ------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  MANIFEST Makefile README diffs extract.c kindex.c
#   mygetNAME.c
# Wrapped by nelson@uncw on Mon Aug 14 15:16:10 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(331 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   1	
X README                     1	
X diffs                      1	
X extract.c                  1	
X kindex.c                   1	
X mygetNAME.c                1	
END_OF_FILE
if test 331 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(445 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
Xall: mygetNAME extract diffs
Xdiffs: /usr/lib/makewhatis ./makewhatis
X	cp /usr/lib/makewhatis ./oldmakewhatis
X	cdiff -c ./oldmakewhatis ./makewhatis>diffs
XmygetNAME: mygetNAME.o kindex.o
X	cc -o mygetNAME mygetNAME.o kindex.o
Xextract: extract.o kindex.o
X	cc -o extract extract.o kindex.o
Xkindex.o: kindex.c
X	cc -c kindex.c
Xshar: Makefile mygetNAME.c extract.c kindex.c diffs README
X	makekit -m Makefile mygetNAME.c extract.c kindex.c diffs README
END_OF_FILE
if test 445 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(184 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XI started to send the entire "new" makewhatis, until I read
Xthe "nasty" copyright notice, so it's now just diffs suitable
Xfor Larry Wall's patch program.  Copyright is scary stuff ...
END_OF_FILE
if test 184 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'diffs' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'diffs'\"
else
echo shar: Extracting \"'diffs'\" \(1477 characters\)
sed "s/^X//" >'diffs' <<'END_OF_FILE'
X*** ./oldmakewhatis	Mon Aug 14 15:10:11 1989
X--- ./makewhatis	Sun Aug 13 20:27:20 1989
X***************
X*** 14 ****
X! rm -f /tmp/whatis$$
X--- 14,16 ----
X! #rm -f /tmp/whatis*
X! # you can do the above manually!
X! dir=`pwd`
X***************
X*** 21,22 ****
X! done >/tmp/whatis$$
X! ex - /tmp/whatis$$ <<\!
X--- 23,51 ----
X! done >/tmp/whatisa 2> ${dir}/stderra.out &
X! 
X! #jhn
X! cd ${DESTDIR}/usr/man
X! for i in cat1
X! do
X! 	cd $i
X! 	for j in *
X! 	do
X! 		man  `${dir}/extract $j` |
X! 		${dir}/mygetNAME 
X! 	done
X! 	cd ..
X! done >/tmp/whatisb 2>${dir}/stderrb.out &
X! for i in cat2 cat3 cat4 cat5 cat6 cat7 cat8
X! do
X! 	cd $i
X! 	for j in *
X! 	do
X! 		man  `${dir}/extract $j` |
X! 		${dir}/mygetNAME 
X! 	done
X! 	cd ..
X! done >/tmp/whatisc 2>${dir}/stderrc.out &
X! wait
X! cat /tmp/whatisa /tmp/whatisb /tmp/whatisc>/tmp/whatis
X! #endjhn
X! 
X! ex - /tmp/whatis <<\!
X***************
X*** 31,33 ****
X! /usr/ucb/expand -24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 /tmp/whatis$$ | sort | /usr/ucb/unexpand -a > ${DESTDIR}/usr/lib/whatis
X! chmod 644 ${DESTDIR}/usr/lib/whatis
X! rm -f /tmp/whatis$$
X--- 60,65 ----
X! #jhn
X! #/usr/ucb/expand -24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 /tmp/whatis | sort | /usr/ucb/unexpand -a > ${DESTDIR}/usr/lib/whatis
X! /usr/ucb/expand -24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 /tmp/whatis | sort | /usr/ucb/unexpand -a > ${dir}/whatis
X! #chmod 644 ${DESTDIR}/usr/lib/whatis
X! #rm -f /tmp/whatis
X! #endjhn
END_OF_FILE
if test 1477 -ne `wc -c <'diffs'`; then
    echo shar: \"'diffs'\" unpacked with wrong size!
fi
# end of 'diffs'
fi
if test -f 'extract.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'extract.c'\"
else
echo shar: Extracting \"'extract.c'\" \(503 characters\)
sed "s/^X//" >'extract.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <ctype.h>
Xmain(argc,argv)
Xchar **argv;
X{
X	char line[513];
X	int section = -1,i,j,zap=0;
X
X	fprintf(stderr,"%s\n",argv[1]);
X	if(argc<=1)exit(1);
X	strcpy(line,argv[1]);
X	for(i=strlen(line);i>=0;i--){
X		if(isdigit(line[i])&&section<0)section=line[i];
X		if(line[i]=='/'){
X			zap=1;
X			break;
X		}
X	}
X	if(zap && i>=0)line[i]=0;
X	if(zap)i++;
X	if(i<0)i=0;
X	for(j=i;line[j];j++)if(
X	  line[j]=='.'
X	&&isdigit(line[j+1]))break;
X	line[j]=0;
X	printf(" %c %s",section,line+i);
X	return 0;
X}
END_OF_FILE
if test 503 -ne `wc -c <'extract.c'`; then
    echo shar: \"'extract.c'\" unpacked with wrong size!
fi
# end of 'extract.c'
fi
if test -f 'kindex.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'kindex.c'\"
else
echo shar: Extracting \"'kindex.c'\" \(427 characters\)
sed "s/^X//" >'kindex.c' <<'END_OF_FILE'
Xkindex(s,t) 
Xchar s[],t[];
X{
X	int c,i,j,k;
X	c=s[0];
X	if(c==0){return -1;
X/*		i=puts("in kindex ... dummy, s[0] is zero");j=i;*/
X/*		puts(t);*/
X/*		if(i==j)exit(1);*/
X		}
X	c=t[0];
X	if(c==0){return -1;
X/*	i=puts("in kindex ... dummy, t[0] is zero");j=i;*/
X/*		puts(s);*/
X/*		if(j==i)exit(1);*/
X		}
X	for(i=0;s[i] !='\0'; i++){
X		for(j=i,k=0;t[k] !='\0' && s[j]==t[k];j++,k++)
X				;
X		if(t[k]=='\0')return (i);
X	}
X		return(-1);
X} 
END_OF_FILE
if test 427 -ne `wc -c <'kindex.c'`; then
    echo shar: \"'kindex.c'\" unpacked with wrong size!
fi
# end of 'kindex.c'
fi
if test -f 'mygetNAME.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mygetNAME.c'\"
else
echo shar: Extracting \"'mygetNAME.c'\" \(872 characters\)
sed "s/^X//" >'mygetNAME.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <ctype.h>
Xmain()
X{
X	int i,nl=0;
X	char *gets();
X	char line[513],title[513];
X	int gott, gotn;	
X	gott=gotn=0;
X	while(gets(line)==line){
X		if(nl>20){fprintf(stderr,"nl>20:%s\n",line);exit(1);}
X		else nl++;
X		if(*line==0)continue;
X		if(kindex(line,"anual")>=0){strcpy(title,line);gott=1;}
X		if(kindex(line,"ocal")>=0){strcpy(title,line);gott=1;}
X		if(kindex(line,"LOCAL")>=0){strcpy(title,line);gott=1;}
X
X		if(kindex(line,"NAME")==0){gotn=1;break;}
X	}
X	if(!gott || !gotn){
X		fprintf(stderr,
X		"gott=%d gotn=%d\n",gott,gotn);
X		exit(1);}
X	if(gets(line)!=line){
X	fprintf(stderr,"out of data\n");
X	
X	exit(1);}
X
X
X	for(i=0;title[i];i++){
X		if(title[i]==' '){
X			title[i]=0;
X			break;
X		}
X		if(isupper(title[i]))title[i]=tolower(title[i]);
X	}
X	for(i=0;line[i]!='-';i++) /* null */ ;
X	if(i>=strlen(line)-1)i=0;
X	printf("%s %s\n",title,line+i);
X	exit(0);
X}
END_OF_FILE
if test 872 -ne `wc -c <'mygetNAME.c'`; then
    echo shar: \"'mygetNAME.c'\" unpacked with wrong size!
fi
# end of 'mygetNAME.c'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Jim Nelson, UNC-Wilmington/CS Dept.(919) 395-3300 
Wilmington NC 28403
usenet/bitnet: nelson@ecsvax