sakw@cvaxa.UUCP (Sak Wathanasin) (12/20/85)
Sorry for the delay in posting these hacks to w2t. There are 4 files in in this package. When you unpack it, the Readme.update file explains what to do. It would appear from the most recent posting of w2troff (Dec 85) that some of you didn't get my earlier hacks, so I have included them in this posting. There are 3 lots of hacks in this posting: 1) added ability to cope with "hanging indents" - this is crude and has only been tested on 2 levels of nested indentations, so watch out. Moreover, I have assumed that the "tag" is separated from the "body" either by a tab or by a CR (new para). I know that tabs in the margin are legal, but I can't see another simple way of detecting the end of the tag. 2) added ability to handle user-inserted page breaks ("Insert page break" in the "Format" menu). I found out, by poking around in a MW doc, that page breaks are stored as "magic" pictures. The only sure way I could see of detecting the magicness of a picture paragraph is to look for the string "MAGICPIC" in the picture data. Is there a better way of doing this? I have ordered a set of Technical Notes from Apple, but it hasn't arrived yet, so I've been guessing. 3) some fixes to stop spurious changes of font sizes or styles. Because of pressure of work, I haven't tested these changes fully - I just did what was needed to get my documents to print -, but I hope that they will be of use to some of you. Regards, Sak Wathanasin, U of Sussex, Cognitive Studies, Falmer, Sussex BN1 9QN, UK uucp:...mcvax!ukc!cvaxa!sakw arpa/janet: sakw%uk.ac.sussex.cvaxa@uk.ac.ucl.cs -------cut here--------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # Readme.update # Makefile.diff # w2t.diff.1 # w2t.diff.2 # This archive created: Thu Dec 19 20:50:27 1985 export PATH; PATH=/bin:$PATH if test -f 'Readme.update' then echo shar: will not over-write existing file "'Readme.update'" else cat << \SHAR_EOF > 'Readme.update' This update package applies to the version of w2troff that was just (Dec 85) posted to net.sources.mac. The steps to follow are: 1) apply the diffs to the Makefile patch Makefile Makefile.diff 2) apply the 1st set of diffs to w2t.c patch w2t.c w2t.diffs.1 3) apply the 2nd set of diffs to the result of (1) patch w2t.c w2t.diffs.2 4) if you have previously applied the patches in my last posting, omit step (2), and apply w2t.diff.2 ONLY to your w2t.c: patch -l w2t.c w2t.diff.2 5) if you have received any other version of w2t from me, discard it and perform steps (2) and (3) using the original version of w2t.c as the base. (The Makefile will already be correct.) Good luck! Sak Wathanasin, U of Sussex, Cognitive Studies, Falmer, Sussex BN1 9QN, UK uucp:...mcvax!ukc!cvaxa!sakw arpa/janet: sakw%uk.ac.sussex.cvaxa@uk.ac.ucl.cs SHAR_EOF fi # end of overwriting check if test -f 'Makefile.diff' then echo shar: will not over-write existing file "'Makefile.diff'" else cat << \SHAR_EOF > 'Makefile.diff' 12c12,14 < CFLAGS= -O $(OLDMACWRITE) --- > BSD= -Dbsd4 > > CFLAGS= -O $(OLDMACWRITE) $(BSD) SHAR_EOF fi # end of overwriting check if test -f 'w2t.diff.1' then echo shar: will not over-write existing file "'w2t.diff.1'" else cat << \SHAR_EOF > 'w2t.diff.1' 15a16,17 > version 1.2, sakw Sep 2, 85. Bug fixes + new -o param for offsetting > page. 24c26 < #define VERSION "1.1" --- > #define VERSION "1.2" 29a32 > #ifdef bsd4 33a37,40 > #else > #define SWAP(s) ; /* null definition */ > #define SWAPL(s) ; > #endif 34a42 > 59a68 > char *pg_offset = "1.0i"; 103a113,115 > case 'o': > pg_offset = *argv + 2; > break; 105c117 < printf("usage: %s [-r] [-p] [-d] [-w] [-s<pointadj>] files...\n", --- > printf("usage: %s [-r] [-p] [-d] [-w] [-s<pointadj>] [-o<offset>] files...\n", 184c196,197 < printf(".pp\n"); --- > if (curJust != LEFTJUST) printf(".pp\n"); > else printf(".br\n"); 203c216 < if(td->nformats > 0) --- > if(td->nformats > 1) /* bug fix by sakw: there is always 1 format info itm */ 210c223 < else if(wrap && *cp == ' ' && col > 65) { --- > else if(wrap && *cp == ' ' && col > 65) { 234c247 < if ( textInfo[j].parFlags & PF_LOCALJUST ) --- > if ( textInfo[j].parFlags & PF_LOCALJUST ) 235a249 > 246c260,262 < printf(".sv %.1fi\n", --- > printf(".br\n.(b\n.sv %.1fi\n.)b\n", > textInfo[j].paraHeight/80. ); > /* bug fix by sakw 247a264 > */ 392a410 > * sakw: set leading to 2 point 394c412 < newSpacing = ((ruler->flags & RF_6LPI? 1 : 4) * (ruler->spacing + 2)) / 2; --- > newSpacing = ((ruler->flags & RF_6LPI? 1 : 2) * (ruler->spacing + 2)) / 2; 421c439 < printf("%.1fi", -curParIndent ); --- > printf("%.1fi", -curParIndent); 435c453 < printf(".\" this file generated by WtoT version %s\n", --- > printf(".\" this file generated by WtoT version %s\n", 437c455 < printf(".po 1i\n"); --- > printf(".po %s\n", pg_offset); 640c658,659 < if ( (int)fp & 1 ) --- > if ( (fp - dataBuf) & 1 ) /* bug fix by sakw: rounding applies to > ptr relative to start of buf */ SHAR_EOF fi # end of overwriting check if test -f 'w2t.diff.2' then echo shar: will not over-write existing file "'w2t.diff.2'" else cat << \SHAR_EOF > 'w2t.diff.2' 17a18,20 > version 1.3, sakw, Nov 25, 85. Fixes for "hanging indents" > Dec 16, 85. Handle user-specifed page breaks > Fix spurious style/size changes 26c29 < #define VERSION "1.2" --- > #define VERSION "1.3" 32a36 > #include <strings.h> 37a42 > #include <string.h> 82a88 > int hangingPar = 0; /* sakw fix for hanging indents */ 152a159,161 > int hangingTag = 0; /* sakw fix for hanging indents */ > int prevHanging = 0; > int nf = 0; /* sakw check for end of format table */ 159,160c168,171 < debug("height %d, position %d, page #%d\n", textInfo[j].paraHeight, < textInfo[j].position, textInfo[j].pageNum); --- > debug("height %d, position %d, page #%d, offset %x\n", > textInfo[j].paraHeight, > textInfo[j].position, textInfo[j].pageNum, > textInfo[j].dataPtr); 196,197c207,211 < if (curJust != LEFTJUST) printf(".pp\n"); < else printf(".br\n"); --- > /* sakw fix for hanging indents */ > if (! hangingPar) > if (curJust == LEFTJUST || curJust == BOTHJUST) > printf(".pp\n"); > else printf (".br\n"); 202c216 < if ( textInfo[j].parFlags & PF_LOCALJUST ) --- > if ( textInfo[j].parFlags & PF_LOCALJUST ) { 203a218,220 > prevHanging = hangingPar; > hangingPar = 0; > } 211a229 > hangingTag = 0; 212a231,232 > nf = td->nformats; > /* sakw - check for end of format info */ 214,216c234,244 < if(i == fp->charPos) { < col += doFormat(fp,i); < if(td->nformats > 1) /* bug fix by sakw: there is always 1 format info itm */ --- > /* sakw fix for hanging indents */ > if (hangingPar && (i == 0)) { > printf(".ip \042"); > hangingTag = 1; > } > > if( i == fp->charPos ) { > debug("charpos= %d\n",i); > col += doFormat(fp,hangingTag ? 1 : i); > if (--nf > 0) > /* bug fix by sakw: there is always 1 format info itm */ 229a258,259 > > 231a262,267 > else if (hangingTag && (*cp == '\t')) { > skipBlanks = 1; > printf("\042\n"); > col = -1; > hangingTag = 0; > } 244a281 > if (hangingTag) putchar('"'); /* sakw - o/p closing quote */ 247c284 < if ( textInfo[j].parFlags & PF_LOCALJUST ) --- > if ( textInfo[j].parFlags & PF_LOCALJUST ) { 249c286,287 < --- > hangingPar = prevHanging; > }; 250a289 > 259,261c298,307 < if ( pflag ) { < printf(".br\n.(b\n.sv %.1fi\n.)b\n", < textInfo[j].paraHeight/80. ); --- > /* sakw: user-specified page breaks ("Insert page break" from "Format") > are stored as "magic" picture paragraphs > output a .bp followed by a .rs to allow for (presumably > intentional) blank lines at top of page > */ > if ( chk_pg_brk( f, &textInfo[j] ) ) > printf(".bp\n.rs\n"); > else if ( pflag ) { > printf(".br\n.(b\n.sv %.1fi\n.)b\n", > textInfo[j].paraHeight/80. ); 263c309 < -textInfo[j].paraHeight/80. ); --- > -textInfo[j].paraHeight/80. ); 271a318 > 410c457 < * sakw: set leading to 2 point --- > * sakw: set leading to 20% of current point 412c459 < newSpacing = ((ruler->flags & RF_6LPI? 1 : 2) * (ruler->spacing + 2)) / 2; --- > newSpacing = ((ruler->flags & RF_6LPI? 1 : (curPoint / 5)) * (ruler->spacing + 2)) / 2; 423,427d469 < if ( curIndent != curLeft / 80. ) { < curIndent = curLeft / 80.; < printf(".ba %.1fi\n", curIndent); < printf(".nr $i %.1fi\n", curIndent); < } 432,434c474,493 < if ( curParIndent != (ruler->paraIndent / 80. - curIndent) ) { < curParIndent = ruler->paraIndent / 80. - curIndent; < printf(".nr pi %.1fi\n", curParIndent ); --- > if ( curParIndent != ((ruler->paraIndent - curLeft) / 80.) ) { > curParIndent = (ruler->paraIndent - curLeft)/ 80.; > if ( (hangingPar = (curParIndent < 0))) { > debug("hangingPar=%d\n",hangingPar); > /* we have a hanging indent - sakw */ > printf(".nr ii %.1fi\n", -curParIndent); > if ( curIndent != ruler->paraIndent / 80. ) { > curIndent = ruler->paraIndent / 80.; > printf(".ba %.1fi\n", curIndent); > printf(".nr $i %.1fi\n", curIndent); > } > } > else { > printf(".nr pi %.1fi\n", curParIndent ); > if ( curIndent != curLeft / 80. ) { > curIndent = curLeft / 80.; > printf(".ba %.1fi\n", curIndent); > printf(".nr $i %.1fi\n", curIndent); > } > } 436a496 > 593c653 < --- > 663a724 > debug("fp=%x databuf=%x nformats=%d\n",fp,dataBuf,nformats); 692a754,780 > /* sak w - page breaks are stored as a "magic picture" > * whose 1st 2 bytes are 0 and whose last 14 bytes are > * 000d 4d41 4749 4350 4943 1101 ff00 > * there must be an easier way to test for this!! > * return true or false > */ > > #define MAGIC_SIZE 22 > #define MAGIC_STR "\0x0dMAGICPIC\0x11\0x01\0xff" > chk_pg_brk ( f, par) > struct infoArrayElem *par; > { static struct { > long picFirst; > long filler; > char picBytes[14]; > } picData; > > debug ("picture data at offset %x size = %d\n", par->dataPtr, > par->parBytes); > if (par->parBytes != MAGIC_SIZE) return (0); > lseek( f, par->dataPtr, 0 ); > if (read( f, &picData, MAGIC_SIZE ) != MAGIC_SIZE) > error( "error reading picture info" ); > debug ("first word of pic is %x\n", picData.picFirst); > return ( (picData.picFirst == 0) && > (strcmp(MAGIC_STR,picData.picBytes) == 0) ); > } SHAR_EOF fi # end of overwriting check # End of shell archive exit 0