diff --git a/bin/aroff/aroff.c b/bin/aroff/aroff.c index c4b295b..feb19d2 100644 --- a/bin/aroff/aroff.c +++ b/bin/aroff/aroff.c @@ -4,18 +4,24 @@ Main loop driver code and awgs wordproc file read routines - $Id: aroff.c,v 1.2 1999/01/15 08:36:31 gdr-ftp Exp $ + $Id: aroff.c,v 1.3 1999/01/15 15:45:04 gdr-ftp Exp $ */ -#pragma stacksize 2048 #include #include #include #include #include #include +#include +#include +#include "aroff.h" -#include "awgs.h" +int noboldflag = 0; +saveArray *docSaveArray; +Ruler *docRulers; +textBlock **docTextBlocks; /* an array of textBlockPtrs */ +word docSACount, numRulers, numBlocks; void fileError(char *s) { @@ -32,21 +38,15 @@ void fileError(char *s) } } -int noboldflag = 0; -saveArray *docSaveArray; -Ruler *docRulers; -textBlock **docTextBlocks; /* an array of textBlockPtrs */ -word docSACount, numRulers, numBlocks; - void readAWGS(char *file) { int ref,err,z; /* refnum, err temp, and loop variable */ long recBlockSize; /* size of the upcoming text block */ int cl[2]; /* pBlock for GS/OS CloseGS call */ - GSString255 f; /* converted cstring(file) -> GSString */ - OpenRecGS o; /* pBlock for GS/OS Open call */ - SetPositionRecGS p; - IORecGS i; + static GSString255 f; /* converted cstring(file) -> GSString */ + static OpenRecGS o; /* pBlock for GS/OS Open call */ + static SetPositionRecGS p; + static IORecGS i; f.length = strlen(file); strcpy(f.text,file); @@ -154,10 +154,13 @@ int main(int argc, char *argv[]) { int i,z; extern void printAWGS(void); +#if 0 extern int _INITGNOSTDIO(); _INITGNOSTDIO(); - +#endif + + __REPORT_STACK(); /* show stack usage on exit if __CHECK_STACK__ defined */ if (argc == 1) { usage(); } diff --git a/bin/aroff/print.c b/bin/aroff/print.c index 2012e05..de7ebc7 100644 --- a/bin/aroff/print.c +++ b/bin/aroff/print.c @@ -3,7 +3,7 @@ the code that formats each individual paragraph is here. - $Id: print.c,v 1.2 1999/01/15 08:36:31 gdr-ftp Exp $ + $Id: print.c,v 1.3 1999/01/15 15:45:04 gdr-ftp Exp $ */ #include @@ -11,8 +11,7 @@ #include #include #include - -#include "awgs.h" +#include "aroff.h" extern saveArray *docSaveArray; extern Ruler *docRulers; @@ -51,17 +50,26 @@ void printPara(RulerPtr ruler, pgraphPtr pptr) calcLine: /* width determines how long this line is in characters; thus, where the break for word wrap will occur */ - if (curLine == 0) width = (ruler->rightMargin - ruler->indentMargin)/8; - else width = (ruler->rightMargin - ruler->leftMargin)/8; - + if (curLine == 0) { + width = (ruler->rightMargin - ruler->indentMargin)/8; + } else { + width = (ruler->rightMargin - ruler->leftMargin)/8; + } + while (*txt != 0x0d) { switch (*txt) { case 1: txt+=3; break; case 2: style = *(++txt); - if (noboldflag) { ++txt; break; }/* turn off boldfacing */ - if (style & 3) paraBuf[curLine][col++] = 15; - else paraBuf[curLine][col++] = 14; + if (noboldflag) { /* turn off boldfacing */ + ++txt; + break; + } + if (style & 3) { + paraBuf[curLine][col++] = 15; + } else { + paraBuf[curLine][col++] = 14; + } txt++; break; case 3: txt+=2; break; @@ -75,15 +83,17 @@ calcLine: numctrl = 0; for (z = col - 1; z > 0; z--) { if (paraBuf[curLine][z] == ' ') { - if (z != col - 1) + if (z != col - 1) { memcpy(¶Buf[curLine+1][0],¶Buf[curLine][z+1], (size_t) (col - z - 1)); + } paraBuf[curLine][z] = 0; curLine++; printcol -= (z + 1 + numctrl); col -= (z + 1); goto calcLine; + } else if (paraBuf[curLine][z] < ' ') { + numctrl++; } - else if (paraBuf[curLine][z] < ' ') numctrl++; } curLine++; col = printcol = 0; /* one big word... don't break line */ @@ -98,12 +108,13 @@ calcLine: if (z == 0) { width = (ruler->rightMargin - ruler->indentMargin)/8; left = (ruler->indentMargin)/8; - } - else { + } else { width = (ruler->rightMargin - ruler->leftMargin)/8; left = (ruler->leftMargin)/8; } - for (i = 0; i < left; i++) putchar(' '); + for (i = 0; i < left; i++) { + putchar(' '); + } printf("%s\n",paraBuf[z]); } }