Proposed changes for text versions of man pages
Paul Eggert
eggert at twinsun.com
Sat Nov 8 01:31:59 UTC 2003
At Tue, 4 Nov 2003 09:45:11 -0500, "Olson, Arthur David (NIH/NCI)" <olsona at dc37a.nci.nih.gov> writes:
> + TXTS= newctime.3.txt newstrftime.3.txt newtzset.3.txt \
> + time2posix.3.txt tzfile.5.txt tzselect.8.txt \
> + zic.8.txt zdump.8.txt date.1.txt
> ...
> + newctime.3.txt: newctime.3
> + newstrftime.3.txt: newstrftime.3
> + newtzset.3.txt: newtzset.3
> + time2posix.3.txt: time2posix.3
> + tzfile.5.txt: tzfile.5
> + tzselect.8.txt: tzselect.8
> + zic.8.txt: zic.8
> + zdump.8.txt: zdump.8
> + date.1.txt: date.1
Rather than continue to maintain TXTS and these dependencies by hand,
how about if we use $(MANS) to derive the man pages? The patch
proposed below does this in a portable way.
> + ./workman $(@:.txt=) > $@
Since workman looks at stdin, stdin should be redirected to /dev/null
here, so that 'make' operates the same regardless of where stdin is.
If it matters, ancient 'make' implementations don't support the $(@:...
notation.
> + chmod +x $@
This should be "chmod a+x", perhaps?
> + tty -s
"tty -s" isn't portable (not required by POSIX); better to use plain "tty"
and redirect stdout.
> + if (($. % 66) <= 7) {
This calculation didn't work for me on Solaris, since Solaris nroff
uses different margins; the result was that the wrong lines were
deleted from the output. Rather than try to figure this out in Perl,
it's probably easier to fix it at the nroff level. Patch proposed
below.
> + 0) more ;;
This should probably look at the PAGER environment variable, for folks
who like 'less'.
Here's a proposed revamping of the patch.
===================================================================
RCS file: RCS/Makefile,v
retrieving revision 2002.2
diff -pu -r2002.2 Makefile
--- Makefile 2002/01/28 17:56:01 2002.2
+++ Makefile 2003/11/08 01:23:45
@@ -267,7 +267,7 @@ TABDATA= iso3166.tab zone.tab
DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
WEB_PAGES= tz-art.htm tz-link.htm
MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
- $(WEB_PAGES) checktab.awk
+ $(WEB_PAGES) checktab.awk workman.sh
ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
# And for the benefit of csh users on systems that assume the user
@@ -374,24 +374,35 @@ check_web: $(WEB_PAGES)
clean:
rm -f core *.o *.out tzselect zdump zic yearistype date \
- ,* *.tar.gz
+ ,* *.tar.gz *.made *.txt workman
names:
@echo $(ENCHILADA)
# The zics below ensure that each data file can stand on its own.
-public: $(ENCHILADA) zic
+public: $(ENCHILADA) zic txts.made
-mkdir /tmp/,tzpublic
for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i ; done
rm -f -r /tmp/,tzpublic
$(AWK) -f checktab.awk $(PRIMARY_YDATA)
- tar cf - $(DOCS) $(SOURCES) $(MISC) | gzip -9 > tzcode.tar.gz
+ tar cf - $(DOCS) $(SOURCES) $(MISC) *.txt | gzip -9 > tzcode.tar.gz
tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
zonenames: $(TDATA)
@$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
+txts.made: workman $(MANS)
+ rm -f *.txt
+ for i in $(MANS); do \
+ ./workman $$i < /dev/null > $$i.txt || exit; \
+ done
+ echo made >$@
+
+workman: workman.sh
+ cp $? $@
+ chmod a+x $@
+
asctime.o: private.h tzfile.h
date.o: private.h
difftime.o: private.h
--- /dev/null 2003-09-05 10:38:07.000000000 -0700
+++ workman.sh 2003-11-07 17:19:22.000000000 -0800
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+# @(#)workman.sh 1.3
+
+tty >/dev/null
+ttyval=$?
+
+case $# in
+ 0) nroff -man ;;
+ 1) if [ -f "$1" ]
+ then
+ ( echo .hy 0; echo .na; echo .pl 100i ) | nroff -man - "$1"
+ else
+ man "$1"
+ fi ;;
+ *) man ${1+"$@"} ;;
+esac | perl -ne '
+ chomp;
+ s/.\010//g;
+ s/[ ]*$//;
+ if (/^$/) {
+ $sawblank = 1;
+ next;
+ } else {
+ if ($sawblank) {
+ print "\n";
+ $sawblank = 0;
+ }
+ print "$_\n";
+ }
+' | case $ttyval in
+ 0) ${PAGER-more} ;;
+ *) cat ;;
+esac
More information about the tz
mailing list