home *** CD-ROM | disk | FTP | other *** search
- *** fmtr.c Thu Jun 19 10:22:09 1986
- --- fmtr.new.c Thu Jun 19 10:21:12 1986
- ***************
- *** 35,41
- /* null or not */
- sarray = earray = (char *) 0;
-
- ! while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
- switch (c) {
- case 'z':
- z_flag = 1;
-
- --- 35,41 -----
- /* null or not */
- sarray = earray = (char *) 0;
-
- ! while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
- switch (c) {
- case 'b':
- b_flag = 1;
- ***************
- *** 37,42
-
- while ((c = getopt(argc, argv, "zw:s:e:")) != EOF)
- switch (c) {
- case 'z':
- z_flag = 1;
- break;
-
- --- 37,45 -----
-
- while ((c = getopt(argc, argv, "bzw:s:e:")) != EOF)
- switch (c) {
- + case 'b':
- + b_flag = 1;
- + break;
- case 'z':
- z_flag = 1;
- break;
- *** fmtr.h Thu Jun 19 10:22:16 1986
- --- fmtr.new.h Thu Jun 19 10:21:14 1986
- ***************
- *** 1,6
- #include <stdio.h>
- #include <ctype.h>
-
- int z_flag; /* look behind zero width spaces? */
- int nf_val; /* no fill on or off? */
- int ul_val; /* number of lines to underline */
-
- --- 1,7 -----
- #include <stdio.h>
- #include <ctype.h>
-
- + int b_flag; /* begin each sentence on a new line */
- int z_flag; /* look behind zero width spaces? */
-
- int nf_val; /* no fill on or off? */
- ***************
- *** 2,7
- #include <ctype.h>
-
- int z_flag; /* look behind zero width spaces? */
- int nf_val; /* no fill on or off? */
- int ul_val; /* number of lines to underline */
- int ce_val; /* number of lines to center */
-
- --- 3,9 -----
-
- int b_flag; /* begin each sentence on a new line */
- int z_flag; /* look behind zero width spaces? */
- +
- int nf_val; /* no fill on or off? */
- int ul_val; /* number of lines to underline */
- int ce_val; /* number of lines to center */
- ***************
- *** 5,10
- int nf_val; /* no fill on or off? */
- int ul_val; /* number of lines to underline */
- int ce_val; /* number of lines to center */
- int llength;
-
- char outbuf[BUFSIZ]; /* output buffer, ridiculously large */
-
- --- 7,15 -----
- int nf_val; /* no fill on or off? */
- int ul_val; /* number of lines to underline */
- int ce_val; /* number of lines to center */
- +
- + int in_display; /* are we inside a display? */
- + int in_preproc; /* are we inside preprocessor commands? */
- int llength;
-
- char outbuf[BUFSIZ]; /* output buffer, ridiculously large */
- *** fmtr.1 Thu Jun 19 10:21:57 1986
- --- fmtr.new.1 Thu Jun 19 10:21:09 1986
- ***************
- *** 1,4
- ! .TH FMTR 1H LOCAL "4th Berkeley Distribution"
- .SH NAME
- fmtr \- simple formatter for
- .I roff
-
- --- 1,4 -----
- ! .TH FMTR 1H LOCAL "Harvard"
- .SH NAME
- fmtr \- simple formatter for
- .I roff
- ***************
- *** 5,11
- source files
- .SH SYNOPSIS
- .B fmtr
- ! [ \-w
- .I width
- ] [ \-z ] [ \-s
- .I .s1.s2.s3 ... .sn
-
- --- 5,11 -----
- source files
- .SH SYNOPSIS
- .B fmtr
- ! [ \-b ] [ -z ] [ \-w
- .I width
- ] [ \-s
- .I .s1.s2.s3 ... .sn
- ***************
- *** 7,13
- .B fmtr
- [ \-w
- .I width
- ! ] [ \-z ] [ \-s
- .I .s1.s2.s3 ... .sn
- ] [ \-e
- .I .e1.e2.e3 ... .en
-
- --- 7,13 -----
- .B fmtr
- [ \-b ] [ -z ] [ \-w
- .I width
- ! ] [ \-s
- .I .s1.s2.s3 ... .sn
- ] [ \-e
- .I .e1.e2.e3 ... .en
- ***************
- *** 84,89
- .I \-z
- flag it will peek under a zero width character at the start of a line
- seeking a command.
- .I Fmtr
- knows about the
- .IR ms (7)
-
- --- 84,92 -----
- .I \-z
- flag it will peek under a zero width character at the start of a line
- seeking a command.
- + If you specify the
- + .I \-b
- + flag each sentence will begin on a new line.
- .I Fmtr
- knows about the
- .IR ms (7)
- *** lowtext.c Thu Jun 19 10:22:24 1986
- --- lowtext.new.c Thu Jun 19 10:21:18 1986
- ***************
- *** 5,10
- #include "fmtr.h"
-
- int ti_val;
-
- /* leadbl() deals with leading blanks, causes break, then sets
- * ti_val to number of blanks, unless line is blank. Then pulls
-
- --- 5,11 -----
- #include "fmtr.h"
-
- int ti_val;
- + int e_of_sen;
-
- /* leadbl() deals with leading blanks, causes break, then sets
- * ti_val to number of blanks, unless line is blank. Then pulls
- ***************
- *** 58,64
- }
-
- while (*pline != ' ' && *pline != '\0') {
- ! if (*pline == '\\' && isspace(pline[1])) /* get escaped space in word */
- *word++ = *pline++;
- *word++ = *pline++;
- }
-
- --- 59,65 -----
- }
-
- while (*pline != ' ' && *pline != '\0') {
- ! if (*pline == '\\' && isspace(pline[1])) /* get escaped space */
- *word++ = *pline++;
- *word++ = *pline++;
- }
- ***************
- *** 63,71
- *word++ = *pline++;
- }
-
- ! /* get trailing spaces, and guarantee spaces at end of line;
- ! * normally one but two at end of sentence.
- ! */
-
- if (*pline == '\0') {
- char *cptmp = pline;
-
- --- 64,70 -----
- *word++ = *pline++;
- }
-
- ! /* are we at end of sentence? */
-
- if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
- char *cptmp = pline;
- ***************
- *** 67,73
- * normally one but two at end of sentence.
- */
-
- ! if (*pline == '\0') {
- char *cptmp = pline;
-
- *word++ = ' ';
-
- --- 66,72 -----
-
- /* are we at end of sentence? */
-
- ! if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
- char *cptmp = pline;
-
- while (any(*--cptmp, "\"']})"))
- ***************
- *** 70,76
- if (*pline == '\0') {
- char *cptmp = pline;
-
- - *word++ = ' ';
- while (any(*--cptmp, "\"']})"))
- ;
- if (any(*cptmp, ".:!?"))
-
- --- 69,74 -----
- if (*pline == '\0' || (*pline == ' ' && *(pline + 1) == ' ')) {
- char *cptmp = pline;
-
- while (any(*--cptmp, "\"']})"))
- ;
- if (any(*cptmp, ".:!?"))
- ***************
- *** 74,79
- while (any(*--cptmp, "\"']})"))
- ;
- if (any(*cptmp, ".:!?"))
- *word++ = ' ';
- }
- while (*pline == ' ')
-
- --- 72,89 -----
- while (any(*--cptmp, "\"']})"))
- ;
- if (any(*cptmp, ".:!?"))
- + e_of_sen = 1;
- + else
- + e_of_sen = 0;
- + }
- +
- + /* if at end of line, add one space (two if end of sentence.
- + * otherwise get trailing spaces.
- + */
- +
- + if (*pline == '\0') {
- + *word++ = ' ';
- + if (e_of_sen)
- *word++ = ' ';
- }
-
- ***************
- *** 76,81
- if (any(*cptmp, ".:!?"))
- *word++ = ' ';
- }
- while (*pline == ' ')
- *word++ = *pline++;
- *word = '\0';
-
- --- 86,92 -----
- if (e_of_sen)
- *word++ = ' ';
- }
- +
- while (*pline == ' ')
- *word++ = *pline++;
-
- ***************
- *** 78,83
- }
- while (*pline == ' ')
- *word++ = *pline++;
- *word = '\0';
- return(pline);
- }
-
- --- 89,95 -----
-
- while (*pline == ' ')
- *word++ = *pline++;
- +
- *word = '\0';
- return(pline);
- }
- ***************
- *** 92,98
- if (s + t <= llength - ti_val) {
- for (; *word; *outp++ = *word++)
- ;
- - return;
- }
- n_brk();
- for (; *word; *outp++ = *word++)
-
- --- 104,109 -----
- if (s + t <= llength - ti_val) {
- for (; *word; *outp++ = *word++)
- ;
- }
- else {
- n_brk();
- ***************
- *** 94,102
- ;
- return;
- }
- ! n_brk();
- ! for (; *word; *outp++ = *word++)
- ! ;
- }
-
- put(line) /* output routine, separate as is more complex in original */
-
- --- 105,120 -----
- for (; *word; *outp++ = *word++)
- ;
- }
- ! else {
- ! n_brk();
- ! for (; *word; *outp++ = *word++)
- ! ;
- ! }
- !
- ! if (e_of_sen && b_flag) {
- ! n_brk();
- ! e_of_sen = 0;
- ! }
- }
-
- put(line) /* output routine, separate as is more complex in original */
- *** command.c Thu Jun 19 10:21:39 1986
- --- command.new.c Thu Jun 19 10:21:16 1986
- ***************
- *** 22,28
-
- enum cmdtype
- {
- ! CE, UL, FI, NF, OTHER
- } cmd, getcmd();
-
- int len;
-
- --- 22,39 -----
-
- enum cmdtype
- {
- ! CE, /* center */
- ! UL, /* underline */
- ! FI, /* fill mode */
- ! NF, /* no fill mode */
- ! PPS, /* start preprocessor statements */
- ! PPE, /* end preprocessor statements */
- ! PS, /* start pic statements, special case .PS < file */
- ! ME_DS, /* start display in me macros */
- ! MM_DS, /* start display in mm macros */
- ! MS_DS, /* start display in ms macros */
- ! DE, /* end display (me or mm) */
- ! OTHER
- } cmd, getcmd();
-
- int len;
- ***************
- *** 30,36
- struct cmd {
- char *name;
- enum cmdtype type;
- ! } cmd_table[50] = { "ce", CE, /* basic nroff requests */
- "ul", UL,
- "nf", NF,
- "fi", FI,
-
- --- 41,47 -----
- struct cmd {
- char *name;
- enum cmdtype type;
- ! } cmd_table[50] = { "ce", CE, /* basic nroff requests */
- "ul", UL,
- "nf", NF,
- "fi", FI,
- ***************
- *** 34,60
- "ul", UL,
- "nf", NF,
- "fi", FI,
- ! "TS", NF, /* universal macros */
- ! "TE", FI,
- ! "EQ", NF,
- ! "EN", FI,
- ! "PS", NF,
- ! "PE", FI,
- ! "IS", NF,
- ! "IE", FI,
- ! "DS", NF, /* ms macros */
- ! "ID", NF,
- ! "CD", NF,
- ! "LD", NF,
- ! "DE", FI,
- ! "(b", NF, /* me macros */
- ! ")b", FI,
- ! "(c", NF,
- ! ")c", FI,
- ! "(l", NF,
- ! ")l", FI,
- ! "(z", NF,
- ! ")z", FI,
- (char *) NULL, OTHER
- };
-
-
- --- 45,73 -----
- "ul", UL,
- "nf", NF,
- "fi", FI,
- ! "TS", PPS, /* preprocessor start and end */
- ! "TE", PPE,
- ! "EQ", PPS,
- ! "EN", PPE,
- ! "PS", PS, /* special because of .PS < file */
- ! "PE", PPE,
- ! "IS", PPS, /* ideal, if you have it! */
- ! "IE", PPE,
- ! "G1", PPS, /* grap */
- ! "G2", PPE,
- ! "DS", MM_DS, /* ms macros */
- ! "ID", MM_DS,
- ! "CD", MM_DS,
- ! "LD", MM_DS,
- ! "DE", DE,
- ! "(b", ME_DS, /* me macros of the display variety */
- ! ")b", DE,
- ! "(c", ME_DS,
- ! ")c", DE,
- ! "(l", ME_DS,
- ! ")l", DE,
- ! "(z", ME_DS,
- ! ")z", DE,
- (char *) NULL, OTHER
- };
-
- ***************
- *** 88,93
- nf_val = 1;
- break;
- case FI:
- nf_val = 0;
- break;
- }
-
- --- 101,118 -----
- nf_val = 1;
- break;
- case FI:
- + if (in_preproc == 0 && in_display == 0)
- + nf_val = 0;
- + break;
- + case ME_DS:
- + case MM_DS:
- + if (index(line, 'F') == NULL) {
- + in_display = 1;
- + nf_val = 1;
- + }
- + break;
- + case DE:
- + in_display = 0;
- nf_val = 0;
- break;
- case PPS:
- ***************
- *** 89,94
- break;
- case FI:
- nf_val = 0;
- break;
- }
-
-
- --- 114,137 -----
- case DE:
- in_display = 0;
- nf_val = 0;
- + break;
- + case PPS:
- + in_preproc = 1;
- + nf_val = 1;
- + break;
- + case PPE:
- + in_preproc = 0;
- + if (in_display == 0)
- + nf_val = 0;
- + break;
- + case PS:
- + if (index(line, '<') == NULL) { /* not .PS < file */
- + in_preproc = 1;
- + nf_val = 1;
- + }
- + break;
- + default:
- + fprintf(stderr, "program bug: got cmd = %d\n", cmd);
- break;
- }
-
-