home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / fmtr.patch / diffs next >
Encoding:
Text File  |  1986-11-30  |  10.7 KB  |  535 lines

  1. *** fmtr.c    Thu Jun 19 10:22:09 1986
  2. --- fmtr.new.c    Thu Jun 19 10:21:12 1986
  3. ***************
  4. *** 35,41
  5.                   /* null or not */
  6.       sarray = earray = (char *) 0;
  7.   
  8. !     while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
  9.       switch (c) {
  10.           case 'z':
  11.           z_flag = 1;
  12.  
  13. --- 35,41 -----
  14.                   /* null or not */
  15.       sarray = earray = (char *) 0;
  16.   
  17. !     while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
  18.       switch (c) {
  19.           case 'b':
  20.           b_flag = 1;
  21. ***************
  22. *** 37,42
  23.   
  24.       while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
  25.       switch (c) {
  26.           case 'z':
  27.           z_flag = 1;
  28.           break;
  29.  
  30. --- 37,45 -----
  31.   
  32.       while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
  33.       switch (c) {
  34. +         case 'b':
  35. +         b_flag = 1;
  36. +         break;
  37.           case 'z':
  38.           z_flag = 1;
  39.           break;
  40. *** fmtr.h    Thu Jun 19 10:22:16 1986
  41. --- fmtr.new.h    Thu Jun 19 10:21:14 1986
  42. ***************
  43. *** 1,6
  44.   #include <stdio.h>
  45.   #include <ctype.h>
  46.   
  47.   int z_flag;        /* look behind zero width spaces? */
  48.   int nf_val;        /* no fill on or off? */
  49.   int ul_val;        /* number of lines to underline */
  50.  
  51. --- 1,7 -----
  52.   #include <stdio.h>
  53.   #include <ctype.h>
  54.   
  55. + int b_flag;        /* begin each sentence on a new line */
  56.   int z_flag;        /* look behind zero width spaces? */
  57.   
  58.   int nf_val;        /* no fill on or off? */
  59. ***************
  60. *** 2,7
  61.   #include <ctype.h>
  62.   
  63.   int z_flag;        /* look behind zero width spaces? */
  64.   int nf_val;        /* no fill on or off? */
  65.   int ul_val;        /* number of lines to underline */
  66.   int ce_val;        /* number of lines to center */
  67.  
  68. --- 3,9 -----
  69.   
  70.   int b_flag;        /* begin each sentence on a new line */
  71.   int z_flag;        /* look behind zero width spaces? */
  72.   int nf_val;        /* no fill on or off? */
  73.   int ul_val;        /* number of lines to underline */
  74.   int ce_val;        /* number of lines to center */
  75. ***************
  76. *** 5,10
  77.   int nf_val;        /* no fill on or off? */
  78.   int ul_val;        /* number of lines to underline */
  79.   int ce_val;        /* number of lines to center */
  80.   int llength;
  81.   
  82.   char outbuf[BUFSIZ];    /* output buffer, ridiculously large */
  83.  
  84. --- 7,15 -----
  85.   int nf_val;        /* no fill on or off? */
  86.   int ul_val;        /* number of lines to underline */
  87.   int ce_val;        /* number of lines to center */
  88. + int in_display;        /* are we inside a display? */
  89. + int in_preproc;        /* are we inside preprocessor commands? */
  90.   int llength;
  91.   
  92.   char outbuf[BUFSIZ];    /* output buffer, ridiculously large */
  93. *** fmtr.1    Thu Jun 19 10:21:57 1986
  94. --- fmtr.new.1    Thu Jun 19 10:21:09 1986
  95. ***************
  96. *** 1,4
  97. ! .TH FMTR 1H LOCAL "4th Berkeley Distribution"
  98.   .SH NAME
  99.   fmtr \- simple formatter for
  100.   .I roff
  101.  
  102. --- 1,4 -----
  103. ! .TH FMTR 1H LOCAL "Harvard"
  104.   .SH NAME
  105.   fmtr \- simple formatter for
  106.   .I roff
  107. ***************
  108. *** 5,11
  109.   source files
  110.   .SH SYNOPSIS
  111.   .B fmtr
  112. ! [ \-w
  113.   .I width
  114.   ] [ \-z ] [ \-s
  115.   .I .s1.s2.s3 ... .sn
  116.  
  117. --- 5,11 -----
  118.   source files
  119.   .SH SYNOPSIS
  120.   .B fmtr
  121. ! [ \-b ] [ -z ] [ \-w
  122.   .I width
  123.   ] [ \-s
  124.   .I .s1.s2.s3 ... .sn
  125. ***************
  126. *** 7,13
  127.   .B fmtr
  128.   [ \-w
  129.   .I width
  130. ! ] [ \-z ] [ \-s
  131.   .I .s1.s2.s3 ... .sn
  132.   ] [ \-e
  133.   .I .e1.e2.e3 ... .en
  134.  
  135. --- 7,13 -----
  136.   .B fmtr
  137.   [ \-b ] [ -z ] [ \-w
  138.   .I width
  139. ! ] [ \-s
  140.   .I .s1.s2.s3 ... .sn
  141.   ] [ \-e
  142.   .I .e1.e2.e3 ... .en
  143. ***************
  144. *** 84,89
  145.   .I \-z
  146.   flag it will peek under a zero width character at the start of a line
  147.   seeking a command.
  148.   .I Fmtr
  149.   knows about the
  150.   .IR ms (7)
  151.  
  152. --- 84,92 -----
  153.   .I \-z
  154.   flag it will peek under a zero width character at the start of a line
  155.   seeking a command.
  156. + If you specify the
  157. + .I \-b
  158. + flag each sentence will begin on a new line.
  159.   .I Fmtr
  160.   knows about the
  161.   .IR ms (7)
  162. *** lowtext.c    Thu Jun 19 10:22:24 1986
  163. --- lowtext.new.c    Thu Jun 19 10:21:18 1986
  164. ***************
  165. *** 5,10
  166.   #include "fmtr.h"
  167.   
  168.   int ti_val;
  169.   
  170.   /*  leadbl() deals with leading blanks, causes break, then sets
  171.    *  ti_val to number of blanks, unless line is blank.  Then pulls
  172.  
  173. --- 5,11 -----
  174.   #include "fmtr.h"
  175.   
  176.   int ti_val;
  177. + int e_of_sen;
  178.   
  179.   /*  leadbl() deals with leading blanks, causes break, then sets
  180.    *  ti_val to number of blanks, unless line is blank.  Then pulls
  181. ***************
  182. *** 58,64
  183.       }
  184.   
  185.       while (*pline != ' ' && *pline != '\0') {
  186. !     if (*pline == '\\' && isspace(pline[1])) /* get escaped space in word */
  187.           *word++ = *pline++;
  188.           *word++ = *pline++;
  189.       }
  190.  
  191. --- 59,65 -----
  192.       }
  193.   
  194.       while (*pline != ' ' && *pline != '\0') {
  195. !     if (*pline == '\\' && isspace(pline[1])) /* get escaped space */
  196.           *word++ = *pline++;
  197.           *word++ = *pline++;
  198.       }
  199. ***************
  200. *** 63,71
  201.           *word++ = *pline++;
  202.       }
  203.   
  204. !     /*  get trailing spaces, and guarantee spaces at end of line;
  205. !      *  normally one but two at end of sentence.
  206. !      */
  207.   
  208.       if (*pline == '\0') {
  209.       char *cptmp = pline;
  210.  
  211. --- 64,70 -----
  212.           *word++ = *pline++;
  213.       }
  214.   
  215. !     /* are we at end of sentence? */
  216.   
  217.       if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  218.       char *cptmp = pline;
  219. ***************
  220. *** 67,73
  221.        *  normally one but two at end of sentence.
  222.        */
  223.   
  224. !     if (*pline == '\0') {
  225.       char *cptmp = pline;
  226.   
  227.       *word++ = ' ';
  228.  
  229. --- 66,72 -----
  230.   
  231.       /* are we at end of sentence? */
  232.   
  233. !     if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  234.       char *cptmp = pline;
  235.   
  236.       while (any(*--cptmp, "\"']})"))
  237. ***************
  238. *** 70,76
  239.       if (*pline == '\0') {
  240.       char *cptmp = pline;
  241.   
  242. -     *word++ = ' ';
  243.       while (any(*--cptmp, "\"']})"))
  244.           ;
  245.       if (any(*cptmp, ".:!?"))
  246.  
  247. --- 69,74 -----
  248.       if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
  249.       char *cptmp = pline;
  250.   
  251.       while (any(*--cptmp, "\"']})"))
  252.           ;
  253.       if (any(*cptmp, ".:!?"))
  254. ***************
  255. *** 74,79
  256.       while (any(*--cptmp, "\"']})"))
  257.           ;
  258.       if (any(*cptmp, ".:!?"))
  259.           *word++ = ' ';
  260.       }
  261.       while (*pline == ' ')
  262.  
  263. --- 72,89 -----
  264.       while (any(*--cptmp, "\"']})"))
  265.           ;
  266.       if (any(*cptmp, ".:!?"))
  267. +         e_of_sen = 1;
  268. +     else
  269. +         e_of_sen = 0;
  270. +     }
  271. +     /*  if at end of line, add one space (two if end of sentence.
  272. +      *  otherwise  get trailing spaces.
  273. +      */
  274. +     if (*pline == '\0') {
  275. +     *word++ = ' ';
  276. +     if (e_of_sen)
  277.           *word++ = ' ';
  278.       }
  279.   
  280. ***************
  281. *** 76,81
  282.       if (any(*cptmp, ".:!?"))
  283.           *word++ = ' ';
  284.       }
  285.       while (*pline == ' ')
  286.       *word++ = *pline++;
  287.       *word = '\0';
  288.  
  289. --- 86,92 -----
  290.       if (e_of_sen)
  291.           *word++ = ' ';
  292.       }
  293.       while (*pline == ' ')
  294.       *word++ = *pline++;
  295.   
  296. ***************
  297. *** 78,83
  298.       }
  299.       while (*pline == ' ')
  300.       *word++ = *pline++;
  301.       *word = '\0';
  302.       return(pline);
  303.   }
  304.  
  305. --- 89,95 -----
  306.   
  307.       while (*pline == ' ')
  308.       *word++ = *pline++;
  309.       *word = '\0';
  310.       return(pline);
  311.   }
  312. ***************
  313. *** 92,98
  314.       if (s + t <= llength - ti_val) {
  315.       for (; *word; *outp++ = *word++)
  316.           ;
  317. -     return;
  318.       }
  319.       n_brk();
  320.       for (; *word; *outp++ = *word++)
  321.  
  322. --- 104,109 -----
  323.       if (s + t <= llength - ti_val) {
  324.       for (; *word; *outp++ = *word++)
  325.           ;
  326.       }
  327.       else {
  328.       n_brk();
  329. ***************
  330. *** 94,102
  331.           ;
  332.       return;
  333.       }
  334. !     n_brk();
  335. !     for (; *word; *outp++ = *word++)
  336. !     ;
  337.   }
  338.   
  339.   put(line)    /* output routine, separate as is more complex in original */
  340.  
  341. --- 105,120 -----
  342.       for (; *word; *outp++ = *word++)
  343.           ;
  344.       }
  345. !     else {
  346. !     n_brk();
  347. !     for (; *word; *outp++ = *word++)
  348. !         ;
  349. !     }
  350. !     if (e_of_sen && b_flag) {
  351. !     n_brk();
  352. !     e_of_sen = 0;
  353. !     }
  354.   }
  355.   
  356.   put(line)    /* output routine, separate as is more complex in original */
  357. *** command.c    Thu Jun 19 10:21:39 1986
  358. --- command.new.c    Thu Jun 19 10:21:16 1986
  359. ***************
  360. *** 22,28
  361.   
  362.   enum cmdtype
  363.       {
  364. !     CE, UL, FI, NF, OTHER
  365.       } cmd, getcmd();
  366.   
  367.   int len;
  368.  
  369. --- 22,39 -----
  370.   
  371.   enum cmdtype
  372.       {
  373. !     CE,        /* center */
  374. !     UL,        /* underline */
  375. !     FI,        /* fill mode */
  376. !     NF,        /* no fill mode */
  377. !     PPS,        /* start preprocessor statements */
  378. !     PPE,        /* end preprocessor statements */
  379. !     PS,        /* start pic statements, special case .PS < file */
  380. !     ME_DS,        /* start display in me macros */
  381. !     MM_DS,        /* start display in mm macros */
  382. !     MS_DS,        /* start display in ms macros */
  383. !     DE,        /* end display (me or mm) */
  384. !     OTHER
  385.       } cmd, getcmd();
  386.   
  387.   int len;
  388. ***************
  389. *** 30,36
  390.   struct cmd {
  391.       char *name;
  392.       enum cmdtype type;
  393. ! } cmd_table[50] = { "ce", CE,    /* basic nroff requests */
  394.               "ul", UL,
  395.               "nf", NF,
  396.               "fi", FI,
  397.  
  398. --- 41,47 -----
  399.   struct cmd {
  400.       char *name;
  401.       enum cmdtype type;
  402. ! } cmd_table[50] = { "ce", CE,        /* basic nroff requests */
  403.               "ul", UL,
  404.               "nf", NF,
  405.               "fi", FI,
  406. ***************
  407. *** 34,60
  408.               "ul", UL,
  409.               "nf", NF,
  410.               "fi", FI,
  411. !             "TS", NF,    /* universal macros */
  412. !             "TE", FI,
  413. !             "EQ", NF,
  414. !             "EN", FI,
  415. !             "PS", NF,
  416. !             "PE", FI,
  417. !             "IS", NF,
  418. !             "IE", FI,
  419. !             "DS", NF,    /* ms macros */
  420. !             "ID", NF,
  421. !             "CD", NF,
  422. !             "LD", NF,
  423. !             "DE", FI,
  424. !             "(b", NF,    /* me macros */
  425. !             ")b", FI,
  426. !             "(c", NF,
  427. !             ")c", FI,
  428. !             "(l", NF,
  429. !             ")l", FI,
  430. !             "(z", NF,
  431. !             ")z", FI,
  432.               (char *) NULL, OTHER
  433.           };
  434.   
  435.  
  436. --- 45,73 -----
  437.               "ul", UL,
  438.               "nf", NF,
  439.               "fi", FI,
  440. !             "TS", PPS,        /* preprocessor start and end */
  441. !             "TE", PPE,
  442. !             "EQ", PPS,
  443. !             "EN", PPE,
  444. !             "PS", PS,        /* special because of .PS < file */
  445. !             "PE", PPE,
  446. !             "IS", PPS,        /* ideal, if you have it! */
  447. !             "IE", PPE,
  448. !             "G1", PPS,        /* grap */
  449. !             "G2", PPE,
  450. !             "DS", MM_DS,    /* ms macros */
  451. !             "ID", MM_DS,
  452. !             "CD", MM_DS,
  453. !             "LD", MM_DS,
  454. !             "DE", DE,
  455. !             "(b", ME_DS,    /* me macros of the display variety */
  456. !             ")b", DE,
  457. !             "(c", ME_DS,
  458. !             ")c", DE,
  459. !             "(l", ME_DS,
  460. !             ")l", DE,
  461. !             "(z", ME_DS,
  462. !             ")z", DE,
  463.               (char *) NULL, OTHER
  464.           };
  465.   
  466. ***************
  467. *** 88,93
  468.           nf_val = 1;
  469.           break;
  470.       case FI:
  471.           nf_val = 0;
  472.           break;
  473.       }
  474.  
  475. --- 101,118 -----
  476.           nf_val = 1;
  477.           break;
  478.       case FI:
  479. +         if (in_preproc == 0 && in_display == 0)
  480. +         nf_val = 0;
  481. +         break;
  482. +     case ME_DS:
  483. +     case MM_DS:
  484. +         if (index(line, 'F') == NULL) {
  485. +         in_display = 1;
  486. +         nf_val = 1;
  487. +         }
  488. +         break;
  489. +     case DE:
  490. +         in_display = 0;
  491.           nf_val = 0;
  492.           break;
  493.       case PPS:
  494. ***************
  495. *** 89,94
  496.           break;
  497.       case FI:
  498.           nf_val = 0;
  499.           break;
  500.       }
  501.   
  502.  
  503. --- 114,137 -----
  504.       case DE:
  505.           in_display = 0;
  506.           nf_val = 0;
  507. +         break;
  508. +     case PPS:
  509. +         in_preproc = 1;
  510. +         nf_val = 1;
  511. +         break;
  512. +     case PPE:
  513. +         in_preproc = 0;
  514. +         if (in_display == 0)
  515. +         nf_val = 0;
  516. +         break;
  517. +     case PS:
  518. +         if (index(line, '<') == NULL) {    /* not .PS < file */
  519. +         in_preproc = 1;
  520. +         nf_val = 1;
  521. +         }
  522. +         break;
  523. +     default:
  524. +         fprintf(stderr, "program bug: got cmd = %d\n", cmd);
  525.           break;
  526.       }
  527.   
  528.