Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!iuvax!pur-ee!ea.ecn.purdue.edu!housel From: housel@en.ecn.purdue.edu (Peter S. Housel) Newsgroups: comp.os.minix Subject: NR patches for Minix (plus 'man'), part 1/2 Message-ID: <7369@ea.ecn.purdue.edu> Date: 13 Dec 88 01:16:33 GMT Sender: housel@ea.ecn.purdue.edu Reply-To: housel@en.ecn.purdue.edu (Peter S. Housel) Organization: Purdue University Engineering Computer Network Lines: 972 Several people asked me to post my changes to NR to allow it to run under Minix. Allen Holub has kindly granted me permission to do so. Also included are my version of the "-man" macros for NR, and my version of the "man" command. For information purposes only: NR is available on disk from M&T Books, 501 Galveston Drive, Redwood City, CA, 94063. -Peter S. Housel- housel@en.ecn.purdue.edu ...!pur-ee!housel ------------------------ #!/bin/sh echo 'x - CRC-LIST' sed 's/^X//' <<'**-CRC-LIST-EOF-**' >CRC-LIST X27111 2375 Makefile X33174 1714 Makefile.tools X25485 392 bitmap.c.cdif X04419 475 bitmap.h.cdif X36609 1155 date.c.cdif X63497 12 debug.h X53318 732 ferr.c.cdif X24543 680 getargs.c.cdif X34407 746 getargs.h.cdif X59767 150 getch.c X39315 1411 hash.c.cdif X15108 749 hash.h.cdif X00922 312 inserts.c.cdif X05666 590 itoascii.c.cdi X63497 12 malloc.h X05137 690 man.sh X38595 326 misc.c X09136 1515 nr.c.cdif X23040 2065 nr.h.cdif X10278 779 nrcmd.c.cdif X14970 1694 nrglbls.c.cdif X50548 4346 nrinp.c.cdif X63216 5797 nrmac.c.cdif X51889 913 nrmap.c.cdif X49659 524 nrmap.h.cdif X10503 824 nrmsc.c.cdif X15454 2442 nrout.c.cdif X43596 1221 nrp.h X03824 1413 nrprocs.c.cdif X49636 1255 nrtext.c.cdif X27216 1828 parse.c.cdif X05126 638 queue.c.cdif X37079 309 skipspac.c.cdi X01093 255 stdarg.h X08152 432 stoi.c.cdif X03631 321 strsave.c.cdif X19711 466 switchar.c.cdi X63919 2325 tmac.an **-CRC-LIST-EOF-** echo 'x - Makefile' sed 's/^X//' <<'**-Makefile-EOF-**' >Makefile X# X# Makefile for NR X# X XCFLAGS= -F -I. X XSRCS = nr.c nrcmd.c nreg.c nrglbls.c nrinp.c nrmac.c \ X nrmap.c nrmsc.c nrout.c nrprocs_1.c nrprocs_2.c \ X nrtab.c nrtext.c XOBJS = nr.s nrcmd.s nreg.s nrglbls.s nrinp.s nrmac.s \ X nrmap.s nrmsc.s nrout.s nrprocs_1.s nrprocs_2.s \ X nrtab.s nrtext.s X XLIBS = tools/libtools.a X Xall: nr X Xnr: $(OBJS) X ./asld -T/usr/tmp -o nr -i /usr/lib/crtso.s $(OBJS) $(LIBS) /usr/lib/libc.a /usr/lib/end.s X Xdepend: X mkdep $(CFLAGS) $(SRCS) X Xclean: X rm -f nr $(OBJS) ERRS core X X# DO NOT DELETE THIS LINE -- mkdep uses it. X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. X Xnr.s: /usr/include/fcntl.h Xnr.s: /usr/include/signal.h Xnr.s: /usr/include/stdio.h Xnr.s: ascii.h Xnr.s: date.h Xnr.s: nr.c Xnr.s: nr.h Xnr.s: tools/bitmap.h Xnr.s: tools/getargs.h Xnrcmd.s: /usr/include/ctype.h Xnrcmd.s: /usr/include/stdio.h Xnrcmd.s: ascii.h Xnrcmd.s: nr.h Xnrcmd.s: nrcmd.c Xnreg.s: /usr/include/stdio.h Xnreg.s: ascii.h Xnreg.s: nr.h Xnreg.s: nreg.c Xnreg.s: tools/hash.h Xnrglbls.s: /usr/include/stdio.h Xnrglbls.s: ascii.h Xnrglbls.s: nr.h Xnrglbls.s: nrglbls.c Xnrinp.s: /usr/include/ctype.h Xnrinp.s: /usr/include/stdio.h Xnrinp.s: ascii.h Xnrinp.s: nr.h Xnrinp.s: nrinp.c Xnrmac.s: /usr/include/stdio.h Xnrmac.s: ascii.h Xnrmac.s: nr.h Xnrmac.s: nrmac.c Xnrmac.s: tools/hash.h Xnrmap.s: /usr/include/ctype.h Xnrmap.s: /usr/include/stdio.h Xnrmap.s: ascii.h Xnrmap.s: nr.h Xnrmap.s: nrmap.c Xnrmap.s: nrmap.h Xnrmsc.s: /usr/include/ctype.h Xnrmsc.s: /usr/include/stdio.h Xnrmsc.s: ascii.h Xnrmsc.s: nr.h Xnrmsc.s: nrmsc.c Xnrout.s: /usr/include/ctype.h Xnrout.s: /usr/include/stdarg.h Xnrout.s: /usr/include/stdio.h Xnrout.s: ascii.h Xnrout.s: nr.h Xnrout.s: nrmap.h Xnrout.s: nrout.c Xnrout.s: nrtlen.h Xnrprocs_1.s: /usr/include/ctype.h Xnrprocs_1.s: /usr/include/stdio.h Xnrprocs_1.s: /usr/include/sys/types.h Xnrprocs_1.s: /usr/include/time.h Xnrprocs_1.s: ascii.h Xnrprocs_1.s: nr.h Xnrprocs_1.s: nrprocs_1.c Xnrprocs_2.s: /usr/include/ctype.h Xnrprocs_2.s: /usr/include/stdio.h Xnrprocs_2.s: /usr/include/sys/types.h Xnrprocs_2.s: /usr/include/time.h Xnrprocs_2.s: ascii.h Xnrprocs_2.s: nr.h Xnrprocs_2.s: nrp.h Xnrprocs_2.s: nrprocs_2.c Xnrtab.s: /usr/include/stdio.h Xnrtab.s: ascii.h Xnrtab.s: nr.h Xnrtab.s: nrtab.c Xnrtext.s: /usr/include/ctype.h Xnrtext.s: /usr/include/stdio.h Xnrtext.s: ascii.h Xnrtext.s: nr.h Xnrtext.s: nrmap.h Xnrtext.s: nrtext.c Xnrtext.s: nrtlen.h X X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY **-Makefile-EOF-** echo 'x - Makefile.tools' sed 's/^X//' <<'**-Makefile.tools-EOF-**' >Makefile.tools X# X# Makefile for tools library X# X XCFLAGS= -F -LIB -I. -I.. X XSRCS = hash.c getargs.c bitmap.c queue.c date.c stoi.c uatoi.c strsave.c \ X queue.c itoascii.c ferr.c cpy.c inserts.c onferr.c parse.c \ X skipspac.c skipto.c switchar.c getch.c misc.c XOBJS = hash.s getargs.s bitmap.s queue.s date.s stoi.s uatoi.s strsave.s \ X queue.s itoascii.s ferr.s cpy.s inserts.s onferr.s parse.s \ X skipspac.s skipto.s switchar.s getch.s misc.s X Xall: libtools.a X Xlibtools.a: $(OBJS) X ar r libtools.a $(OBJS) X Xdepend: X mkdep $(CFLAGS) $(SRCS) X Xclean: X rm -f $(OBJS) ERRS libtools.a X X# DO NOT DELETE THIS LINE -- mkdep uses it. X# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. X Xhash.s: ../tools/debug.h Xhash.s: ../tools/hash.h Xhash.s: /usr/include/ctype.h Xhash.s: /usr/include/limits.h Xhash.s: /usr/include/stdio.h Xhash.s: hash.c Xhash.s: malloc.h Xgetargs.s: ../tools/getargs.h Xgetargs.s: /usr/include/stdio.h Xgetargs.s: getargs.c Xbitmap.s: ../tools/bitmap.h Xbitmap.s: /usr/include/stdio.h Xbitmap.s: bitmap.c Xqueue.s: queue.c Xdate.s: /usr/include/sys/types.h Xdate.s: /usr/include/time.h Xdate.s: date.c Xstoi.s: /usr/include/ctype.h Xstoi.s: stoi.c Xuatoi.s: uatoi.c Xstrsave.s: strsave.c Xqueue.s: queue.c Xitoascii.s: /usr/include/ctype.h Xitoascii.s: itoascii.c Xferr.s: /usr/include/stdarg.h Xferr.s: /usr/include/stdio.h Xferr.s: ferr.c Xcpy.s: cpy.c Xinserts.s: inserts.c Xonferr.s: onferr.c Xparse.s: /usr/include/ctype.h Xparse.s: /usr/include/stdarg.h Xparse.s: /usr/include/stdio.h Xparse.s: parse.c Xskipspac.s: /usr/include/ctype.h Xskipspac.s: skipspac.c Xskipto.s: skipto.c Xswitchar.s: switchar.c Xgetch.s: getch.c Xmisc.s: /usr/include/stdio.h Xmisc.s: /usr/include/sys/stat.h Xmisc.s: misc.c X X# IF YOU PUT ANYTHING HERE IT WILL GO AWAY **-Makefile.tools-EOF-** echo 'x - README' sed 's/^X//' <<'**-README-EOF-**' >README XThis is the patch kit to adapt NR to Minix. X XNR is an implementation of the NROFF text formatter, written by Allen XHolub and published by M&T Publishing. The program is Copyright 1987, X1988 by Alan Holub. [Disclaimer: I have no relationship to M&T Xpublishing other than as a reader of Dr. Dobb's Journal of Software XTools, and as a purchaser of the NR disk.] X XMr. Holub has graciously granted permission for me to post these patches. X XINSTRUCTIONS X X1) Extract the sources from the NR.ARC file on the distribution disk, and Xcopy them to Minix using dosread. X X2) Apply all of the patches (*.cdif and *.cdi) using patch. I kept Xrunning out of /tmp space ("no space on RAM disk") when patching Xnrprocs.c, and had to mount a floppy disk on /tmp before it would work. X X3) Create a "tools" subdirectory, and move the following files into it: Xbitmap.c getargs.c malloc.h stoi.c Xbitmap.h getargs.h misc.c strsave.c Xcpy.c getch.c onferr.c switchar.c Xdate.c hash.c parse.c uatoi.c Xdate.h hash.h queue.c Xdebug.h inserts.c skipspac.c Xferr.c itoascii.c skipto.c X XThe files "malloc.h", "debug.h", "misc.c", and "getch.c" are from this Xkit, and the rest are part of NR. Also, move "Makefile.tools" from Xthis kit into the "tools" directory and rename it "Makefile". X X4) Replace the "Makefile" in the main directory with the one from this kit. XAlso, make sure "nrp.h" from this kit is in the main directory. X X5) Split "nrprocs.c" into two parts (right between ss() and ta()), using: X split -1600 nrprocs.c X mv xaa nrprocs_1.c X head -22 nrprocs_1.c | cat - xab > nrprocs_2.c X rm xab X XNow, edit nrprocs_2.c and change the line which says: X static Nestlev = 0; /* .{/.} Nesting level */ Xto: X #include "nrp.h" X X6) Copy /bin/asld to the main directory, and run "chmem =49000 asld". XOtherwise asld will run out of space. (This is a tight squeeze.) Also, Xtry "chmem +700 /lib/cem" - this is necessary to compile nrprocs_2.c Xon a PC. Increasing the space much beyond this causes cem to crash. X X7) Install "stdarg.h" in "/usr/include". This is the ANSI C equivalent Xof "varargs.h". X X8) Do a "make" in the "tools" directory. You should have a "libtools.a". X X9) Do a "make" in the main directory. Install "nr" as "/usr/bin/nroff". X X10) Insert a line containing ".cm" at the beginning of, and ".cm on" at Xthe end of "s.mac". This puts NR in "NR copy mode" while it is reading Xthe "-ms" macros, but leaves it in NROFF mode when it is done. This is Xnecessary because I have changed the NR default (see the patch for Xnrglbls.c). X X11) Create the directory "/usr/lib/tmac". Copy "s.mac" to X"/usr/lib/tmac/tmac.s". Copy "tmac.an" (the "-man" macros, from this kit) Xto "/usr/lib/tmac/tmac.an". X X12) If desired, Copy "man.sh" to "/usr/bin/man". Make directories X"/usr/man", "/usr/man/man[1-8]", and "/usr/man/cat[1-8]". X XNOTES X XThe patches were designed strictly with the intent of getting a version Xworking on Minix, with no consideration for keeping things #ifdef'ed. X XThere's probably not any way I can make this easier to do. X XAs noted above, the default copy mode is now nroff-compatible instead Xof NR-compatible. Use a ".cm" command for your strictly-NR files. X XSeveral of the changes (mostly in nrout.c) were bug fixes necessary to get Xfont changes to work, especially for the -man macros. I unfortunately Xdon't remember what I fixed, and some things may still be broken. X XBe forewarned that NR only understands units in terms of n's (horizontal) Xand v's (vertical), and doesn't allow any units to be specified. X XThe "-man" macros are pretty much a minimal set that serve to get Xacceptable-looking manual pages for most things. There are usually a Xlot of error messages when a manual page author has used an Xunimplemented construct or macro. Ignore these and see how it turns Xout. X XHalf of the work implementing tmac.an was spent trying to get hanging Xindentation to work right. It still isn't quite right. X XMany of the remaining bugs are probably Not My Fault. **-README-EOF-** echo 'x - bitmap.c.cdif' sed 's/^X//' <<'**-bitmap.c.cdif-EOF-**' >bitmap.c.cdif X*** ../../nr.orig/tools/bitmap.c Mon Nov 28 18:10:23 1988 X--- bitmap.c Mon Dec 12 16:10:52 1988 X*************** X*** 9,13 **** X */ X X! extern char *calloc ( unsigned, unsigned ); X X /*----------------------------------------------------------------------*/ X--- 9,13 ---- X */ X X! extern char *calloc (); X X /*----------------------------------------------------------------------*/ **-bitmap.c.cdif-EOF-** echo 'x - bitmap.h.cdif' sed 's/^X//' <<'**-bitmap.h.cdif-EOF-**' >bitmap.h.cdif X*** ../../nr.orig/tools/bitmap.h Mon Nov 28 18:10:27 1988 X--- bitmap.h Mon Dec 12 16:10:55 1988 X*************** X*** 4,9 **** X typedef char *BITMAP; X X! extern BITMAP makebitmap ( unsigned ); X! extern int setbit ( unsigned, BITMAP, int ); X! extern void setall ( BITMAP, int ); X! extern int testbit ( unsigned, BITMAP ); X--- 4,9 ---- X typedef char *BITMAP; X X! extern BITMAP makebitmap(); X! extern int setbit(); X! extern void setall(); X! extern int testbit(); **-bitmap.h.cdif-EOF-** echo 'x - date.c.cdif' sed 's/^X//' <<'**-date.c.cdif-EOF-**' >date.c.cdif X*** ../../nr.orig/tools/date.c Mon Nov 28 18:10:33 1988 X--- date.c Mon Dec 12 16:10:58 1988 X*************** X*** 2,10 **** X */ X X! #include X! X! extern int intdos( union REGS*, union REGS* ); X! X! /*----------------------------------------------------------------------*/ X X date( month, day, year, day_of_the_week ) X--- 2,6 ---- X */ X X! #include X X date( month, day, year, day_of_the_week ) X*************** X*** 12,29 **** X { X /* Return the month, day, year, and day of the week (0 = sunday, X! * 6 = saturday). This function is totally non-portable, X! * and must be compiled with the lattice C compiler. X! */ X! X! union REGS regs; X! X! regs.h.ah = 0x2a ; X! X! intdos( ®s, ®s ); X! X! *month = regs.h.dh ; X! *day = regs.h.dl ; X! *year = regs.x.cx ; X! *day_of_the_week = regs.h.al ; X } X X--- 8,24 ---- X { X /* Return the month, day, year, and day of the week (0 = sunday, X! * 6 = saturday). X! */ X! X! struct tm *t; X! time_t now; X! X! time(&now); X! t = localtime(&now); X! X! *month = t->tm_mon + 1; X! *day = t->tm_mday; X! *year = t->tm_year + 1900; X! *day_of_the_week = t->tm_wday; X } X **-date.c.cdif-EOF-** echo 'x - debug.h' sed 's/^X//' <<'**-debug.h-EOF-**' >debug.h X/* empty */ **-debug.h-EOF-** echo 'x - ferr.c.cdif' sed 's/^X//' <<'**-ferr.c.cdif-EOF-**' >ferr.c.cdif X*** ../../nr.orig/tools/ferr.c Mon Nov 28 18:10:48 1988 X--- ferr.c Mon Dec 12 16:11:01 1988 X*************** X*** 1,6 **** X #include X X- #ifdef MSDOS /*-------------- Use the ANSI functions -----------------*/ X- X #include X X--- 1,4 ---- X*************** X*** 21,45 **** X } X X- #else /*------------------------- Unix System V ------------------------*/ X- X- #include X- X- void ferr( va_alist ) X- va_dcl /* No semicolon! */ X- { X- extern int errno; X- va_list args; X- char *fmt; X- X- va_start( args ); X- fmt = va_arg( args, char* ); X- X- if( fmt ) X- _doprnt( fmt, args, stderr ); X- else X- perror( va_arg(args, char* ) ); X- X- exit( on_ferr() ); X- } X- X- #endif X--- 19,20 ---- **-ferr.c.cdif-EOF-** echo 'x - getargs.c.cdif' sed 's/^X//' <<'**-getargs.c.cdif-EOF-**' >getargs.c.cdif X*** ../../nr.orig/tools/getargs.c Mon Nov 28 18:10:52 1988 X--- getargs.c Mon Dec 12 16:31:20 1988 X*************** X*** 25,29 **** X X extern int switchar (); X! extern int stoi ( char** ); X X typedef int (*PFI)(); X--- 25,29 ---- X X extern int switchar (); X! extern int stoi (); X X typedef int (*PFI)(); X*************** X*** 62,71 **** X X case PROC: X! /* this kludge is required by MSC, ver. 5, which X! * won't allow a cast from int pointer to function X! * pointer (the jerks). X! */ X! X! (* (PFI) ((unsigned long)(argp->variable)) )( linep ); X X linep = ""; X--- 62,66 ---- X X case PROC: X! (* (PFI) ((argp->variable)) )( linep ); X X linep = ""; **-getargs.c.cdif-EOF-** echo 'x - getargs.h.cdif' sed 's/^X//' <<'**-getargs.h.cdif-EOF-**' >getargs.h.cdif X*** ../../nr.orig/tools/getargs.h Mon Nov 28 18:10:55 1988 X--- getargs.h Mon Dec 12 16:11:08 1988 X*************** X*** 11,16 **** X typedef struct X { X! unsigned arg : 7 ; /* Command line switch */ X! unsigned type : 4 ; /* variable type */ X int *variable ; /* pointer to variable */ X char *errmsg ; /* pointer to error message */ X--- 11,16 ---- X typedef struct X { X! unsigned char arg ; /* Command line switch */ X! unsigned char type ; /* variable type */ X int *variable ; /* pointer to variable */ X char *errmsg ; /* pointer to error message */ X*************** X*** 18,20 **** X ARG; X X! extern int getargs( int, char**, ARG*, int, int (*)() ); X--- 18,20 ---- X ARG; X X! extern int getargs(); **-getargs.h.cdif-EOF-** echo 'x - getch.c' sed 's/^X//' <<'**-getch.c-EOF-**' >getch.c Xint getch() X{ X char c; X int fd; X X if((fd = open("/dev/tty", 0)) < 0 || 1 != read(fd, &c, 1) || close(fd)) X return -1; X else X return c & 0xFF; X} **-getch.c-EOF-** echo 'x - hash.c.cdif' sed 's/^X//' <<'**-hash.c.cdif-EOF-**' >hash.c.cdif X*** ../../nr.orig/tools/hash.c Mon Nov 28 18:11:02 1988 X--- hash.c Mon Dec 12 16:11:13 1988 X*************** X*** 7,10 **** X--- 7,13 ---- X #include X X+ #define PUBLIC X+ #define PRIVATE static X+ #define CHAR_BIT 8 X X /* HASHTAB.C General-purpose hash table functions. X*************** X*** 61,66 **** X */ X X! PRIVATE unsigned hash ( char*, HASH_TAB*); X! PRIVATE int symcmp ( BUCKET**, BUCKET** ); X X /*----------------------------------------------------------------------*/ X--- 64,69 ---- X */ X X! PRIVATE unsigned hash(); X! PRIVATE int symcmp(); X X /*----------------------------------------------------------------------*/ X*************** X*** 143,147 **** X PUBLIC void use_pjw() { Pjw = 1; } X X! #define HASH(n,t) ( Pjw ? (*hash_pjw) : (*hash_add) )(n,t) X X /*----------------------------------------------------------------------*/ X--- 146,150 ---- X PUBLIC void use_pjw() { Pjw = 1; } X X! #define HASH(n,t) (hash_add(n,t)) X X /*----------------------------------------------------------------------*/ X*************** X*** 245,249 **** X for(; last->next ; last = last->next ) X if( strcmp(last->sname,last->next->sname) == 0 ) X! return (char *)( last->next + 1 ); X return NULL; X } X--- 248,252 ---- X for(; last->next ; last = last->next ) X if( strcmp(last->sname,last->next->sname) == 0 ) X! return (void *)(char *)( last->next + 1 ); X return NULL; X } **-hash.c.cdif-EOF-** echo 'x - hash.h.cdif' sed 's/^X//' <<'**-hash.h.cdif-EOF-**' >hash.h.cdif X*** ../../nr.orig/tools/hash.h Mon Nov 28 18:11:06 1988 X--- hash.h Mon Dec 12 16:11:16 1988 X*************** X*** 26,34 **** X #define symname(p) ( ((BUCKET*)(p) - 1)->sname ) X X! extern void *addsym (HASH_TAB *, char *, int ); X! extern void delsym (HASH_TAB *, BUCKET * ); X! extern void *findsym (HASH_TAB *, char * ); X! extern void *nextsym (BUCKET * ); X! extern HASH_TAB *maketab (unsigned int ); X! extern void ptab (HASH_TAB *, void (*)(), int ); X! extern void use_pjw (void ); X--- 26,34 ---- X #define symname(p) ( ((BUCKET*)(p) - 1)->sname ) X X! extern void *addsym(); X! extern void delsym(); X! extern void *findsym(); X! extern void *nextsym(); X! extern HASH_TAB *maketab(); X! extern void ptab(); X! extern void use_pjw(); **-hash.h.cdif-EOF-** echo 'x - inserts.c.cdif' sed 's/^X//' <<'**-inserts.c.cdif-EOF-**' >inserts.c.cdif X*** ../../nr.orig/tools/inserts.c Mon Nov 28 18:11:09 1988 X--- inserts.c Mon Dec 12 16:11:19 1988 X*************** X*** 1,6 **** X- #ifndef MSC_VER4 /* Microsoft C, version 5 */ X- # define memcpy(d,s,c) memmove(d,s,c) X- #endif X- X int inserts( str, target, maxch ) X register char *str, *target; X--- 1,2 ---- **-inserts.c.cdif-EOF-** echo 'x - itoascii.c.cdi' sed 's/^X//' <<'**-itoascii.c.cdi-EOF-**' >itoascii.c.cdi X*** ../../nr.orig/tools/itoascii.c Mon Nov 28 18:11:15 1988 X--- itoascii.c Mon Dec 12 16:11:23 1988 X*************** X*** 26,33 **** X */ X X! #define SSIZE 16 /* Maximum size of expanded number */ X! X! extern char *cpy (char*, char* ); X! extern void strcpy (char*, char* ); X X /*----------------------------------------------------------------------*/ X--- 26,35 ---- X */ X X! #include X! X! #define SSIZE 16 /* Maximum size of expanded number */ X! X! extern char *cpy (); X! extern void strcpy (); X X /*----------------------------------------------------------------------*/ **-itoascii.c.cdi-EOF-** echo 'x - malloc.h' sed 's/^X//' <<'**-malloc.h-EOF-**' >malloc.h X/* empty */ **-malloc.h-EOF-** echo 'x - man.sh' sed 's/^X//' <<'**-man.sh-EOF-**' >man.sh X#!/bin/sh X# Author: Peter S. Housel May 1988 Xcd /usr/man Xif test -t 1 ; then X PAGER=${PAGER-/usr/bin/more} Xelse X PAGER=cat Xfi Xs=1 Xfor i ; do X case $i in X[1-9]*) X s=$i;; X-*) X echo "Unknown flag $i";; X*)if /usr/bin/test -f cat$s/$i.$s ; then X $PAGER cat$s/$i.$s X else X if /usr/bin/test -f man$s/$i.$s ; then X echo -n "Reformatting page..." X /usr/bin/nroff -man man$s/$i.$s > cat$s/$i.$s X echo "done." X $PAGER cat$s/$i.$s X else X found=no X for j in 1 2 3 4 5 6 7 8 ; do X if /usr/bin/test -f man$j/$i.$j; then X man $j $i X found=yes X fi X done X case $found in Xno) echo "$i: manual page not found" X exit 1 X esac X fi X fi;; X esac Xdone **-man.sh-EOF-** echo 'x - misc.c' sed 's/^X//' <<'**-misc.c-EOF-**' >misc.c X#include X#include X Xint rename(from, to) /* incredibly lazy on my part */ Xchar *from, *to; X{ X char cmdbuf[128]; X sprintf(cmdbuf, "mv %s %s", from, to); X return system(cmdbuf); X} X Xlong filelength(fd) Xint fd; X{ X struct stat stb; X X if(fstat(fd, &stb) < 0) X return -1L; X else X return stb.st_size; X} X **-misc.c-EOF-** echo 'x - nr.c.cdif' sed 's/^X//' <<'**-nr.c.cdif-EOF-**' >nr.c.cdif X*** ../nr.orig/nr.c Mon Nov 28 18:11:34 1988 X--- nr.c Mon Dec 12 15:25:42 1988 X*************** X*** 49,53 **** X /* of proportionally spaced characters. */ X X! #define X(x) (int (*))((long)(x)) X X static ARG Argtab[] = X--- 49,53 ---- X /* of proportionally spaced characters. */ X X! #define X(x) (int (*))(x) X X static ARG Argtab[] = X*************** X*** 85,89 **** X */ X X! #define MACFILE "\\lib\\tmac\\%1.8s.mac" X X /*--------------------------------------------------------*/ X--- 85,89 ---- X */ X X! #define MACFILE "/usr/lib/tmac/tmac.%s" X X /*--------------------------------------------------------*/ X*************** X*** 205,209 **** X X static sgetc(s) X! UCHAR **s; X { X return **s ? *((*s)++) : EOF ; X--- 205,209 ---- X X static sgetc(s) X! char **s; X { X return **s ? *((*s)++) : EOF ; X*************** X*** 304,309 **** X char **argv; X { X! fprintf(stderr, "NR ver. 1.2a [%s]. ", _DAY_ ); X! fprintf(stderr, "(C) 1987 Allen I. Holub. All rights reserved.\n" ); X X /* Initialize: */ X--- 304,312 ---- X char **argv; X { X! (void) "NR ver. 1.2a. "; X! (void) "(C) 1987 Allen I. Holub. All rights reserved.\n"; X! X! Ifile = stdin; /* can't initialize in nrglbls.c */ X! Ofile = stdout; X X /* Initialize: */ X*************** X*** 357,361 **** X X if( Unbuf ) X! setvbuf( Ifile, NULL, _IONBF, 0 ); X X screate( ".f" , Ifilename ); X--- 360,364 ---- X X if( Unbuf ) X! setbuf(Ifile, NULL); X X screate( ".f" , Ifilename ); **-nr.c.cdif-EOF-** echo 'x - nr.h.cdif' sed 's/^X//' <<'**-nr.h.cdif-EOF-**' >nr.h.cdif X*** ../nr.orig/nr.h Mon Nov 28 18:11:41 1988 X--- nr.h Mon Dec 12 15:28:34 1988 X*************** X*** 1,3 **** X! #include X X #define min(a,b) ((a) < (b) ? (a) : (b)) X--- 1,3 ---- X! #include "ascii.h" X X #define min(a,b) ((a) < (b) ? (a) : (b)) X*************** X*** 6,10 **** X typedef unsigned char UCHAR; X X! #define MSC_VER5 /* For Microsoft C, version 5, if this define */ X /* doesn't exit, version 4 is assumed. */ X X--- 6,10 ---- X typedef unsigned char UCHAR; X X! /* #define MSC_VER5 /* For Microsoft C, version 5, if this define */ X /* doesn't exit, version 4 is assumed. */ X X*************** X*** 194,199 **** X char *cmd; /* Command name */ X int (*action)(); /* Subroutine to call when cmd found */ X! unsigned type : 3 ; /* Command type */ X! unsigned inhib : 1 ; /* 1 ==> Inhibit works */ X char *def; /* Default value of numeric argument */ X } X--- 194,199 ---- X char *cmd; /* Command name */ X int (*action)(); /* Subroutine to call when cmd found */ X! unsigned char type ; /* Command type */ X! unsigned char inhib ; /* 1 ==> Inhibit works */ X char *def; /* Default value of numeric argument */ X } X*************** X*** 217,227 **** X typedef struct X { X! UCHAR name; /* Font name */ X! UCHAR smac[3]; /* Macro to enter new font */ X! UCHAR emac[3]; /* Macro to exit font */ X! int resolution; /* Min horizontal resolution from .hd */ X! UCHAR *left; /* String to go left from .hd */ X! UCHAR *right; /* String to go right from .hd */ X! UCHAR *widths; /* Array of character widths. */ X } X FONT; X--- 217,227 ---- X typedef struct X { X! char name; /* Font name */ X! char smac[3]; /* Macro to enter new font */ X! char emac[3]; /* Macro to exit font */ X! int resolution; /* Min horizontal resolution from .hd */ X! char *left; /* String to go left from .hd */ X! char *right; /* String to go right from .hd */ X! char *widths; /* Array of character widths. */ X } X FONT; **-nr.h.cdif-EOF-** echo 'x - nrcmd.c.cdif' sed 's/^X//' <<'**-nrcmd.c.cdif-EOF-**' >nrcmd.c.cdif X*** ../nr.orig/nrcmd.c Mon Nov 28 18:11:51 1988 X--- nrcmd.c Mon Dec 12 15:20:29 1988 X*************** X*** 71,76 **** X int error; X extern int getvar(), null(); X! extern double parse(); X! double val = 0.0 ; X X if( **s ) X--- 71,76 ---- X int error; X extern int getvar(), null(); X! extern long parse(); X! long val = 0 ; X X if( **s ) X*************** X*** 162,166 **** X * Type 1: (* action)( val, str, offset, dobreak ); X * Type 2: (* action)( val, str, offset, dobreak, tail); X! * double val; X * char *str; X * char *tail; X--- 162,166 ---- X * Type 1: (* action)( val, str, offset, dobreak ); X * Type 2: (* action)( val, str, offset, dobreak, tail); X! * long val; X * char *str; X * char *tail; **-nrcmd.c.cdif-EOF-** echo 'x - nrglbls.c.cdif' sed 's/^X//' <<'**-nrglbls.c.cdif-EOF-**' >nrglbls.c.cdif X*** ../nr.orig/nrglbls.c Mon Nov 28 18:12:06 1988 X--- nrglbls.c Mon Dec 12 15:24:29 1988 X*************** X*** 106,110 **** X int Nobreak = '\''; /* Nobreak character */ X int Nospace = 0 ; /* Inhibit spacing as per .ns command */ X! int Nr_cpmode = 0 ; /* Nroff copy mode, expand \ in macro definitions*/ X int Num_bold = 0 ; /* Remaining number of input lines to print bold */ X int Num_center = 0 ; /* Remaining number of input lines to center */ X--- 106,110 ---- X int Nobreak = '\''; /* Nobreak character */ X int Nospace = 0 ; /* Inhibit spacing as per .ns command */ X! int Nr_cpmode = 1 ; /* Nroff copy mode, expand \ in macro definitions*/ X int Num_bold = 0 ; /* Remaining number of input lines to print bold */ X int Num_center = 0 ; /* Remaining number of input lines to center */ X*************** X*** 146,155 **** X char Itrap_name[3] = {0,0,0}; /* Macro executed when Intrap == 0 */ X X! FILE *Ifile = stdin; /* Current input descriptor */ X! char *Ifilename = "stdin"; /* Name of input file or macro */ X! FILE *Ofile = stdout; /* Output descriptor */ X! char *Ofilename = "stdout"; /* Name of output file or macro */ X! X! int Nestlev = 0 ; /* Nesting level determined by .{ & .} */ X X int Nm_on = 0 ; /* Line numbering enabled by .nm cmd */ X--- 146,153 ---- X char Itrap_name[3] = {0,0,0}; /* Macro executed when Intrap == 0 */ X X! FILE *Ifile = NULL; /* Current input descriptor */ X! char *Ifilename = "stdin"; /* Name of input file or macro */ X! FILE *Ofile = NULL; /* Output descriptor */ X! char *Ofilename = "stdout"; /* Name of output file or macro */ X X int Nm_on = 0 ; /* Line numbering enabled by .nm cmd */ **-nrglbls.c.cdif-EOF-** exit 0