home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / ro / part02 < prev    next >
Encoding:
Internet Message Format  |  1990-02-05  |  48.3 KB

  1. Subject:  v21i004:  A text formatter with some nroff-like capabilities, Part02/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: tcamp@dukeac.UUCP (Ted A. Campbell)
  7. Posting-number: Volume 21, Issue 4
  8. Archive-name: ro/part02
  9.  
  10. #! /bin/sh
  11. #
  12. # This is a shell archive.  Save this into a file, edit it
  13. # and delete all lines above this comment.  Then give this
  14. # file to sh by executing the command "sh file".  The files
  15. # will be extracted into the current directory owned by
  16. # you with default permissions.
  17. #
  18. # The files contained herein are:
  19. #
  20. # -rw-r--r--  1 tcamp   users      8693 Nov 24 12:50 ro_dive.c
  21. # -rw-r--r--  1 tcamp   users      8527 Nov 24 12:50 ro_word.c
  22. # -rw-r--r--  1 tcamp   users      7044 Nov 24 12:50 ro_text.c
  23. # -rw-r--r--  1 tcamp   users      5367 Nov 24 12:50 ro_setp.c
  24. # -rw-r--r--  1 tcamp   users      8805 Nov 24 12:50 ro_outp.c
  25. # -rw-r--r--  1 tcamp   users       280 Nov 10 09:08 Makefile
  26. # -rw-r--r--  1 tcamp   users       827 Nov 24 13:05 ro.mak
  27. # -rw-r--r--  1 tcamp   users       355 Nov 24 12:50 term.h
  28. # -rw-r--r--  1 tcamp   users       730 Nov 24 12:50 termnull.c
  29. # -rw-r--r--  1 tcamp   users       796 Nov 24 12:50 termansi.c
  30. # -rw-r--r--  1 tcamp   users       843 Nov 24 12:50 termnx10.c
  31. #
  32. echo 'x - ro_dive.c'
  33. if test -f ro_dive.c; then echo 'shar: not overwriting ro_dive.c'; else
  34. sed 's/^X//' << '________This_Is_The_END________' > ro_dive.c
  35. X/********************************************************/
  36. X/*                            */
  37. X/*    ro_dive.c    diversion and register routines    */
  38. X/*            for ro                */
  39. X/*                            */
  40. X/*    ro version 1.00                    */
  41. X/*                            */
  42. X/*    Portions copyright (c) 1989 by Ted A. Campbell    */
  43. X/*        Bywater Software            */
  44. X/*        P. O. Box 4023                */
  45. X/*        Duke Station                */
  46. X/*        Durham, NC  27706            */
  47. X/*                            */
  48. X/*    Contains portions of ROFF4, Version 1.60    */
  49. X/*      (c) 1983, 4 by Ernest E. Bergmann               */
  50. X/*        Physics, Building #16            */
  51. X/*        Lehigh University            */
  52. X/*        Bethlehem, Pa. 18015            */
  53. X/*                            */
  54. X/*    Contains portions of ROFF4, Version 1.61    */
  55. X/*      (c) 1985 by Konrad Kwok                         */
  56. X/*        20 3rd Street, Section M        */
  57. X/*        Fariview Park,                */
  58. X/*        Hong Kong                */
  59. X/*                            */
  60. X/*    ro and its predecessor ROFF4 are based on     */
  61. X/*    the ROFF text processor described in Kernigan    */
  62. X/*    and Plauger's now-classic text <Software Tools> */
  63. X/*                            */
  64. X/* Permission is hereby granted for all commercial and    */
  65. X/* non-commercial reproduction and distribution of this */
  66. X/* material provided this notice is included.        */
  67. X/*                            */
  68. X/********************************************************/
  69. X
  70. X#include "ro.h"
  71. X
  72. X/****************************************/
  73. X/* checks RLIST; creates new entry if needed;
  74. X   returns pointer to integer variable */
  75. X
  76. Xint *
  77. Xregist( s )     
  78. X    char *s;
  79. X    {
  80. X    struct divfd *pw;
  81. X    int *pi;
  82. X    char *pc, *s2;
  83. X    struct divfd *sptr;
  84. X
  85. X    pw = find2( s, rlink );    
  86. X
  87. X    if ( pw != NULL ) 
  88. X        {
  89. X        return( &( pw->val ) );
  90. X        }
  91. X
  92. X    /*  else create new entry */
  93. X
  94. X    if ( ( sptr = (struct divfd *) malloc( (size_t) sizeof( struct divfd ))) == NULL )
  95. X        {
  96. X        fprintf( stderr, "Fatal error: cannot allocate memory for register structure.  \n" );
  97. X        exit ( -1 );
  98. X        }
  99. X    sptr->prev = rlink;        /* save previous link    */
  100. X    strcpy( sptr->nm, s );        /* copy register name to structure */
  101. X    sptr->bf = NULL;        /* not a stream */
  102. X    sptr->mstr = NULL;        /* and not a macro */
  103. X    rlink = sptr;            /* set new link     */
  104. X    pi = &(sptr->val);
  105. X    *pi = REGDEF;
  106. X    return( pi );
  107. X    }
  108. X
  109. X/****************************************/
  110. X/* process .nr request                  */
  111. X
  112. Xdovar()
  113. X    {
  114. X    static char wbuf[MAXLINE];
  115. X    static int typ;
  116. X    int val, *pw;
  117. X    getwrd( ro_curline, wbuf );
  118. X    skip_blanks( ro_curline );
  119. X    val = get_val( ro_curline, &typ );
  120. X    getwrd( ro_curline, wbuf);
  121. X    if ( wbuf[0] == NUMSIGN && wbuf[1] == '\0' )
  122. X        {
  123. X        set( &ro_newpag, val, typ, ro_newpag, 1, 9999);
  124. X        }
  125. X    else
  126. X        {
  127. X        pw = (int *) regist(wbuf);
  128. X        set( pw, val, typ, REGDEF, 0, 9999);
  129. X        }
  130. X    }
  131. X
  132. Xpreregister( name, value )
  133. X    char *name;
  134. X    int value;
  135. X    {
  136. X    int *pw;
  137. X    pw = (int *) regist( name );
  138. X    *pw = value;
  139. X    }
  140. X
  141. X/****************************************/
  142. X/* process .di version */
  143. X
  144. Xdodiv()         
  145. X    {
  146. X    char wbuf[MAXLINE], *pc, *pc1, *wb;
  147. X    struct divfd *pd;
  148. X    int *pw, p;
  149. X
  150. X    getwrd( ro_curline, wbuf );
  151. X    if ( getwrd( ro_curline, wbuf) != WE_HAVE_A_WORD )
  152. X        {
  153. X        strcpy( wbuf, "div.$$$");
  154. X        fprintf( stderr,".di:  no name, %s assumed\n",
  155. X            wbuf);
  156. X        }
  157. X    if ( strlen( wbuf ) > 2 )
  158. X        {
  159. X        wbuf[ 2 ] = '\0';
  160. X        if ( ro_verbose )
  161. X            {
  162. X            fprintf( stderr,
  163. X                ".di:  name over two characters shortened to <%s> \n",
  164. X                wbuf );
  165. X            }
  166. X        }    
  167. X
  168. X    if ( ( pd = find2( wbuf, dlink )) != NULL ) /*if in table*/
  169. X        {
  170. X        if DEBUG
  171. X            {
  172. X            fprintf( stderr, "DEBUG:  diversion <%s> found. \n",
  173. X                wbuf );
  174. X            }
  175. X        if ( ( pd->bf == NULL ))        /* file not open */
  176. X            {
  177. X            if (( pd->bf = fopen( pd->fn, "w" )) != NULL)
  178. X                {
  179. X                if DEBUG
  180. X                    {
  181. X                    fprintf( stderr, "DEBUG:  .di:  <%s> reopened for diversion.\n", pd->fn );
  182. X                    }
  183. X                }
  184. X            else
  185. X                {
  186. X                fprintf( stderr, "Fatal error:  <%s> cannot be rewritten\n",wbuf);
  187. X                exit( -1 );
  188. X                }
  189. X            }
  190. X        }
  191. X    else            /* not in table, build new entry */
  192. X        {
  193. X
  194. X        if ( ( pd = (struct divfd *) malloc( (size_t) sizeof( struct divfd ))) == NULL )
  195. X            {
  196. X            fprintf( stderr, "Fatal error: cannot allocate memory for diversion structure.  \n" );
  197. X            exit ( -1 );
  198. X            }
  199. X
  200. X        pd->prev = dlink;        /* save previous link    */
  201. X        strcpy( pd->nm, wbuf );        /* save name        */
  202. X        dlink = pd;            /* set new link     */
  203. X        pd->mstr = NULL;        /* not a macro        */
  204. X        pd->ls = pd->cs = 0;        /* set these to 0       */
  205. X        strcpy( pd->fn, wbuf );        /* get name in filename */
  206. X        strcat( pd->fn, "_ro.div" );    /* make unique diversion name */
  207. X
  208. X        if (( pd->bf = fopen( pd->fn, "w" )) == NULL )
  209. X            {
  210. X            fprintf( stderr, 
  211. X                "Fatal error:  Can't create diversion file <%s>.\n", pd->fn );
  212. X            exit( -1 );
  213. X            }
  214. X        }
  215. X
  216. X    /*** from this point we may presume a valid structure and file */
  217. X
  218. X    while ( ro_gets( ro_curline ) != NULL )
  219. X        {
  220. X        if (( *ro_curline == COMMAND ) && ( comtyp( ro_curline ) == DI )) 
  221. X            {
  222. X
  223. X            /*** NESTING of diversions not currently supported; 
  224. X                 implementation would require testing at this point 
  225. X                 for argument to .di ***/
  226. X
  227. X            break;
  228. X            }
  229. X        if ( pc = (char *) macq( ro_curline))    /* if macro    */
  230. X            {
  231. X            pbmac( pc, ro_curline);    /* process macro */
  232. X            continue;
  233. X            }
  234. X
  235. X        /*else*/
  236. X
  237. X        p = strlen( ro_curline );
  238. X        ro_curline[ p ] = '\n';        /* terminate the line with CR */
  239. X        ++p;
  240. X        ro_curline[ p ] = '\0';        /* and then '\0' */
  241. X        fputs( ro_curline, pd->bf );    /* and put to diversion file */
  242. X        ( pd->ls )++;            /* increment line counter */
  243. X        ( pd->cs ) += strlen( ro_curline ); /* and char counter */
  244. X        }
  245. X    }
  246. X
  247. X/****************************************/
  248. X/* read from diversion                  */
  249. X
  250. Xread_div( sptr )
  251. X    struct divfd *sptr;
  252. X    {
  253. X    if ( sptr->bf != NULL )
  254. X        {
  255. X        dclose( sptr );
  256. X        }
  257. X
  258. X    if DEBUG
  259. X        {
  260. X        fprintf( stderr, "DEBUG:  reading from diversion <%s>, file <%s> \n",
  261. X            sptr->nm, sptr->fn );
  262. X        }
  263. X
  264. X    if ( ro_fptr < FMAX ) 
  265. X        {
  266. X        ro_fstack[ ro_fptr++ ] = instream;
  267. X        }
  268. X    else    
  269. X        {
  270. X        fprintf( stderr,"Fatal error:  ro_fstack overflow\n");
  271. X        exit( -1 );
  272. X        }
  273. X
  274. X    if (( instream = fopen( sptr->fn, "r" )) != NULL ) 
  275. X        {
  276. X        return;        /* file opened successfully */
  277. X        }
  278. X
  279. X    /* else the attempt has failed */
  280. X
  281. X    if ( ro_verbose )
  282. X        {
  283. X        fprintf( stderr, ".%s:  can't open <%s>\n", sptr->nm, sptr->fn );
  284. X        }
  285. X    endso();
  286. X
  287. X    }
  288. X
  289. X/****************************************/
  290. X/* .so -- read from source file         */
  291. X
  292. Xsource()
  293. X    {
  294. X    char name[ MAXLINE ];
  295. X
  296. X    getwrd( ro_curline, name );
  297. X    if( getwrd( ro_curline, name ) != WE_HAVE_A_WORD)
  298. X        {
  299. X        if ( ro_verbose )
  300. X            {
  301. X            fprintf( stderr,".so has no name\n");
  302. X            }
  303. X        return -1;
  304. X        }
  305. X
  306. X    if ( ro_fptr < FMAX ) 
  307. X        {
  308. X        ro_fstack[ ro_fptr++ ] = instream;
  309. X        }
  310. X    else    
  311. X        {
  312. X        fprintf( stderr,"Fatal error:  ro_fstack overflow\n");
  313. X        exit( -1 );
  314. X        }
  315. X
  316. X    if (( instream = fopen( name, "r" )) != NULL ) 
  317. X        {
  318. X        return;
  319. X        }
  320. X
  321. X    /* else the attempt has failed */
  322. X
  323. X    if ( ro_verbose )
  324. X        {
  325. X        fprintf( stderr, ".so:  can't open <%s>\n", name );
  326. X        }
  327. X    endso();
  328. X    }
  329. X
  330. X/****************************************/
  331. X
  332. Xshowr() /*lists register names and contents*/
  333. X    {
  334. X    struct divfd *pw;
  335. X    fprintf( stderr, "REGISTERS and <values>:\n");
  336. X    pw = rlink;
  337. X    while ( pw != NULL )
  338. X        {
  339. X        fprintf( stderr, "%s:\t<%d> \n",pw->nm, pw->val );
  340. X        pw = pw->prev;
  341. X        }
  342. X    dashes();
  343. X    }
  344. X
  345. X/****************************************/
  346. X
  347. Xshowd() /*shows all diversions and status*/
  348. X    {
  349. X    struct divfd *pd;
  350. X
  351. X    fprintf( stderr, "Diversion files:\n");
  352. X    pd = dlink;
  353. X    while( pd != NULL )
  354. X        {
  355. X        fprintf( stderr, "%s:\t", pd->nm );
  356. X        fprintf( stderr, "%d characters, %d lines [",
  357. X        pd->cs, pd->ls );
  358. X        if( pd->bf ) 
  359. X            {
  360. X            fprintf( stderr, "open]\n");
  361. X            }
  362. X        else    
  363. X            {
  364. X            fprintf( stderr, "closed]\n");
  365. X            }
  366. X        pd = pd->prev;
  367. X        }
  368. X    dashes();
  369. X    }
  370. X
  371. X/****************************************/
  372. X/* flushes and closes all open diversions, */
  373. X/* erases diversion files */
  374. X
  375. Xdsclose()     
  376. X    {
  377. X    struct divfd *pd;
  378. X
  379. X    pd = dlink;
  380. X    while( pd != NULL )
  381. X        {
  382. X        if ( pd->bf != NULL ) 
  383. X            {
  384. X            dclose( pd );
  385. X            if ( unlink( pd->fn ) == -1 )
  386. X                {
  387. X                if DEBUG
  388. X                    {
  389. X                    fprintf( stderr, "Failed to erase <%s> \n",
  390. X                        pd->fn );
  391. X                    }
  392. X                }
  393. X            }
  394. X        pd = pd->prev;
  395. X        }
  396. X    }
  397. X
  398. X/****************************************/
  399. X
  400. Xdclose( pd )        /*flushes and closes diversion*/
  401. X    struct divfd *pd;
  402. X    {
  403. X    if ( pd && ( !( pd->bf ))) 
  404. X        {
  405. X        return(FALSE);
  406. X        }
  407. X
  408. X    if ( ro_verbose == TRUE )
  409. X        {
  410. X        fprintf( stderr, "Closing %s ", pd->nm );
  411. X        }
  412. X
  413. X    fflush( pd->bf );        /* Flush the stream        */
  414. X
  415. X    if( fclose( pd->bf ) == ERROR )    /* Close the file        */
  416. X        {
  417. X        if ( ro_verbose == TRUE )
  418. X            {
  419. X            fprintf( stderr, "FAILED! \n" );
  420. X            }
  421. X        }
  422. X    else if ( ro_verbose == TRUE )
  423. X        {
  424. X        fprintf( stderr, "[O.K.]\n");
  425. X        pd->bf = NULL;        /* Set file pointer to NULL    */
  426. X        }
  427. X    return( TRUE );            /* Indicate successful completion */
  428. X    }
  429. X
  430. X/****************************************/
  431. X
  432. Xucstr(s)        /*convert s to upper case*/
  433. X    char *s;
  434. X    {
  435. X    while(*s)
  436. X        {
  437. X        *s = toupper(*s);
  438. X        s++;
  439. X        }
  440. X    }
  441. X
  442. X/****************************************/
  443. X
  444. Xendso() /*called upon EOF to return to previous input file*/
  445. X    {
  446. X    if ( ro_fptr )
  447. X        {
  448. X        fclose( instream );
  449. X        instream = ro_fstack[ --ro_fptr ];
  450. X        }
  451. X    ro_binp = 0;
  452. X    }
  453. X
  454. X/****************************************/
  455. X
  456. Xdashes()
  457. X    {
  458. X    fprintf( stderr, "-----------\n");
  459. X    }
  460. ________This_Is_The_END________
  461. if test `wc -l < ro_dive.c` -ne 425; then
  462.     echo 'shar: ro_dive.c was damaged during transit (should have been 425 bytes)'
  463. fi
  464. fi        ; : end of overwriting check
  465. echo 'x - ro_word.c'
  466. if test -f ro_word.c; then echo 'shar: not overwriting ro_word.c'; else
  467. sed 's/^X//' << '________This_Is_The_END________' > ro_word.c
  468. X/********************************************************/
  469. X/*                            */
  470. X/*    ro_word.c    word-handling routines for ro    */
  471. X/*                            */
  472. X/*    ro version 1.00                    */
  473. X/*                            */
  474. X/*    Portions copyright (c) 1989 by Ted A. Campbell    */
  475. X/*        Bywater Software            */
  476. X/*        P. O. Box 4023                */
  477. X/*        Duke Station                */
  478. X/*        Durham, NC  27706            */
  479. X/*                            */
  480. X/*    Contains portions of ROFF4, Version 1.60    */
  481. X/*      (c) 1983, 4 by Ernest E. Bergmann               */
  482. X/*        Physics, Building #16            */
  483. X/*        Lehigh University            */
  484. X/*        Bethlehem, Pa. 18015            */
  485. X/*                            */
  486. X/*    Contains portions of ROFF4, Version 1.61    */
  487. X/*      (c) 1985 by Konrad Kwok                         */
  488. X/*        20 3rd Street, Section M        */
  489. X/*        Fariview Park,                */
  490. X/*        Hong Kong                */
  491. X/*                            */
  492. X/*    ro and its predecessor ROFF4 are based on     */
  493. X/*    the ROFF text processor described in Kernigan    */
  494. X/*    and Plauger's now-classic text <Software Tools> */
  495. X/*                            */
  496. X/* Permission is hereby granted for all commercial and    */
  497. X/* non-commercial reproduction and distribution of this */
  498. X/* material provided this notice is included.        */
  499. X/*                            */
  500. X/********************************************************/
  501. X
  502. X#include "ro.h"
  503. X
  504. X/****************************************/
  505. X
  506. Xputtl3( s1, s2, s3, pageno )
  507. X    char *s1, *s2, *s3;
  508. X    int pageno;             /*put out three part title, none
  509. X                    containing '\n', with
  510. X                    optional page numbering; aligning
  511. X                    with page margins,0 & ro_rmval[0];*/
  512. X    {
  513. X    int size1, gap1, size2, gap2, size3, gaps, remain;
  514. X    size1 = strln3( s1, FALSE, pageno );
  515. X    ro_outtop = ro_ltop;
  516. X    ro_outbot = ro_lbot;
  517. X    size2 = strln3(s2,FALSE,pageno);
  518. X    if (ro_ltop<ro_outtop)
  519. X        ro_outtop=ro_ltop;
  520. X    size3 = strln3(s3,FALSE,pageno);
  521. X    if (ro_ltop<ro_outtop)
  522. X        ro_outtop=ro_ltop;
  523. X    gaps = ro_max( 0, ro_rmval[0]-size1-size2-size3);
  524. X    gap1 = gaps/2;
  525. X    gap2 = gaps-gap1;
  526. X    remain = ro_rmval[0];
  527. X    if ( size1 <= remain )
  528. X        {
  529. X        puttl( s1, pageno);
  530. X        remain -= size1;
  531. X        }
  532. X    if ( gap1 < remain )
  533. X        {
  534. X        blanks( gap1 );
  535. X        remain -= gap1;
  536. X        }
  537. X    if ( size2 <= remain )
  538. X        {
  539. X        puttl( s2, pageno );
  540. X        remain -= size2;
  541. X        }
  542. X    if ( gap2 < remain )
  543. X        {
  544. X        blanks( gap2 );
  545. X        remain -= gap2;
  546. X        }
  547. X    if ( size3 <= remain )
  548. X        {
  549. X        puttl( s3, pageno );
  550. X        remain -= size3;
  551. X        }
  552. X    printout();
  553. X    putchar('\r');
  554. X    }
  555. X
  556. X/****************************************/
  557. X
  558. Xblanks( i )
  559. X    int i;    /*sends i blanks to ro_out2buf*/
  560. X    {        
  561. X    if(i<0) return;
  562. X    for( ; i ; i--) putout( BLANK );
  563. X    }
  564. X
  565. X/****************************************/
  566. X/* Gets from source line three part title that it
  567. X    transfers to buffer delineated by ttl1 which has
  568. X    capacity for all three strings; none of the strings
  569. X    will contain '\n' */
  570. X
  571. Xgettl3( sl, ttl1, ttl2, ttl3 )
  572. X    char *sl, *ttl1, *ttl2, *ttl3;
  573. X    {
  574. X    char c, cc, *dp;
  575. X
  576. X    if DEBUG fprintf( stderr,"DEBUG:  gettl3() sl = <%s> \n", sl );
  577. X
  578. X    /*pass over command*/
  579. X
  580. X    for ( c = *sl; c != ' ' && c != '\n' && c != '\t'; sl++ )
  581. X        {
  582. X        c = *sl;
  583. X        }
  584. X
  585. X    /*advance to first non-blank or '\n' */
  586. X
  587. X    for ( ; c == ' ' || c == '\t'; sl++ )
  588. X        {
  589. X        c = *sl;
  590. X        }
  591. X
  592. X    /* c should now be set to the delimiter */
  593. X    /* advance beyond delimiter, if present */
  594. X
  595. X    if ( c != '\n' && !c ) 
  596. X        {
  597. X        sl++;
  598. X        }
  599. X
  600. X    dp = ttl1;
  601. X    transfer( &sl, &dp, c );
  602. X    dp = ttl2;
  603. X    transfer( &sl, &dp, c);
  604. X    dp = ttl3;
  605. X    transfer( &sl, &dp, c);
  606. X
  607. X    if DEBUG
  608. X        {
  609. X        fprintf( stderr,"DEBUG:  delim=<%c>\nT1=<%s>\nT2=<%s>\nT3=<%s>;\n",
  610. X            c, ttl1, ttl2, ttl3);
  611. X        }
  612. X
  613. X    }
  614. X
  615. X/****************************************/
  616. X/* Copy string from source to destination.    Original delim.
  617. Xcan be \0, \n, or char.    The pointer to the source is updated
  618. Xto point at the \0, \n, or past char.    In destination, delim.
  619. Xis always replaced by \0.    The destination pointer always
  620. Xpoints past this \0. */
  621. X
  622. Xtransfer( src, dst, c )
  623. X    char c;             /* terminal character */
  624. X    char **src;        /* source string */
  625. X    char **dst;        /* destination string */
  626. X    {
  627. X    char a;
  628. X
  629. X    a = **src;
  630. X    while ( a != c && a != '\n' && a != '\0' && a )
  631. X        {
  632. X        **dst = a;    
  633. X        (*dst)++;
  634. X        (*src)++;    
  635. X        a = **src;
  636. X        }
  637. X    **dst = '\0';
  638. X    (*dst)++;
  639. X    if ( a != '\n' ) 
  640. X        {
  641. X        (*src)++;
  642. X        }
  643. X    }
  644. X
  645. X/**********************************************************
  646. X centers a line of text
  647. X**********************************************************/
  648. X
  649. Xcenter (line)
  650. X    char *line;
  651. X    {
  652. X    ro_tival = ro_max(( ro_rmval[0]+ro_tival-strln3(line,FALSE,1))/2, 0 );
  653. X    ro_outtop=ro_ltop;
  654. X    ro_outbot=ro_lbot;
  655. X    return;
  656. X    }
  657. X
  658. X/************************************************************
  659. XRevised April 24,83.Transfers next word from in to out.    Scans
  660. Xoff leading white space from in.    If there is no word, returns
  661. XFALSE.    Otherwise, input is truncated on left of word which is
  662. Xtransfered to out without leading or trailling blanks.
  663. XWE_HAVE_A_WORD will be returned.    If the transfered word
  664. Xterminates a sentence then ro_sentence is set to 1, otherwise it
  665. Xis reset to FALSE.
  666. X**************************************************************/
  667. X
  668. Xint getwrd (in,    out )
  669. X    char *in, *out;
  670. X    {
  671. X    char *pin, *pout, c, cm, cp;
  672. X
  673. X    skip_blanks(in);
  674. X    replace_char(in,TAB,BLANK);
  675. X    pin = in;
  676. X    pout = out;
  677. X    c = *pin;
  678. X    ro_sentence=FALSE;
  679. X    if(c==NEWLINE || c=='\0')
  680. X        {
  681. X        *out='\0';
  682. X        if DEBUG fprintf( stderr,"DEBUG:  getwrd() = <%s> \n", out );
  683. X        return(FALSE);
  684. X        }
  685. X    while(c!=BLANK && c!=NEWLINE && c)
  686. X        {
  687. X        *(pout++) = c;
  688. X        *pin = BLANK;
  689. X        c=*(++pin);
  690. X        }
  691. X    *pout = '\0';    /*terminate out string*/
  692. X    cm=*(pout-1);
  693. X    cp=*(pin+1);
  694. X    switch (cm)
  695. X        {
  696. X    case ':' :
  697. X    case ';' :
  698. X    case '?' :
  699. X    case '!' :
  700. X            ro_sentence=1;
  701. X            break;
  702. X    case '.' :
  703. X            if(cp==BLANK||cp==NEWLINE||c==NEWLINE)
  704. X                 ro_sentence=1;
  705. X        }
  706. X    if DEBUG fprintf( stderr, "DEBUG:  getwrd() = <%s> \n", out );
  707. X    return(WE_HAVE_A_WORD);
  708. X    }
  709. X
  710. X/*******************************************************
  711. XTruncates white-space characters at the end of a string.
  712. X********************************************************/
  713. X
  714. Xtrunc_bl (string)
  715. X    char *string;
  716. X    {
  717. X    char *ptr;
  718. X    int k;
  719. X    k = strlen (string);
  720. X    ptr = &string[ k-1 ];     /* char before terminating nul */
  721. X    while (*ptr==BLANK || *ptr==TAB || *ptr==NEWLINE)        
  722. X            *ptr--    = '\0';
  723. X    }
  724. X
  725. X/*********************************************
  726. X         distribute words evenly across a line
  727. X**********************************************/
  728. X
  729. Xspread ( line, nextra, no_words)
  730. X    char *line;
  731. X    int nextra;    /* no. extra places left in line */
  732. X    int no_words;     /* no. words in the line        */
  733. X    {
  734. X    int i, j, nblanks, nholes;
  735. X
  736. X    if DEBUG fprintf( stderr,"DEBUG:  spread(): line = <%s>,\n        nextra = %d, no_words = %d\n",
  737. X         line, nextra, no_words    );
  738. X
  739. X    if (nextra <= 0 || no_words <= 1)
  740. X        return;
  741. X    ro_dir = !(ro_dir);
  742. X    nholes = no_words - 1;
  743. X    trunc_bl (line);
  744. X    i = strlen(line) - 1 ; /* last character of string */
  745. X    j = ro_min(MAXLINE-2,i+nextra);    /* last    position in output */
  746. X    line[j+1] = '\0';
  747. X    for ( ; i<j ; i--, j-- )
  748. X        { 
  749. X            line[j] = line[i];
  750. X            if ( line[i] == BLANK)
  751. X                { 
  752. X                 if (ro_dir == 0) nblanks=(nextra-1)/nholes+1;
  753. X                 else            nblanks = nextra/nholes;
  754. X                 nextra = nextra - nblanks;
  755. X                 nholes = nholes - 1;
  756. X                 for ( ; nblanks > 0;    nblanks-- )
  757. X                    line[--j] = BLANK;
  758. X                }
  759. X        }
  760. X    }
  761. X
  762. X/************************************************
  763. Xplace portion of title line with optional page no. in ro_out2buf
  764. X*************************************************/
  765. X
  766. Xputtl ( str, num )
  767. X    char *str;
  768. X    int num;
  769. X    {
  770. X    int i;
  771. X    char c;
  772. X    for (i=0;c= *str; str++)
  773. X        {
  774. X            if ( c != NUMSIGN ) putout(c);
  775. X            else putnum(num);
  776. X        }
  777. X    }
  778. X
  779. X/*******************************************
  780. X put out num to ro_out2buf (conversion)
  781. X********************************************/
  782. Xputnum ( num, w )
  783. X    int num;
  784. X    {
  785. X    int i, nd;
  786. X    char chars[10];
  787. X    nd = itoc ( num, chars, 10 );
  788. X    for ( i=0;i<nd; i++) putout(chars[i]);
  789. X    }
  790. X
  791. X/************************************************
  792. X convert int num to char string in numstr
  793. X*************************************************/
  794. X
  795. Xitoc ( num, numstr, size )
  796. X    int num;
  797. X    char *numstr;
  798. X    int size;        /* largest size of numstr */
  799. X    {
  800. X    int absnum, i, j, k, d;
  801. X    absnum = abs (num);
  802. X    numstr[0] = '\0';
  803. X    i = 0;
  804. X    do         { 
  805. X            i++;
  806. X            d = absnum % 10;
  807. X            numstr[i] = d + '0';
  808. X            absnum = absnum/10;
  809. X        }
  810. X    while ( absnum != 0 && i<size );
  811. X    if ( num < 0 && i<size )
  812. X        { 
  813. X            i++;
  814. X            numstr[i] = '-';
  815. X        }
  816. X    for( j=0; j<i; j++ )
  817. X        { 
  818. X            k = numstr[i];
  819. X            numstr[i] = numstr[j];
  820. X            numstr[j] = k;
  821. X            i--;
  822. X        }
  823. X    return ( strlen(numstr) );
  824. X    }
  825. X
  826. X/****************************************/
  827. X
  828. Xputout(c)        /*places c in ro_out2buf[]*/
  829. X    char c;
  830. X    {
  831. X    if(c==ro_scval[0]) c= BLANK;
  832. X    if(c==NEWLINE)c='\0';
  833. X    ro_out2buf[ro_bpos++]=c;
  834. X    ro_out2buf[ro_bpos]='\0';/*safty net*/
  835. X    }
  836. X
  837. X/************************************
  838. X replace c1 in string with c2
  839. X*************************************/
  840. X
  841. Xreplace_char (string, c1, c2)
  842. X    char *string, c1, c2;
  843. X    {
  844. X    int i;
  845. X    for (i=0; string[i]; i++)
  846. X            if (string[i] == c1)    string[i] = c2;
  847. X    }
  848. ________This_Is_The_END________
  849. if test `wc -l < ro_word.c` -ne 380; then
  850.     echo 'shar: ro_word.c was damaged during transit (should have been 380 bytes)'
  851. fi
  852. fi        ; : end of overwriting check
  853. echo 'x - ro_text.c'
  854. if test -f ro_text.c; then echo 'shar: not overwriting ro_text.c'; else
  855. sed 's/^X//' << '________This_Is_The_END________' > ro_text.c
  856. X/********************************************************/
  857. X/*                            */
  858. X/*    ro_text.c    text-handling routines for ro    */
  859. X/*                            */
  860. X/*    ro version 1.00                    */
  861. X/*                            */
  862. X/*    Portions copyright (c) 1989 by Ted A. Campbell    */
  863. X/*        Bywater Software            */
  864. X/*        P. O. Box 4023                */
  865. X/*        Duke Station                */
  866. X/*        Durham, NC  27706            */
  867. X/*                            */
  868. X/*    Contains portions of ROFF4, Version 1.61    */
  869. X/*      (c) 1985 by Konrad Kwok                         */
  870. X/*        20 3rd Street, Section M        */
  871. X/*        Fariview Park,                */
  872. X/*        Hong Kong                */
  873. X/*                            */
  874. X/*      Contains portions of ROFF4, Version 1.60        */
  875. X/*      (c) 1983, 4 by Ernest E. Bergmann               */
  876. X/*              Physics, Building #16                   */
  877. X/*              Lehigh University                       */
  878. X/*              Bethlehem, Pa. 18015                    */
  879. X/*                                                      */
  880. X/*    ro and its predecessor ROFF4 are based on     */
  881. X/*    the ROFF text processor described in Kernigan    */
  882. X/*    and Plauger's now-classic text <Software Tools> */
  883. X/*                            */
  884. X/* Permission is hereby granted for all commercial and    */
  885. X/* non-commercial reproduction and distribution of this */
  886. X/* material provided this notice is included.        */
  887. X/*                            */
  888. X/********************************************************/
  889. X
  890. X#include "ro.h"
  891. X
  892. X/**************************************************
  893. Xhandles case of leading blanks or tabs; empty lines 
  894. X***************************************************/
  895. X
  896. Xleadbl( line )
  897. X    char *line;
  898. X    {
  899. X    int i, j, white;
  900. X    ro_brk();
  901. X    for ( white = 0, i = 0; line[i] == ' ' || line[i] == '\t'; i++ )
  902. X        {
  903. X        if (line[i] == ' ')
  904. X            white++;
  905. X        else
  906. X            white = ro_min( ro_rmval[0], ro_tabsiz[0]*(1+white/ro_tabsiz[0]));
  907. X        }
  908. X
  909. X    if ( line[i] != NEWLINE )
  910. X        ro_tival += white;
  911. X
  912. X    /* move line to left */
  913. X    for( j = 0; (line[j] = line[i]) != '\0'; j++, i++ );
  914. X    }
  915. X
  916. X/*****************************************
  917. Xputs out page header
  918. X******************************************/
  919. X
  920. Xphead()
  921. X    {
  922. X    exchange();
  923. X    ro_uf=ro_xf=FALSE;
  924. X    ro_mcnt=1;
  925. X    ro_curpag = ro_newpag++;
  926. X    preregister( "%", ro_curpag );
  927. X    if((ro_curpag<ro_firstpage)||(ro_curpag>ro_lastpage))
  928. X        ro_suppress=TRUE;
  929. X    else
  930. X        ro_suppress=FALSE;
  931. X    ro_oldln=-1;
  932. X    if( ro_pagestop )
  933. X        {
  934. X        fprintf( stderr, "%cPAGE:  Please type <RETURN> to continue:  ",
  935. X            BELL );
  936. X        getchar();         /* wait until char typed at console */ 
  937. X        }
  938. X    ro_plineno=0;
  939. X    ro_pflineno=0;
  940. X    if (ro_m1val[0] > 0 )
  941. X        { 
  942. X        ro_vlineno = ro_m1val[0]-1;
  943. X        if (ro_curpag % 2) puttl3 ( ro_ohead, ro_oh2, ro_oh3, ro_curpag );
  944. X        else puttl3 ( ro_ehead, ro_eh2, ro_eh3, ro_curpag );
  945. X        }
  946. X    ro_vlineno = ro_m1val[0]+ro_m2val[0]; 
  947. X    ro_vflineno=0;
  948. X    exchange();
  949. X    }
  950. X
  951. X/**************************************
  952. Xputs out page footer
  953. X***************************************/
  954. X
  955. Xpfoot()
  956. X    {
  957. X    exchange();
  958. X    ro_uf=ro_xf=FALSE;
  959. X    ro_mcnt=1;
  960. X    ro_vlineno = ro_bottom+ro_m3val[0]; 
  961. X    ro_vflineno=0;
  962. X    if ( ro_m4val[0] > 0 )
  963. X        { 
  964. X        if(ro_curpag % 2)puttl3 ( ro_ofoot,ro_of2,ro_of3, ro_curpag );
  965. X        else puttl3(ro_efoot,ro_ef2,ro_ef3,ro_curpag);
  966. X        }
  967. X    ro_vlineno = ro_plval[0];
  968. X    ro_vflineno=0;
  969. X    if (ro_useff) putchar(FORMF);
  970. X    else padv();
  971. X    ro_oldbot=ro_plineno=ro_pflineno=0; /*printer at start of newpage*/
  972. X    ro_oldln=-1;
  973. X    exchange();
  974. X    }
  975. X
  976. X/**********************************************
  977. Xspace n lines or to bottom of the page
  978. X***********************************************/
  979. X
  980. Xdo_space( n )
  981. X    int n;
  982. X    {
  983. X    ro_brk(); /* flush out last unfilled line */
  984. X    if ( ro_vlineno >= ro_bottom)    
  985. X        {
  986. X        return; /* end of page */
  987. X        }
  988. X    if ( ro_vlineno < 0) 
  989. X        {
  990. X        phead(); /* top of page */
  991. X        }
  992. X    ro_vlineno += n;
  993. X
  994. X    if ( ro_vlineno >= ro_bottom ) 
  995. X        {
  996. X        pfoot(); /* print footer if bottom */
  997. X        }
  998. X    }
  999. X
  1000. X/*******************************************************/
  1001. X
  1002. Xtext (line)
  1003. X    char *line;
  1004. X    {
  1005. X    char wrdbuf [LSZ];
  1006. X    int i, j, k;
  1007. X    char *p1, *p2;
  1008. X    if DEBUG fprintf( stderr, "DEBUG:  text: <%s> \n", line);
  1009. X
  1010. X    if (line[0] == BLANK || line[0]==NEWLINE || line[0] == TAB)
  1011. X        leadbl (line);
  1012. X    if (ro_ceval > 0)
  1013. X        { 
  1014. X        center(line);
  1015. X        put(line);
  1016. X        ro_ceval--;
  1017. X        }
  1018. X    else if ( ( line[0] == NEWLINE ) || ( line[0] == '\0' ))
  1019. X        {
  1020. X        do_space( ro_lsval[0] );
  1021. X        }
  1022. X    else if(!ro_fill[0])
  1023. X        put(line);
  1024. X    else
  1025. X        while (WE_HAVE_A_WORD == getwrd (line, wrdbuf))
  1026. X            putwrd (wrdbuf);
  1027. X    }
  1028. X
  1029. X/******************************************************
  1030. Xput out a line of text with correct indentation
  1031. Xunderlining if specified
  1032. X*******************************************************/
  1033. X
  1034. Xput (line)
  1035. X    char *line;
  1036. X    {
  1037. X    int i, fs, minfs;
  1038. X    if ((ro_vlineno < 0)||(ro_vlineno >= ro_bottom))
  1039. X        {
  1040. X        phead();
  1041. X        }
  1042. X    fs=(ro_vlineno-ro_oldln)*ro_frval;
  1043. X    minfs=ro_oldbot-ro_outtop; 
  1044. X    if(!(ro_oldbot&&ro_outtop))
  1045. X        {
  1046. X        minfs++;
  1047. X        }
  1048. X    while ( fs < minfs )
  1049. X        {
  1050. X        fs += ro_frval;
  1051. X        ro_vlineno++;
  1052. X        }
  1053. X    need(0);
  1054. X    putline(line);
  1055. X    ro_tival = ro_inval[0];
  1056. X    ro_vlineno += ro_lsval[0];
  1057. X    if (ro_vlineno >= ro_bottom)
  1058. X        {
  1059. X        pfoot();
  1060. X        }
  1061. X    }
  1062. X
  1063. X/***********************************************************
  1064. Xconcatenates the word onto the end of ro_outbuf for filled text
  1065. X************************************************************/
  1066. X
  1067. Xputwrd (wrdbuf) /*Nov 22: ro_sentence*/
  1068. X    char *wrdbuf;
  1069. X    {
  1070. X    int i, j, k;
  1071. X    char s[MAXLINE], ch;
  1072. X    int line_len, new_out_width, wid;
  1073. X    int nextra;
  1074. X    skip_blanks (wrdbuf); 
  1075. X    trunc_bl (wrdbuf);
  1076. X    wid =1+ro_sentence+strln3(wrdbuf,TRUE,1);/*sets ro_wtop,ro_wbot*/
  1077. X    line_len = ro_rmval[0] - ro_tival;
  1078. X    new_out_width = ro_outw+wid;
  1079. X    if (new_out_width > ro_min(line_len, MAXLINE-1))
  1080. X        { 
  1081. X        nextra = ro_min(line_len, MAXLINE-1)-ro_outw+1;
  1082. X        if(ro_outbuf[ro_outpos-2]==BLANK) nextra++;
  1083. X        if(ro_adjust) spread(ro_outbuf,nextra,ro_outwrds);
  1084. X        ro_brk();
  1085. X        }
  1086. X    ro_outw += wid;
  1087. X    OUTcat(wrdbuf);
  1088. X    OUTSP(); 
  1089. X    if(ro_sentence) OUTSP();
  1090. X    ro_outwrds++;
  1091. X    if(ro_wtop<ro_outtop) ro_outtop=ro_wtop;
  1092. X    if(ro_wbot>ro_outbot) ro_outbot=ro_wbot;
  1093. X    }
  1094. X
  1095. X/**********************************************************
  1096. Xa new putline routine; sends line to    OUTPUT2
  1097. X***********************************************************/
  1098. X
  1099. Xputline (line)
  1100. X    char *line;
  1101. X    {
  1102. X    char c;
  1103. X    blanks ( ro_tival );
  1104. X    for ( ; c = *line; line++ )
  1105. X        {
  1106. X        putout(c);
  1107. X        }
  1108. X    putout('\0');
  1109. X    printout();
  1110. X    }
  1111. X
  1112. X/****************************************/
  1113. X
  1114. XOUTcat(str)     /*appends string to ro_outbuf*/
  1115. X    char *str;
  1116. X    {
  1117. X    while(ro_outbuf[ro_outpos]=*(str++))
  1118. X        ro_outpos++;
  1119. X    }
  1120. X
  1121. X/****************************************/
  1122. X
  1123. XOUTSP()         /*appends BLANK to ro_outbuf*/
  1124. X    {
  1125. X    ro_outbuf[ro_outpos++]=BLANK;
  1126. X    ro_outbuf[ro_outpos]='\0';
  1127. X    }
  1128. X
  1129. X/****************************************/
  1130. X
  1131. Xgloss() /*prints on STDOUT a glossary of .tr chars*/
  1132. X    {
  1133. X    int i;
  1134. X    char line[20],tcs;
  1135. X    put("GLOSSARY:");
  1136. X    put("USE     <GET>");
  1137. X    tcs=ro_tcval[0];
  1138. X    ro_tcval[0] |= 128; /*set most significant bit*/
  1139. X    for(i=1;i<19;i++) line[i]=' ';
  1140. X    line[0]=tcs;
  1141. X    line[8]='<';
  1142. X    line[9]=ro_tcval[0];
  1143. X    line[11]='>';
  1144. X    line[12]='\0';
  1145. X    for(i=' ';i<127;i++)
  1146. X        {
  1147. X        if(ro_tptr[i-' '])
  1148. X            {
  1149. X            line[1]=line[10]=i;
  1150. X            put(line);
  1151. X            }
  1152. X        }
  1153. X    ro_tcval[0]=tcs;
  1154. X    do_space(HUGE);
  1155. X    }
  1156. X
  1157. X/***************************************/
  1158. X
  1159. Xexchange() /*maintain separate environment for headers and
  1160. X        footers*/
  1161. X    {
  1162. X    int i;
  1163. X    i=ro_mcnt2; 
  1164. X    ro_mcnt2=ro_mcnt; 
  1165. X    ro_mcnt=i;
  1166. X    i=ro_xf2; 
  1167. X    ro_xf2=ro_xf; 
  1168. X    ro_xf=i;
  1169. X    i=ro_uf2; 
  1170. X    ro_uf2=ro_uf; 
  1171. X    ro_uf=i;
  1172. X    }
  1173. ________This_Is_The_END________
  1174. if test `wc -l < ro_text.c` -ne 317; then
  1175.     echo 'shar: ro_text.c was damaged during transit (should have been 317 bytes)'
  1176. fi
  1177. fi        ; : end of overwriting check
  1178. echo 'x - ro_setp.c'
  1179. if test -f ro_setp.c; then echo 'shar: not overwriting ro_setp.c'; else
  1180. sed 's/^X//' << '________This_Is_The_END________' > ro_setp.c
  1181. X/********************************************************/
  1182. X/*                            */
  1183. X/*    ro_setp.c    set parameters and other     */
  1184. X/*            routines for ro            */
  1185. X/*                            */
  1186. X/*    ro version 1.00                    */
  1187. X/*                            */
  1188. X/*    Portions copyright (c) 1989 by Ted A. Campbell    */
  1189. X/*        Bywater Software            */
  1190. X/*        P. O. Box 4023                */
  1191. X/*        Duke Station                */
  1192. X/*        Durham, NC  27706            */
  1193. X/*                            */
  1194. X/*    Contains portions of ROFF4, Version 1.60    */
  1195. X/*      (c) 1983, 4 by Ernest E. Bergmann               */
  1196. X/*        Physics, Building #16            */
  1197. X/*        Lehigh University            */
  1198. X/*        Bethlehem, Pa. 18015            */
  1199. X/*                            */
  1200. X/*    Contains portions of ROFF4, Version 1.61    */
  1201. X/*      (c) 1985 by Konrad Kwok                         */
  1202. X/*        20 3rd Street, Section M        */
  1203. X/*        Fariview Park,                */
  1204. X/*        Hong Kong                */
  1205. X/*                            */
  1206. X/*    ro and its predecessor ROFF4 are based on     */
  1207. X/*    the ROFF text processor described in Kernigan    */
  1208. X/*    and Plauger's now-classic text <Software Tools> */
  1209. X/*                            */
  1210. X/* Permission is hereby granted for all commercial and    */
  1211. X/* non-commercial reproduction and distribution of this */
  1212. X/* material provided this notice is included.        */
  1213. X/*                            */
  1214. X/********************************************************/
  1215. X
  1216. X#include "ro.h"
  1217. X
  1218. X/**************************************************/
  1219. X
  1220. Xint value( base, string)    /*unsigned conversion*/
  1221. X    int base;            /*radix for conversion*/
  1222. X    char *string;             /*no leading blanks please!*/
  1223. X                /*trailing whitespace or '\0'*/
  1224. X    {
  1225. X    int val,d;
  1226. X    char c;
  1227. X    val=0;
  1228. X    for(d=digit(*string);d>=0 && d<base ; d=digit(*string))
  1229. X        {
  1230. X        val = val*base + d;
  1231. X        string++;
  1232. X        }
  1233. X    c = *string;
  1234. X    if ( !c || c==' ' || c==TAB || c=='\n') return(val);
  1235. X    else return(-1);        /*error return is -1*/
  1236. X    }
  1237. X
  1238. X/**************************************************/
  1239. X
  1240. Xint digit(d)
  1241. Xchar d;
  1242. X    {     
  1243. X    d=toupper(d);
  1244. X    if(d<='9') return(d-'0');
  1245. X    if(d<'A') return(-1); /*error return is negative val*/
  1246. X    if(d<='Z') return(10-'A'+d);
  1247. X    return(-1);     /*error*/
  1248. X    }
  1249. X
  1250. X/**************************************************/
  1251. X/* returns printed string length; checks legality of
  1252. Xword function; keeps track of vertical
  1253. Xexcursions; records them in globals */
  1254. X
  1255. Xstrln3( s, word, num )
  1256. X    char *s;
  1257. X    int word;               /* boolean, if true, check is made for none
  1258. X                    black characters in the string */
  1259. X    int num;                /* for expansion of NUMSIGN; set 1 to ignore */
  1260. X    {
  1261. X    int i, i2, p1, p2, p3;
  1262. X    int t, b, h;            /*vertical vars*/
  1263. X    char c, *ss;
  1264. X    ss = s;
  1265. X    t = b = h = 0;
  1266. X    p3 = p2 = p1 = -LSZ;
  1267. X    for ( c = *ss, i2 = i = 0; c; c = *(++ss) )
  1268. X        {
  1269. X        if ( c == NUMSIGN )
  1270. X            {
  1271. X            i++;
  1272. X            if(num>9) i++;
  1273. X            if(num>99) i++;
  1274. X            if(num>999) i++;
  1275. X            }
  1276. X        else if ( (c != ro_tcval[0] ) && ( c != ESCAPE ) )
  1277. X            {
  1278. X            if ( ( c <= ' ' ) && (word) )
  1279. X                {
  1280. X                if ( ro_verbose == TRUE )
  1281. X                    {
  1282. X                    fprintf( stderr, "ro: illegal character 0x%x \n",
  1283. X                        c );
  1284. X                    }
  1285. X                goto error;
  1286. X                }
  1287. X            else i++;
  1288. X            }
  1289. X        else if ( c == ESCAPE )
  1290. X            {
  1291. X            c = *(++ss);        
  1292. X            if ( c == ESCAPE ) 
  1293. X                {
  1294. X                goto error; /*both ro_cfval[0], ro_tcval[0] */
  1295. X                }
  1296. X            switch( c )
  1297. X                {
  1298. X                case ROMAN:
  1299. X                case ITALIC:
  1300. X                case BOLD:
  1301. X                case HALFUP:
  1302. X                case HALFDOWN:
  1303. X                    break;
  1304. X                default: 
  1305. X                    if (ro_verbose )
  1306. X                        fprintf( stderr, "ro:  c <%c> is not printer code. \n", c );
  1307. X                    goto error;     /*undecipherable*/
  1308. X                    break;
  1309. X                }
  1310. X            }
  1311. X        else    /*c==ro_tcval[0]*/
  1312. X            {
  1313. X            if(class(*(s+1))!=BLACK)
  1314. X                {
  1315. X                goto error;      /*illegal translation*/
  1316. X                }
  1317. X            }
  1318. X        }
  1319. X    if ( h )
  1320. X        {
  1321. X        goto error;
  1322. X        }
  1323. X    if ( word )
  1324. X        {
  1325. X        ro_wtop=t;
  1326. X        ro_wbot=b;
  1327. X        }
  1328. X    else
  1329. X        {
  1330. X        ro_ltop=t;
  1331. X        ro_lbot=b;
  1332. X        }
  1333. X    if(i>=i2)
  1334. X        {
  1335. X        return( i );
  1336. X        }
  1337. X
  1338. X    /* else prints beyond last character: */
  1339. X
  1340. Xerror:
  1341. X    if ( ro_verbose == TRUE )
  1342. X        {
  1343. X        fprintf( stderr, "ro: line <%s> is illegally formed.\n", s );
  1344. X        }
  1345. X
  1346. X    return ( strlen( ss ) );
  1347. X    }
  1348. X
  1349. X/* A properly formed token string has its first printable
  1350. Xcharacter indicating the lefthand edge and the last printable
  1351. Xcharacter at the right hand edge.    Only legal control pairs
  1352. Xaccepted.    It must consist of printable symbols. */
  1353. X
  1354. X/**************************************************************
  1355. XSet a stack variable like set() sets a global integer variable.  
  1356. X**************************************************************/
  1357. X
  1358. XsetS ( param, val, arg_typ, defval, minval, maxval )
  1359. X    int param[STKSIZ], val, defval, minval, maxval;
  1360. X    int arg_typ;
  1361. X    {
  1362. X    register int i;
  1363. X
  1364. X    if ( val == NO_VAL )
  1365. X        {
  1366. X        for ( i = 0; i < STKSIZ - 1; i++ )    /*pop*/
  1367. X            {
  1368. X            param[ i ] = param[ i + 1 ];
  1369. X            }
  1370. X        param[ STKSIZ - 1 ] = defval;
  1371. X        }
  1372. X    else
  1373. X        {
  1374. X        for ( i = STKSIZ - 1; i; i-- )    /*push*/
  1375. X            {
  1376. X             param[ i ] = param[ i - 1 ];
  1377. X            }
  1378. X        if ( arg_typ == '+' ) 
  1379. X            {
  1380. X            param[ 0 ] += val;
  1381. X            }
  1382. X        else if ( arg_typ == '-' ) 
  1383. X            {
  1384. X            param[ 0 ] -= val;
  1385. X            }
  1386. X        else param[ 0 ] = val;
  1387. X        }
  1388. X    param[ 0 ] = ro_min( ro_max( param[ 0 ], minval), maxval );
  1389. X
  1390. X    if DEBUG fprintf( stderr, "DEBUG:  setS(): *param = %d \n", *param );
  1391. X
  1392. X    }
  1393. X
  1394. X/******************************************
  1395. Xinitialize stack type variable, st, with v
  1396. X*******************************************/
  1397. X
  1398. Xinitsk( st, v )
  1399. X    int st[STKSIZ], v;
  1400. X    {
  1401. X    register int i;
  1402. X    for ( i = STKSIZ - 1; i >= 0; --i )
  1403. X        {
  1404. X        st[ i ] = v;
  1405. X        }
  1406. X    }
  1407. X
  1408. X/**************************************************/
  1409. X
  1410. Xgettr() /*process .tr */
  1411. X    {
  1412. X    if ( ro_verbose )
  1413. X        fprintf( stderr, ".tr is not currently implemented. \n" );
  1414. X    }
  1415. X
  1416. X/**************************************************/
  1417. X
  1418. Xoutstr(p)     /*print string whose bytecount is *p */
  1419. Xchar *p;
  1420. X    {
  1421. X    int i;
  1422. X    for(i=*(p++); i; i--) putchar(*(p++));
  1423. X    }
  1424. X
  1425. ________This_Is_The_END________
  1426. if test `wc -l < ro_setp.c` -ne 244; then
  1427.     echo 'shar: ro_setp.c was damaged during transit (should have been 244 bytes)'
  1428. fi
  1429. fi        ; : end of overwriting check
  1430. echo 'x - ro_outp.c'
  1431. if test -f ro_outp.c; then echo 'shar: not overwriting ro_outp.c'; else
  1432. sed 's/^X//' << '________This_Is_The_END________' > ro_outp.c
  1433. X/********************************************************/
  1434. X/*                            */
  1435. X/*    ro_outp.c    output routines for ro        */
  1436. X/*                            */
  1437. X/*    ro version 1.00                    */
  1438. X/*                            */
  1439. X/*    Portions copyright (c) 1989 by Ted A. Campbell    */
  1440. X/*        Bywater Software            */
  1441. X/*        P. O. Box 4023                */
  1442. X/*        Duke Station                */
  1443. X/*        Durham, NC  27706            */
  1444. X/*                            */
  1445. X/*    Contains portions of ROFF4, Version 1.60    */
  1446. X/*      (c) 1983, 4 by Ernest E. Bergmann               */
  1447. X/*        Physics, Building #16            */
  1448. X/*        Lehigh University            */
  1449. X/*        Bethlehem, Pa. 18015            */
  1450. X/*                            */
  1451. X/*    Contains portions of ROFF4, Version 1.61    */
  1452. X/*      (c) 1985 by Konrad Kwok                         */
  1453. X/*        20 3rd Street, Section M        */
  1454. X/*        Fariview Park,                */
  1455. X/*        Hong Kong                */
  1456. X/*                            */
  1457. X/*    ro and its predecessor ROFF4 are based on     */
  1458. X/*    the ROFF text processor described in Kernigan    */
  1459. X/*    and Plauger's now-classic text <Software Tools> */
  1460. X/*                            */
  1461. X/* Permission is hereby granted for all commercial and    */
  1462. X/* non-commercial reproduction and distribution of this */
  1463. X/* material provided this notice is included.        */
  1464. X/*                            */
  1465. X/********************************************************/
  1466. X
  1467. X#include "ro.h"
  1468. X
  1469. X/*assuming REVSCROLL is FALSE*/
  1470. X/*output ro_out2buf with the vertical height of the mainline
  1471. Xspecified by ro_vlineno,ro_vflineno[they must not be changed here].
  1472. XExcessive superscripting will be pushed down.*/
  1473. X
  1474. Xprintout()
  1475. X    {
  1476. X    int level, top, bot;       /* "up" is negative; units fractional */
  1477. X    int lsave;
  1478. X    register int n;
  1479. X
  1480. X    ro_out2buf[ ro_bpos ] = '\0';           /* terminate with '\0' */
  1481. X    lsave = ro_vlineno;
  1482. X    level = ro_plineno - ro_vlineno;
  1483. X
  1484. X    if ( !ro_oldbot )
  1485. X        {
  1486. X        level++;
  1487. X        }
  1488. X
  1489. X    excurs( &ro_out2buf[0], &top, &bot );
  1490. X
  1491. X    if ( top > level )
  1492. X        {
  1493. X        level=top;
  1494. X        }
  1495. X
  1496. X    padv();
  1497. X
  1498. X    /* output offset spaces at beginning of line */
  1499. X
  1500. X    for ( n = 0; n < ro_poval; ++n )
  1501. X        {
  1502. X        putchar( ' ' );
  1503. X        }
  1504. X
  1505. X    for ( ; level <= bot; level++ )
  1506. X        {
  1507. X        ro_ocnt = 0;
  1508. X        do
  1509. X            {
  1510. X            ro_ocnt++; 
  1511. X            flp( level, FALSE );
  1512. X            }
  1513. X        while ( retype() );
  1514. X        }
  1515. X
  1516. X    ro_out2buf[0] = ro_bpos = 0;
  1517. X    ro_oldln = ro_vlineno = lsave;
  1518. X    ro_oldbot = bot;
  1519. X    }
  1520. X
  1521. X/****************************************/
  1522. X/*moves printer vertically so that its position is specified
  1523. Xby ro_vlineno,ro_vflineno*/
  1524. X
  1525. Xpadv()
  1526. X    {
  1527. X    int w;
  1528. X
  1529. X    w = ro_vlineno - ro_plineno;
  1530. X    if ( w < 0 )
  1531. X        {
  1532. X        if (ro_verbose )
  1533. X            {
  1534. X            fprintf( stderr,"padv(): VL=%d, PL=%d\n",
  1535. X                ro_vlineno, ro_plineno);
  1536. X            }
  1537. X        ro_vlineno += w;
  1538. X        }
  1539. X    while( w-- )
  1540. X        {
  1541. X        putchar('\n');
  1542. X        ro_plineno++;
  1543. X        }
  1544. X    }
  1545. X
  1546. X/**************************************************/
  1547. X/* finds the topmost and bottommost line
  1548. Xpositions of str */
  1549. X
  1550. Xexcurs( str, t, b)
  1551. X    char *str;
  1552. X    int *t, *b;
  1553. X    {
  1554. X    int l;
  1555. X    char c;
  1556. X    *t = *b = l = 0;        /*current line position */
  1557. X    c = *str;
  1558. X    while ( c )
  1559. X        {
  1560. X        if ( c == ro_cfval[0])
  1561. X            {
  1562. X            if ( c = *(++str) )
  1563. X                {
  1564. X                switch ( c )
  1565. X                    {
  1566. X                case '+':
  1567. X                    l--; 
  1568. X                    if ( l < *t )
  1569. X                        {
  1570. X                        *t = l;
  1571. X                        }
  1572. X                    c = *( ++str );
  1573. X                    break;
  1574. X                case '-':
  1575. X                    l++; 
  1576. X                    if ( l >* b)
  1577. X                        {
  1578. X                        *b = l;
  1579. X                        }
  1580. X                    c = *( ++str );
  1581. X                    break;
  1582. X                default : 
  1583. X                    c = *( ++str );
  1584. X                    break;
  1585. X                    }
  1586. X                }
  1587. X            }
  1588. X        else c = *( ++str );
  1589. X        }
  1590. X    }
  1591. X
  1592. X/**************************************************/
  1593. X/*fancy line print at a given vertical level
  1594. Xthe string in ro_out2buf[] with backspacing,
  1595. Xunderlining, and strikout.    To permit boldface
  1596. Xit modifies ro_dbuf[], ro_dpos so that retype can be
  1597. Xused to patch up ro_out2buf for resubmittal to
  1598. Xflp()*/
  1599. X
  1600. Xflp( level, updat )
  1601. X    int level;    /* current vertical level to print*/
  1602. X    int updat;    /* boolean for update of ro_uf,ro_xf,ro_mcnt*/
  1603. X    {
  1604. X    int i;
  1605. X    ro_blkcnt=lbc(level,ro_out2buf);
  1606. X    ro_first=TRUE;
  1607. X    while((ro_blkcnt>0)||updat)
  1608. X        {
  1609. X        prpass(level,updat); 
  1610. X        putchar('\r');
  1611. X        updat=ro_first=FALSE;
  1612. X        }
  1613. X    if(ro_xcol>-1)    {
  1614. X        for(i=0;i<=ro_xcol;i++)
  1615. X            putchar(ro_xbuf[i]);
  1616. X        putchar('\r');
  1617. X        }
  1618. X    if(ro_ucol>-1)    {
  1619. X        for(i=0;i<=ro_ucol;i++)
  1620. X            putchar(ro_ubuf[i]);
  1621. X        putchar('\r');
  1622. X        }
  1623. X    if((ro_ucol>-1)||(ro_xcol>-1)) initxu();
  1624. X    }
  1625. X
  1626. X/**************************************************/
  1627. Xretype()        /*restores characters into ro_out2buf from ro_dbuf
  1628. X            that need to be overstruck again*/
  1629. X    {
  1630. X    int i;
  1631. X    if ( ro_dpos == -1 )
  1632. X        {
  1633. X        return(FALSE);
  1634. X        }
  1635. X    else
  1636. X        {
  1637. X        for(i=0;i<=ro_dpos;i++)
  1638. X            {
  1639. X            if(ro_dbuf[i])
  1640. X                {
  1641. X                ro_out2buf[i]=ro_dbuf[i];
  1642. X                ro_dbuf[i]=FALSE;
  1643. X                }
  1644. X            }
  1645. X        ro_dpos = -1;
  1646. X        return( TRUE );
  1647. X        }
  1648. X    }
  1649. X
  1650. X/**************************************************/
  1651. X/*counts printable chars in line level and
  1652. Xabove; parity must be reset*/
  1653. X
  1654. Xint lbc( lev, str ) 
  1655. X    int lev; /*=0 main line,=-1 superscripts,=+1 subscripts, etc.*/
  1656. X    char *str;
  1657. X    {
  1658. X    char c;
  1659. X    int l, n;
  1660. X    l = n = 0;
  1661. X    c = *str;
  1662. X    while ( c )
  1663. X        {
  1664. X        if(c == ro_cfval[0])
  1665. X            {
  1666. X            if ( c = *(++str) )
  1667. X                {
  1668. X                switch(c)
  1669. X                    {
  1670. X                case '+':
  1671. X                    l--;
  1672. X                    c = *(++str);
  1673. X                    break;
  1674. X                case '-':
  1675. X                    l++;
  1676. X                    c = *(++str);
  1677. X                    break;
  1678. X                default: 
  1679. X                    c = *(++str);
  1680. X                    break;
  1681. X                    }
  1682. X                }
  1683. X            }
  1684. X        else
  1685. X            {
  1686. X            if((c>' ')&&(l<=lev))
  1687. X                {
  1688. X                if(c!=ro_tcval[0])
  1689. X                    {
  1690. X                    n++;
  1691. X                    }
  1692. X                }
  1693. X            c = *( ++str );
  1694. X            }
  1695. X        }
  1696. X    return(n);
  1697. X    }
  1698. X
  1699. X/**************************************************/
  1700. X/*printer pass initial cr; no lf anywhere*/
  1701. X
  1702. Xprpass( lev, updat ) 
  1703. X    int lev; /*=0 main line,=-1 superscripts,=+1 subscripts, etc.*/
  1704. X    int updat;/*boolean to update ro_uf,ro_xf,ro_mcnt*/
  1705. X    {
  1706. X    char ch;
  1707. X    int l;
  1708. X    int xfs,ufs,mcnts;    /*save variables*/
  1709. X    int p1,p2,p3;         /*position holders*/
  1710. X    int cp2;        /*for tabulation calculation*/
  1711. X    xfs=ro_xf; 
  1712. X    ufs=ro_uf; 
  1713. X    mcnts=ro_mcnt;
  1714. X    p1=p2=p3=l=ro_bpos=ro_cp=ro_pp=0;
  1715. X    while(ch=ro_out2buf[ro_bpos])
  1716. X        {
  1717. X        switch (class(ch))
  1718. X            {
  1719. X        case     ESCAPE:
  1720. X        case    BLACK:    /*print it if posssible*/
  1721. X            if ( ( ro_pp > ro_cp ) || ( l > lev ) )    
  1722. X                {
  1723. X                ro_cp++;
  1724. X                ro_bpos++;
  1725. X                break;
  1726. X                }
  1727. X            else        {
  1728. X                while(ro_cp>ro_pp)    {
  1729. X                    putchar(' ');
  1730. X                    ro_pp++;
  1731. X                    }
  1732. X                if(ch==ro_scval[0])putchar(' ');
  1733. X                else putchar(ch);
  1734. X                ro_pp++;
  1735. X                if(ro_mcnt>ro_ocnt)
  1736. X                    {
  1737. X                    ro_dbuf[ro_bpos]=ro_out2buf[ro_bpos];
  1738. X                    if(ro_bpos>ro_dpos) ro_dpos=ro_bpos;
  1739. X                    }
  1740. X                ro_out2buf[ro_bpos++]=' ';
  1741. X                if(ro_uf&&ro_first)ro_ubuf[ro_ucol=ro_cp]=UCHAR;
  1742. X                if(ro_xf&&ro_first)ro_xbuf[ro_xcol=ro_cp]=XCHAR;
  1743. X                ro_blkcnt--; 
  1744. X                ro_cp++;
  1745. X                } 
  1746. X            break;
  1747. X        case    WHITE:/*assume blank*/
  1748. X            ro_cp++;
  1749. X            ro_bpos++;
  1750. X            break;
  1751. X        case    TRANSLATE:/*similar to BLACK and WHITE*/
  1752. X            ch=ro_out2buf[++ro_bpos];
  1753. X            if((ro_pp>ro_cp)||(l>lev)||(ch==' '))
  1754. X                {
  1755. X                ro_cp++;
  1756. X                ro_bpos++;
  1757. X                break;
  1758. X                }
  1759. X            else
  1760. X                    {
  1761. X                while(ro_cp>ro_pp)    {
  1762. X                    putchar(' ');
  1763. X                    ro_pp++;
  1764. X                    }
  1765. X                trch(ch);
  1766. X                ro_pp++;
  1767. X                if(ro_mcnt>ro_ocnt)
  1768. X                    {
  1769. X                    ro_dbuf[ro_bpos]=ro_out2buf[ro_bpos];
  1770. X                    ro_dbuf[ro_bpos-1]=ro_out2buf[ro_bpos-1];
  1771. X                    if(ro_bpos>ro_dpos) ro_dpos=ro_bpos;
  1772. X                    }
  1773. X                ro_out2buf[ro_bpos++]=' ';
  1774. X                if(ro_uf&&ro_first)ro_ubuf[ro_ucol=ro_cp]=UCHAR;
  1775. X                if(ro_xf&&ro_first)ro_xbuf[ro_xcol=ro_cp]=XCHAR;
  1776. X                ro_blkcnt--; 
  1777. X                ro_cp++;
  1778. X                } 
  1779. X            break;
  1780. X
  1781. X        case    SENTINEL: 
  1782. X            ro_out2buf[ro_bpos]=0;
  1783. X            break;
  1784. X        case    HTAB: 
  1785. X            for(cp2=0;ro_cp>=0;cp2+=ro_tabsiz[0])ro_cp-=ro_tabsiz[0];
  1786. X            ro_cp=cp2; 
  1787. X            ro_bpos++; 
  1788. X            break;
  1789. X        case    OTHERS:
  1790. X            if ( ro_verbose )
  1791. X                fprintf( stderr,"\nweird character value[octal]: %o\n",ch);
  1792. X            ro_bpos++;
  1793. X            break;
  1794. X            }
  1795. X        }
  1796. X    if(!updat)    {/*restore original values*/
  1797. X        ro_newxf=ro_xf;
  1798. X        ro_xf=xfs;
  1799. X        ro_newuf=ro_uf;
  1800. X        ro_uf=ufs;
  1801. X        ro_newmcnt=ro_mcnt;
  1802. X        ro_mcnt=mcnts;
  1803. X        }
  1804. X    }
  1805. X
  1806. X/**************************************************/
  1807. Xupdatef()    /* 3rd Mar, 85         */
  1808. X    {        /* By Conrad Kwok    */
  1809. X    ro_xf=ro_newxf;
  1810. X    ro_uf=ro_newuf;
  1811. X    ro_mcnt=ro_newmcnt;
  1812. X    }
  1813. X
  1814. X/**************************************************/
  1815. X
  1816. Xint class( c )
  1817. X    char c;
  1818. X    {
  1819. X    if ( c == ro_tcval[0] ) return(TRANSLATE);
  1820. X    if ( c == ESCAPE ) return(ESCAPE);
  1821. X    if ( c > ' ' ) return(BLACK);
  1822. X    if ( c == ' ') return(WHITE);
  1823. X    if ( c == '\n' ) return(SENTINEL);
  1824. X    if ( c == '\r' ) return(SENTINEL);
  1825. X    if ( c == TAB ) return(HTAB);
  1826. X    if (!c) return(SENTINEL);
  1827. X    return ( OTHERS );
  1828. X    }
  1829. X
  1830. X/**************************************************/
  1831. Xfraction()    /*put printer in fractional spcing mode;
  1832. X                set ro_frq*/
  1833. X    {
  1834. X    if(!ro_frq && ro_frstring && (ro_frval!=1))
  1835. X        {
  1836. X        outstr(ro_frstring);
  1837. X        ro_frq = TRUE;
  1838. X        }
  1839. X    }
  1840. X/**************************************************/
  1841. Xwhole()         /*put printer in whole line spacing;
  1842. X                reset ro_frq */
  1843. X    {
  1844. X    if(ro_frq && ro_whstring)
  1845. X        {
  1846. X        outstr(ro_whstring);
  1847. X        ro_frq = FALSE;
  1848. X        }
  1849. X    }
  1850. X/**************************************************/
  1851. Xtrch(c) /*output string translation of c*/
  1852. Xchar c;
  1853. X    {
  1854. X    char *p;
  1855. X    if(c<' ') 
  1856. X        {
  1857. X        putchar(ro_tcval[0]);
  1858. X        putchar(c);
  1859. X        return;
  1860. X        }
  1861. X    p = ro_tptr[c-' '];
  1862. X    if(p) outstr(p);
  1863. X    else        
  1864. X        {/*not initialized*/
  1865. X        putchar(ro_tcval[0]);
  1866. X        putchar('?');
  1867. X        }
  1868. X    }
  1869. X/****************************************/
  1870. Xpcont(c) /*output printer control string for c*/
  1871. Xchar c;
  1872. X    {
  1873. X    char *p;
  1874. X    if(c<' ') 
  1875. X        {
  1876. X        putchar(ro_cfval[0]);
  1877. X        putchar(c);
  1878. X        return;
  1879. X        }
  1880. X    p = ro_cptr[c-' '];
  1881. X    if(p) outstr(p);
  1882. X    else    
  1883. X        {/*not initialized*/
  1884. X        putchar(ro_cfval[0]);
  1885. X        putchar('?');
  1886. X        }
  1887. X    }
  1888. ________This_Is_The_END________
  1889. if test `wc -l < ro_outp.c` -ne 455; then
  1890.     echo 'shar: ro_outp.c was damaged during transit (should have been 455 bytes)'
  1891. fi
  1892. fi        ; : end of overwriting check
  1893. echo 'x - Makefile'
  1894. if test -f Makefile; then echo 'shar: not overwriting Makefile'; else
  1895. sed 's/^X//' << '________This_Is_The_END________' > Makefile
  1896. XCFLAGS=        -O
  1897. X
  1898. XOFILES=        ro.o ro_proc.o ro_macr.o ro_dive.o ro_outp.o ro_word.o \
  1899. X        ro_setp.o ro_text.o
  1900. X
  1901. XCFILES=        ro.c ro_proc.c ro_macr.c ro_dive.c ro_outp.c ro_word.c \
  1902. X        ro_setp.c ro_text.c
  1903. X
  1904. XHFILES=        ro.h
  1905. X
  1906. Xroff4:        $(OFILES)
  1907. X        $(CC) $(CFLAGS) $(OFILES) -o ro
  1908. X
  1909. X$(OFILES):    $(HFILES)
  1910. ________This_Is_The_END________
  1911. if test `wc -l < Makefile` -ne 14; then
  1912.     echo 'shar: Makefile was damaged during transit (should have been 14 bytes)'
  1913. fi
  1914. fi        ; : end of overwriting check
  1915. echo 'x - ro.mak'
  1916. if test -f ro.mak; then echo 'shar: not overwriting ro.mak'; else
  1917. sed 's/^X//' << '________This_Is_The_END________' > ro.mak
  1918. XPROJ    =RO
  1919. XDEBUG    =0
  1920. XCC    =qcl
  1921. XCFLAGS_G    = /AS /W1 /Za 
  1922. XCFLAGS_D    = /Zd /Zr /Gi$(PROJ).mdt /Od 
  1923. XCFLAGS_R    = /O /Ot /DNDEBUG 
  1924. XCFLAGS    =$(CFLAGS_G) $(CFLAGS_R)
  1925. XLFLAGS_G    =/NOI
  1926. XLFLAGS_D    =/INCR /CO
  1927. XLFLAGS_R    =
  1928. XLFLAGS    =$(LFLAGS_G) $(LFLAGS_R)
  1929. XRUNFLAGS    =
  1930. XOBJS_EXT =     
  1931. XLIBS_EXT =     
  1932. X
  1933. Xall:    $(PROJ).exe
  1934. X
  1935. Xro.obj:    ro.c
  1936. X
  1937. Xro_dive.obj:    ro_dive.c
  1938. X
  1939. Xro_macr.obj:    ro_macr.c
  1940. X
  1941. Xro_outp.obj:    ro_outp.c
  1942. X
  1943. Xro_proc.obj:    ro_proc.c
  1944. X
  1945. Xro_setp.obj:    ro_setp.c
  1946. X
  1947. Xro_word.obj:    ro_word.c
  1948. X
  1949. Xro_text.obj:    ro_text.c
  1950. X
  1951. X$(PROJ).exe:    ro.obj ro_dive.obj ro_macr.obj ro_outp.obj ro_proc.obj ro_setp.obj ro_word.obj \
  1952. X    ro_text.obj $(OBJS_EXT)
  1953. X    echo >NUL @<<$(PROJ).crf
  1954. Xro.obj +
  1955. Xro_dive.obj +
  1956. Xro_macr.obj +
  1957. Xro_outp.obj +
  1958. Xro_proc.obj +
  1959. Xro_setp.obj +
  1960. Xro_word.obj +
  1961. Xro_text.obj +
  1962. X$(OBJS_EXT)
  1963. X$(PROJ).exe
  1964. X
  1965. X$(LIBS_EXT);
  1966. X<<
  1967. X    link $(LFLAGS) @$(PROJ).crf
  1968. X
  1969. Xrun: $(PROJ).exe
  1970. X    $(PROJ) $(RUNFLAGS)
  1971. X
  1972. ________This_Is_The_END________
  1973. if test `wc -l < ro.mak` -ne 54; then
  1974.     echo 'shar: ro.mak was damaged during transit (should have been 54 bytes)'
  1975. fi
  1976. fi        ; : end of overwriting check
  1977. echo 'x - term.h'
  1978. if test -f term.h; then echo 'shar: not overwriting term.h'; else
  1979. sed 's/^X//' << '________This_Is_The_END________' > term.h
  1980. X#define    ESCAPE        0x1b
  1981. X
  1982. X/**    Single-character printer code designations ***/
  1983. X
  1984. X#define    ROMAN        'R'    /* Restore "roman" or "regular" font */
  1985. X                /* Should turn off Bold and Italic */
  1986. X#define    ITALIC        'I'    /* Switch to italics or underline */
  1987. X#define    BOLD        'B'    /* Switch to bold */
  1988. X#define    HALFUP        'u'    /* Half-line up */
  1989. X#define    HALFDOWN    'd'    /* Half-line down */
  1990. X
  1991. X
  1992. ________This_Is_The_END________
  1993. if test `wc -l < term.h` -ne 12; then
  1994.     echo 'shar: term.h was damaged during transit (should have been 12 bytes)'
  1995. fi
  1996. fi        ; : end of overwriting check
  1997. echo 'x - termnull.c'
  1998. if test -f termnull.c; then echo 'shar: not overwriting termnull.c'; else
  1999. sed 's/^X//' << '________This_Is_The_END________' > termnull.c
  2000. X
  2001. X#include "stdio.h"
  2002. X#include "term.h"
  2003. X
  2004. Xchar progname[] = "termnull";
  2005. X
  2006. Xmain()
  2007. X    {
  2008. X    register int c;
  2009. X
  2010. X    while( !feof( stdin ))
  2011. X        {
  2012. X        c = getchar();
  2013. X        switch( c )
  2014. X            {
  2015. X            case ESCAPE:
  2016. X                getpc();
  2017. X                break;
  2018. X            case EOF:
  2019. X                break;
  2020. X            default:
  2021. X                putchar( c );
  2022. X                break;
  2023. X            }
  2024. X        }
  2025. X    }
  2026. X
  2027. Xgetpc()
  2028. X    {
  2029. X    register int c;
  2030. X
  2031. X    c = getchar();
  2032. X    switch( c )
  2033. X        {
  2034. X        case ROMAN:
  2035. X            roman();
  2036. X            break;
  2037. X        case ITALIC:
  2038. X            italic();
  2039. X            break;
  2040. X        case BOLD:
  2041. X            bold();
  2042. X            break;
  2043. X        case HALFUP:
  2044. X            halfup();
  2045. X            break;
  2046. X        case HALFDOWN:
  2047. X            halfdown();
  2048. X            break;
  2049. X        default:
  2050. X            fprintf( stderr, "%s:  unrecognized output escape sequence ESC-0x%x \n", progname, c );
  2051. X            break;
  2052. X        }
  2053. X    }
  2054. X
  2055. Xroman()
  2056. X    {
  2057. X    }
  2058. X
  2059. Xitalic()
  2060. X    {
  2061. X    }
  2062. X
  2063. Xbold()
  2064. X    {
  2065. X    }
  2066. X
  2067. Xhalfup()
  2068. X    {
  2069. X    }
  2070. X
  2071. Xhalfdown()
  2072. X    {
  2073. X    }
  2074. X
  2075. X
  2076. ________This_Is_The_END________
  2077. if test `wc -l < termnull.c` -ne 76; then
  2078.     echo 'shar: termnull.c was damaged during transit (should have been 76 bytes)'
  2079. fi
  2080. fi        ; : end of overwriting check
  2081. echo 'x - termansi.c'
  2082. if test -f termansi.c; then echo 'shar: not overwriting termansi.c'; else
  2083. sed 's/^X//' << '________This_Is_The_END________' > termansi.c
  2084. X
  2085. X#include "stdio.h"
  2086. X#include "term.h"
  2087. X
  2088. Xchar progname[] = "termansi";
  2089. X
  2090. Xmain()
  2091. X    {
  2092. X    register int c;
  2093. X
  2094. X    while( !feof( stdin ))
  2095. X        {
  2096. X        c = getchar();
  2097. X        switch( c )
  2098. X            {
  2099. X            case ESCAPE:
  2100. X                getpc();
  2101. X                break;
  2102. X            case EOF:
  2103. X                break;
  2104. X            default:
  2105. X                putchar( c );
  2106. X                break;
  2107. X            }
  2108. X        }
  2109. X    }
  2110. X
  2111. Xgetpc()
  2112. X    {
  2113. X    register int c;
  2114. X
  2115. X    c = getchar();
  2116. X    switch( c )
  2117. X        {
  2118. X        case ROMAN:
  2119. X            roman();
  2120. X            break;
  2121. X        case ITALIC:
  2122. X            italic();
  2123. X            break;
  2124. X        case BOLD:
  2125. X            bold();
  2126. X            break;
  2127. X        case HALFUP:
  2128. X            halfup();
  2129. X            break;
  2130. X        case HALFDOWN:
  2131. X            halfdown();
  2132. X            break;
  2133. X        default:
  2134. X            fprintf( stderr, "%s:  unrecognized output escape sequence ESC-0x%x \n", progname, c );
  2135. X            break;
  2136. X        }
  2137. X    }
  2138. X
  2139. Xroman()
  2140. X    {
  2141. X    printf( "\033[0m" );
  2142. X    }
  2143. X
  2144. Xitalic()
  2145. X    {
  2146. X    printf( "\033[4m" );
  2147. X    }
  2148. X
  2149. Xbold()
  2150. X    {
  2151. X    printf( "\033[1m" );
  2152. X    }
  2153. X
  2154. Xhalfup()
  2155. X    {
  2156. X    }
  2157. X
  2158. Xhalfdown()
  2159. X    {
  2160. X    }
  2161. X
  2162. X
  2163. ________This_Is_The_END________
  2164. if test `wc -l < termansi.c` -ne 79; then
  2165.     echo 'shar: termansi.c was damaged during transit (should have been 79 bytes)'
  2166. fi
  2167. fi        ; : end of overwriting check
  2168. echo 'x - termnx10.c'
  2169. if test -f termnx10.c; then echo 'shar: not overwriting termnx10.c'; else
  2170. sed 's/^X//' << '________This_Is_The_END________' > termnx10.c
  2171. X
  2172. X#include "stdio.h"
  2173. X#include "term.h"
  2174. X
  2175. Xchar progname[] = "termnx10";
  2176. X
  2177. Xmain()
  2178. X    {
  2179. X    register int c;
  2180. X
  2181. X    while( !feof( stdin ))
  2182. X        {
  2183. X        c = getchar();
  2184. X        switch( c )
  2185. X            {
  2186. X            case ESCAPE:
  2187. X                getpc();
  2188. X                break;
  2189. X            case EOF:
  2190. X                break;
  2191. X            default:
  2192. X                putchar( c );
  2193. X                break;
  2194. X            }
  2195. X        }
  2196. X    }
  2197. X
  2198. Xgetpc()
  2199. X    {
  2200. X    register int c;
  2201. X
  2202. X    c = getchar();
  2203. X    switch( c )
  2204. X        {
  2205. X        case ROMAN:
  2206. X            roman();
  2207. X            break;
  2208. X        case ITALIC:
  2209. X            italic();
  2210. X            break;
  2211. X        case BOLD:
  2212. X            bold();
  2213. X            break;
  2214. X        case HALFUP:
  2215. X            halfup();
  2216. X            break;
  2217. X        case HALFDOWN:
  2218. X            halfdown();
  2219. X            break;
  2220. X        default:
  2221. X            fprintf( stderr, "%s:  unrecognized output escape sequence ESC-0x%x \n", progname, c );
  2222. X            break;
  2223. X        }
  2224. X    }
  2225. X
  2226. Xroman()
  2227. X    {
  2228. X    printf( "\0335\033H" );
  2229. X    }
  2230. X
  2231. Xitalic()
  2232. X    {
  2233. X    printf( "\0334" );
  2234. X    }
  2235. X
  2236. Xbold()
  2237. X    {
  2238. X    printf( "\033G" );
  2239. X    }
  2240. X
  2241. Xhalfup()
  2242. X    {
  2243. X    printf( "\033j\022" );
  2244. X    }
  2245. X
  2246. Xhalfdown()
  2247. X    {
  2248. X    printf( "\033J\022" );
  2249. X    }
  2250. X
  2251. X
  2252. ________This_Is_The_END________
  2253. if test `wc -l < termnx10.c` -ne 81; then
  2254.     echo 'shar: termnx10.c was damaged during transit (should have been 81 bytes)'
  2255. fi
  2256. fi        ; : end of overwriting check
  2257. exit 0
  2258.  
  2259.  
  2260.