diff -Narup man-1.5k.orig/gencat/genlib.c man-1.5k/gencat/genlib.c --- man-1.5k.orig/gencat/genlib.c 1997-12-02 08:23:30.000000000 -0500 +++ man-1.5k/gencat/genlib.c 2002-12-19 09:16:38.000000000 -0500 @@ -47,6 +47,7 @@ up-to-date. Many thanks. 01/14/91 4 nazgul Off by one on number specified entries */ +#undef _GNU_SOURCE #include #ifdef SYSV #include diff -Narup man-1.5k.orig/src/apropos.sh man-1.5k/src/apropos.sh diff -Narup man-1.5k.orig/src/man-getopt.c man-1.5k/src/man-getopt.c --- man-1.5k.orig/src/man-getopt.c 2002-07-17 15:32:32.000000000 -0400 +++ man-1.5k/src/man-getopt.c 2002-12-19 09:25:36.000000000 -0500 @@ -171,7 +171,7 @@ get_options_from_string(const char *s) { char **argvec; int optindsv; - if (!s) + if (!s || *s==0) return; /* In order to avoid having a list of options in two places, diff -Narup man-1.5k.orig/src/man.c man-1.5k/src/man.c --- man-1.5k.orig/src/man.c 2002-07-17 17:33:20.000000000 -0400 +++ man-1.5k/src/man.c 2002-12-19 09:19:05.000000000 -0500 @@ -300,7 +300,7 @@ ultimate_source (const char *name0) { if (strlen(name0) >= sizeof(ultname)) return name0; - strcpy(ultname, name0); + strncpy(ultname, name0, BUFSIZE-32); name = ultname; again: @@ -332,7 +332,7 @@ again: * .so files - we could glob for all possible extensions, * for now: only try .gz */ - else if (fp == NULL && get_expander(".gz") && + if (fp == NULL && get_expander(".gz") && strlen(name)+strlen(".gz") < BUFSIZE) { strcat(name, ".gz"); fp = fopen (name, "r"); @@ -361,7 +361,7 @@ again: beg++; end = beg; - while (*end != ' ' && *end != '\t' && *end != '\n' && *end != '\0') + while (*end != ' ' && *end != '\t' && *end != '\n' && *end != '\0' && (end-buf)sizeof(ultname)) _exit(1); goto again; } @@ -1197,6 +1200,20 @@ main (int argc, char **argv) { #endif + char *s; +#define CHECK(p, l) s=getenv(p); if(s && (strlen(s)>l)) { fprintf(stderr, "ERROR: Environment variable %s too long!\n", p); exit(1); } + + CHECK("LANG", 32); + CHECK("MANPAGER", 128); + CHECK("PAGER", 128); + CHECK("SYSTEM", 64); + CHECK("MANROFFSEQ", 128); + CHECK("MANSECT", 128); + CHECK("MANPL", 128); + CHECK("MAN_HP_DIREXT", 128); + CHECK("LANGUAGE", 128); + CHECK("LC_MESSAGES", 128); + #ifndef __FreeBSD__ /* Slaven Rezif: FreeBSD-2.2-SNAP does not recognize LC_MESSAGES. */ setlocale(LC_CTYPE, ""); /* used anywhere? maybe only isdigit()? */ diff -Narup man-1.5k.orig/src/makewhatis.sh man-1.5k/src/makewhatis.sh --- man-1.5k.orig/src/makewhatis.sh 2002-07-17 14:59:05.000000000 -0400 +++ man-1.5k/src/makewhatis.sh 2002-12-19 09:24:14.000000000 -0500 @@ -41,7 +41,7 @@ # and should be first. # It is a bug to add /var/cache/man to DEFCATPATH. dm= -for d in /usr/man /usr/share/man +for d in /usr/share/man /usr/X11R6/man /usr/local/man /usr/man do if [ -d $d ]; then if [ x$dm = x ]; then dm=$d; else dm=$dm:$d; fi @@ -49,13 +49,13 @@ done DEFMANPATH=$dm dc= -for d in /usr/man/preformat /usr/man /usr/share/man/preformat /usr/share/man +for d in /var/cache/man /usr/share/man/preformat /usr/man/preformat do if [ -d $d ]; then if [ x$dc = x ]; then dc=$d; else dc=$dc:$d; fi fi done -DEFCATPATH=$dc +DEFCATPATH=$dc:$DEFMANPATH # In case /usr is read-only, make /usr/man/whatis (etc) a symlink to # something like /var/cache/man/whatis. @@ -70,12 +70,12 @@ # We try here to be careful (and avoid preconstructed symlinks) # in case makewhatis is run as root, by creating a subdirectory of /tmp. -TMPFILEDIR=/tmp/whatis.tmp.dir.$$ -rm -rf TMPFILEDIR -if ! mkdir -m 0700 $TMPFILEDIR; then - echo Could not create $TMPFILEDIR - exit 1; +TMPFILEDIR=`mktemp -d /tmp/makewhatisXXXXXX` +if [ $? -ne 0 ]; then + echo "$0: Can't create temp file, exiting..." + exit 1 fi +chmod 0700 $TMPFILEDIR TMPFILE=$TMPFILEDIR/w # make sure TMPFILEDIR is deleted if program is killed or terminates @@ -109,8 +109,10 @@ continue;; -s) setsections=1 continue;; - -u) findarg="-ctime 0" - update=1 + -u) if [ -e /var/cache/man/whatis ]; then + findarg="-newer /var/cache/man/whatis" + update=1 + fi continue;; -v) verbose=1 continue;; @@ -149,14 +151,7 @@ # first truncate all the whatis files that will be created new, # then only update - we might visit the same directory twice if [ x$update = x ]; then - for pages in man cat - do - eval path="\$$pages"path - for mandir in $path - do - cp /dev/null $mandir/whatis - done - done + cp /dev/null /var/cache/man/whatis fi for pages in man cat @@ -165,14 +160,10 @@ eval path="\$$pages"path for mandir in $path do - if [ x$verbose != x ]; then - echo "about to enter $mandir" > /dev/stderr - fi - if [ -s ${mandir}/whatis -a $pages = man -a x$update = x ]; then - if [ x$verbose != x ]; then - echo skipping $mandir - we did it already > /dev/stderr - fi - else + [ -d "$mandir" ] || continue + if [ x$verbose != x ]; then + echo "about to enter $mandir" > /dev/stderr + fi here=`pwd` cd $mandir for i in $sections @@ -391,23 +382,14 @@ cd $here - # kludge for Slackware's /usr/man/preformat - if [ $mandir = /usr/man/preformat ] - then - mandir1=/usr/man - else - mandir1=$mandir - fi - - if [ -f ${mandir1}/whatis ] + if [ -f /var/cache/man/whatis ] then - cat ${mandir1}/whatis >> $TMPFILE + cat /var/cache/man/whatis >> $TMPFILE fi - sed '/^$/d' < $TMPFILE | sort | uniq > ${mandir1}/whatis + sed '/^$/d' < $TMPFILE | sort | uniq > /var/cache/man/whatis - chmod 644 ${mandir1}/whatis + chmod 644 /var/cache/man/whatis rm $TMPFILE - fi done done --- man-1.5k.orig/src/apropos.sh 2001-11-22 18:30:42.000000000 -0500 +++ man-1.5k/src/apropos.sh 2002-12-19 09:16:09.000000000 -0500 @@ -18,9 +18,9 @@ program=`basename $0` # When man pages in your favorite locale look to grep like binary files # (and you use GNU grep) you may want to add the 'a' option to *grepopt1. -aproposgrepopt1='i' +aproposgrepopt1='ia' aproposgrepopt2='' -whatisgrepopt1='iw' +whatisgrepopt1='iwa' whatisgrepopt2='^' grepopt1=$%apropos_or_whatis%grepopt1 grepopt2=$%apropos_or_whatis%grepopt2