1*433d6423SLionel SambucCawf - nroff-like text formatter 2*433d6423SLionel Sambuc 3*433d6423SLionel SambucCawf is a C version of awf, Henry Spencer's Amazingly Workable (text) 4*433d6423SLionel SambucFormatter. (Awf is written in awk and appears in comp.sources.unix, 5*433d6423SLionel SambucVolume 23, Issue 27.) Cawf and awf provide a usable subset of raw nroff 6*433d6423SLionel Sambuccapabilities and the styles of the man(7), me(7) and ms(7) macro sets. 7*433d6423SLionel SambucOne of cawf's virtues is that it will run on PC clones under MS-DOS. It 8*433d6423SLionel Sambucis also, like awf, totally independent of any licensed Unix source code. 9*433d6423SLionel Sambuc 10*433d6423SLionel SambucThis distribution contains complete source, make files for Unix and 11*433d6423SLionel SambucMS-DOS, documentation (raw and formatted) and MS-DOS executables for cawf 12*433d6423SLionel Sambucand a companion output filters, bsfilt. 13*433d6423SLionel Sambuc 14*433d6423SLionel SambucThis is the fourth distribution of cawf. Changes include: 15*433d6423SLionel Sambuc 16*433d6423SLionel Sambuc * Some rudimentary output device support has been added, via a device 17*433d6423SLionel Sambuc configuration file. 18*433d6423SLionel Sambuc 19*433d6423SLionel Sambuc * The code has been converted to use unsigned characters. 20*433d6423SLionel Sambuc 21*433d6423SLionel Sambuc * An attempt has been made to make the code ANSI C compliant. 22*433d6423SLionel Sambuc 23*433d6423SLionel Sambuc * The following bugs have been fixed: 24*433d6423SLionel Sambuc 25*433d6423SLionel Sambuc A bug in the locating of the device file has been corrected, 26*433d6423SLionel Sambuc so that the code performs as documented. 27*433d6423SLionel Sambuc 28*433d6423SLionel Sambuc Null macro arguments are ignored. 29*433d6423SLionel Sambuc 30*433d6423SLionel Sambuc Some unused arguments to local functions have been more 31*433d6423SLionel Sambuc carefully type cast to avoid portability problems. 32*433d6423SLionel Sambuc 33*433d6423SLionel Sambuc * The .fl and .rn requests are now supported. 34*433d6423SLionel Sambuc 35*433d6423SLionel Sambuc * Limited support has been added for the non-break request control 36*433d6423SLionel Sambuc character, the acute accent ('). 37*433d6423SLionel Sambuc 38*433d6423SLionel Sambuc * Argument count conditionals -- operating on \n(.$ -- may now use 39*433d6423SLionel Sambuc the >= and <= operators in addition to [<=>]. 40*433d6423SLionel Sambuc 41*433d6423SLionel Sambuc * Macros may be terminated with "..", ".", "''" or "'". 42*433d6423SLionel Sambuc 43*433d6423SLionel Sambuc * String interpolation is performed if it is specified at the start 44*433d6423SLionel Sambuc of the .ds request argument. 45*433d6423SLionel Sambuc 46*433d6423SLionel Sambuc * The .tr request has been enhanced to handle named characters and 47*433d6423SLionel Sambuc string interpolation. 48*433d6423SLionel Sambuc 49*433d6423SLionel Sambuc * The SS macro is now included in man.mac. 50*433d6423SLionel Sambuc 51*433d6423SLionel Sambuc * The cawf version number is now displayed in the help output. 52*433d6423SLionel Sambuc 53*433d6423SLionel Sambuc * A limited -me macro set is included in me.mac. 54*433d6423SLionel Sambuc 55*433d6423SLionel SambucChanges to cawf to run under Minix: 56*433d6423SLionel Sambuc 57*433d6423SLionel Sambuc * The DOS binaries and make files have been removed. 58*433d6423SLionel Sambuc 59*433d6423SLionel Sambuc * Tabs stops changed from per 5 to per 8. 60*433d6423SLionel Sambuc 61*433d6423SLionel Sambuc * Bold and underline as it should be in device.cf. 62*433d6423SLionel Sambuc 63*433d6423SLionel Sambuc * Added .SB and .TA to man.mac. 64*433d6423SLionel Sambuc 65*433d6423SLionel Sambuc * Numerous prototypes added. 66*433d6423SLionel Sambuc 67*433d6423SLionel Sambuc 68*433d6423SLionel SambucCONTENTS 69*433d6423SLionel Sambuc-------- 70*433d6423SLionel Sambuc 71*433d6423SLionel SambucThis Minix distribution of cawf includes: 72*433d6423SLionel Sambuc 73*433d6423SLionel Sambuc README this file 74*433d6423SLionel Sambuc *.c and *.h source files to build cawf and bsfilt (bsfilt 75*433d6423SLionel Sambuc removes Backspaces from cawf output) 76*433d6423SLionel Sambuc bsfilt.1 nroff source for the bsfilt manual page 77*433d6423SLionel Sambuc cawf.1 nroff source for the cawf manual page 78*433d6423SLionel Sambuc common initialization file for CAWFLIB library 79*433d6423SLionel Sambuc device.cf output device configuration file for CAWFLIB 80*433d6423SLionel Sambuc library 81*433d6423SLionel Sambuc dumb.dev device description file for CAWFLIB library 82*433d6423SLionel Sambuc Makefile Unix-style make file 83*433d6423SLionel Sambuc man.mac man(7) macros for CAWFLIB library 84*433d6423SLionel Sambuc me.mac me(7) macros for CAWFLIB library 85*433d6423SLionel Sambuc ms.mac ms(7) macros for CAWFLIB library 86*433d6423SLionel Sambuc diffs Minix patches 87*433d6423SLionel Sambuc#ifdef PUTTING_IT_ON_THE_NET 88*433d6423SLionel Sambuc cawf 89*433d6423SLionel Sambuc bsfilt binaries compiled under Minix-PC 1.5 using the ACK 90*433d6423SLionel Sambuc ANSI C compiler using software floating point 91*433d6423SLionel Sambuc#endif 92*433d6423SLionel Sambuc 93*433d6423SLionel Sambuc 94*433d6423SLionel SambucLIBRARY 95*433d6423SLionel Sambuc------- 96*433d6423SLionel Sambuc 97*433d6423SLionel SambucTo use cawf, you must select a location for the CAWFLIB library files. The 98*433d6423SLionel Sambucdistributed cawf binary expects to find them in /usr/local/lib/cawf but you 99*433d6423SLionel Sambuccan alter that with the CAWFLIB environment variable, or you can change the 100*433d6423SLionel SambucCAWFLIB #define in cawf.h and rebuild cawf from the sources. 101*433d6423SLionel Sambuc 102*433d6423SLionel SambucCAWFLIB contains a minimum of six files: 103*433d6423SLionel Sambuc 104*433d6423SLionel Sambuc common common raw nroff commands to get cawf started 105*433d6423SLionel Sambuc dumb.dev a set of character definitions for a plain, "dumb" 106*433d6423SLionel Sambuc ASCII device - e. g., the console display, a CRT or 107*433d6423SLionel Sambuc a basic line printer 108*433d6423SLionel Sambuc device.cf the output device configuration file 109*433d6423SLionel Sambuc man.mac the man(7) macros 110*433d6423SLionel Sambuc me.mac the me(7) macros 111*433d6423SLionel Sambuc ms.mac the ms(7) macros 112*433d6423SLionel Sambuc 113*433d6423SLionel SambucYou may want to add your own macro files to the library. Just name them 114*433d6423SLionel Sambuc"m[your-name].mac", following the usual nroff naming convention for macro 115*433d6423SLionel Sambucfiles. 116*433d6423SLionel Sambuc 117*433d6423SLionel SambucIf you have fancy output devices with special character specifications, you 118*433d6423SLionel Sambucmay want to generate new *.dev files for them. Follow the format of dumb.dev 119*433d6423SLionel Sambucin making new character specifications. To define characters for a new 120*433d6423SLionel Sambucdevice, select a name prefix for it and create a file in CAWFLIB with the 121*433d6423SLionel Sambucname "<prefix>.dev". To use the new file, set the TERM environment variable 122*433d6423SLionel Sambucto <prefix> - e. g., when I test cawf on Unix, I need a vt100.dev, because 123*433d6423SLionel Sambucmy TERM environment variable value is usually vt100. All I do is make 124*433d6423SLionel Sambucvt100.dev a symbolic link to dumb.dev. Even that isn't even necessary, 125*433d6423SLionel Sambucbecause cawf will use dumb.dev if it can't find TERM.dev. 126*433d6423SLionel Sambuc 127*433d6423SLionel SambucIn addition to the character specifications possible through the *.dev files, 128*433d6423SLionel Sambuccawf provides one-time font selection and bold or italic face support for 129*433d6423SLionel Sambucoutput devices via its -d and -f options. Cawf can be directed to issue 130*433d6423SLionel Sambucspecific device codes for bold and italic characters, and one font can be 131*433d6423SLionel Sambucspecified for the entire document. Cawf has some built-in output device 132*433d6423SLionel Sambucsupport, and addition support is contained in the device configuration file, 133*433d6423SLionel Sambucdevice.cf. Additional devices may be defined in device.cf. 134*433d6423SLionel Sambuc 135*433d6423SLionel SambucIt is not necessary to generate a new *.dev file for each output device 136*433d6423SLionel Sambucdefinition. Only when you need special character definitions do you need to 137*433d6423SLionel Sambuccreate a *.dev file. The dumb.dev file is adequate for most devices you 138*433d6423SLionel Sambucdefine in device.cf. 139*433d6423SLionel Sambuc 140*433d6423SLionel Sambuc 141*433d6423SLionel SambucSOURCES 142*433d6423SLionel Sambuc------- 143*433d6423SLionel Sambuc 144*433d6423SLionel SambucThe Unix make file has some definitions that help tune it to the local 145*433d6423SLionel SambucUnix environment: 146*433d6423SLionel Sambuc 147*433d6423SLionel Sambuc CAWFLIB is a string that can be used in lieu of changes 148*433d6423SLionel Sambuc to cawf.h's CWFLIB #define. 149*433d6423SLionel Sambuc 150*433d6423SLionel Sambuc MALLOCH is a string that should be defined when a UNIX 151*433d6423SLionel Sambuc environment has a <malloc.h>, unless it also has a 152*433d6423SLionel Sambuc <stdlib.h> with protoypes for malloc() and its 153*433d6423SLionel Sambuc relatives. In the latter case, you should define 154*433d6423SLionel Sambuc STDLIB, but you don't need to define MALLOCH. 155*433d6423SLionel Sambuc 156*433d6423SLionel Sambuc STDLIB indicates that standard library function prototype 157*433d6423SLionel Sambuc definitions may be found in <stdlib.h>. 158*433d6423SLionel Sambuc 159*433d6423SLionel Sambuc STDLIB must be defined for MS-DOS Quick C. 160*433d6423SLionel Sambuc 161*433d6423SLionel Sambuc If STDLIB is not defined, the cawf sources try to 162*433d6423SLionel Sambuc define their own library function return values. 163*433d6423SLionel Sambuc 164*433d6423SLionel Sambuc __STR__ The definition of this string must be deleted when 165*433d6423SLionel Sambuc using the xlc 1.2 compiler on the RISC/System 6000 166*433d6423SLionel Sambuc under AIX 3.2. Put 167*433d6423SLionel Sambuc 168*433d6423SLionel Sambuc -U__STR__ 169*433d6423SLionel Sambuc 170*433d6423SLionel Sambuc in the Makefile DEFS string. This must be done 171*433d6423SLionel Sambuc because the xlc 1.2 compiler does not correctly inline 172*433d6423SLionel Sambuc string functions when compiling pass3.c. 173*433d6423SLionel Sambuc 174*433d6423SLionel Sambuc UNIX switches the build environment to Unix. You may also 175*433d6423SLionel Sambuc have to decide about MALLOCH, STDLIB, __STR__ and USG 176*433d6423SLionel Sambuc when you define UNIX. 177*433d6423SLionel Sambuc 178*433d6423SLionel Sambuc Do not define UNIX for MS-DOS Quick-C; do define 179*433d6423SLionel Sambuc STDLIB. 180*433d6423SLionel Sambuc 181*433d6423SLionel Sambuc USG adjusts for System V. (UNIX must also be defined.) 182*433d6423SLionel Sambuc 183*433d6423SLionel Sambuc You may also need to define USG to select the proper 184*433d6423SLionel Sambuc header file for string function prototypes. If UNIX 185*433d6423SLionel Sambuc and USG are defined, "proto.h" selects <string.h>; 186*433d6423SLionel Sambuc if only UNIX, <strings.h>. Cawf needs the more 187*433d6423SLionel Sambuc complete set of definitions, including strchr() and 188*433d6423SLionel Sambuc strrchr(). If <string.h> #includes <strings.h>, as 189*433d6423SLionel Sambuc is sometimes the case, define only UNIX. 190*433d6423SLionel Sambuc 191*433d6423SLionel SambucI have built and tested cawf in the UNIX context under AIX 3.2 (see the 192*433d6423SLionel Sambucnote above on __STR__), BSD4.3-Tahoe, Sequent DYNIX, ETAV (SYSV 3.0), 193*433d6423SLionel SambucNeXTStep 3.0, SunOS 4.1.1 and Ultrix 2.2. If you build under another Unix 194*433d6423SLionel Sambucvariant, you may have to adjust the source code, header files and Makefile 195*433d6423SLionel Sambucto fit. Check the Makefile first for hints. 196*433d6423SLionel Sambuc 197*433d6423SLionel Sambuc 198*433d6423SLionel SambucANSI C COMPLIANCE 199*433d6423SLionel Sambuc----------------- 200*433d6423SLionel Sambuc 201*433d6423SLionel SambucSome effort has been devoted to making the cawf sources ANSI C compliant. 202*433d6423SLionel SambucThe header file proto.h contains function prototypes that enable ANSI C 203*433d6423SLionel Sambucargument checking. The state of definition of the __STDC__ symbol is used 204*433d6423SLionel Sambucto select options that depend on strict adherence to the ANSI C standard -- 205*433d6423SLionel Sambuce.g., the need for the isascii() test before islower() or isupper(). If 206*433d6423SLionel Sambucyour ANSI compiler doesn't define this variable when it's acting in strict 207*433d6423SLionel SambucANSI C mode, you may have to define it in the Makefile. 208*433d6423SLionel Sambuc 209*433d6423SLionel Sambuc 210*433d6423SLionel SambucMS-DOS CONSIDERATIONS 211*433d6423SLionel Sambuc--------------------- 212*433d6423SLionel Sambuc 213*433d6423SLionel SambucThe MS-DOS version of cawf was created to run under the KornShell of the 214*433d6423SLionel SambucMortis Kern Systems Toolkit. One ramification of using MKS' ksh is that it 215*433d6423SLionel Sambucsupports the separate standard error and standard output streams. Hence, 216*433d6423SLionel Sambuccawf blithely distributes its error messages to the standard error file, and 217*433d6423SLionel Sambucassumes the user's shell is capable of separating them from standard output. 218*433d6423SLionel Sambuc 219*433d6423SLionel SambucIf you don't use the MKS KornShell, but do want to separate the output 220*433d6423SLionel Sambucstreams, you'll have to modify the cawf source code. As a rudimentary aid, 221*433d6423SLionel Sambuccawf uses a separate stream pointer, Efs, for writing error output, but sets 222*433d6423SLionel Sambucit to stderr. You can change that process to open a separate error file and 223*433d6423SLionel Sambucset Efs to point to it. 224*433d6423SLionel Sambuc 225*433d6423SLionel Sambuc 226*433d6423SLionel SambucCOPYRIGHTS AND CREDITS 227*433d6423SLionel Sambuc---------------------- 228*433d6423SLionel Sambuc 229*433d6423SLionel SambucThe sources are copyrighted, but freely distributable under usual terms - 230*433d6423SLionel Sambucretention of credit, etc. 231*433d6423SLionel Sambuc 232*433d6423SLionel SambucPlease acknowledge: 233*433d6423SLionel Sambuc 234*433d6423SLionel Sambuc AT&T for their public-domain release of getopt(3) at the 1985 235*433d6423SLionel Sambuc UNIFORUM conference; 236*433d6423SLionel Sambuc 237*433d6423SLionel Sambuc Chet Creider, Bob Hardy and Ted Campbell for their contributions 238*433d6423SLionel Sambuc to font filtering; 239*433d6423SLionel Sambuc 240*433d6423SLionel Sambuc Henry Spencer for awf and his regular expression package; 241*433d6423SLionel Sambuc 242*433d6423SLionel Sambuc Andy Tanenbaum for his help in ANSI C compliance, including his 243*433d6423SLionel Sambuc ansi.h header file from Minix. 244*433d6423SLionel Sambuc 245*433d6423SLionel SambucHenry says about awf, "I can't believe I really wrote this." Those are 246*433d6423SLionel Sambucmy sentiments exactly about cawf, but I also understand that necessity 247*433d6423SLionel Sambucsometimes forces us to do what we would prefer to avoid. 248*433d6423SLionel Sambuc 249*433d6423SLionel Sambuc 250*433d6423SLionel SambucBUGS AND ENHANCEMENTS 251*433d6423SLionel Sambuc--------------------- 252*433d6423SLionel Sambuc 253*433d6423SLionel SambucI'll be glad to hear about bugs and needs for enhancements, but make no 254*433d6423SLionel Sambucpromises about delivering fixes or upgrades in response. 255*433d6423SLionel Sambuc 256*433d6423SLionel SambucVic Abell <abe@cc.purdue.edu> 257*433d6423SLionel Sambuc24 November 1992 258*433d6423SLionel Sambuc 259*433d6423SLionel Sambuc 260*433d6423SLionel SambucMINIX SPECIFIC TINKERING 261*433d6423SLionel Sambuc------------------------ 262*433d6423SLionel Sambuc 263*433d6423SLionel SambucKees J. Bot <kjb@cs.vu.nl> 264*433d6423SLionel Sambuc26 November 1992 265