1: # include "e.h"
   2: # include "e.def"
   3: 
   4: int csp;
   5: int psp;
   6: #define CSSIZE  400
   7: char    cs[420];
   8: 
   9: int lf, rf; /* temporary spots for left and right fonts */
  10: 
  11: text(t,p1) int t; char *p1; {
  12:     int c;
  13:     char *p;
  14:     tbl *tp, *lookup();
  15:     extern tbl *restbl;
  16: 
  17:     yyval = oalloc();
  18:     ebase[yyval] = 0;
  19:     eht[yyval] = VERT(2);   /* 2 half-spaces */
  20:     lfont[yyval] = rfont[yyval] = ROM;
  21:     if (t == QTEXT)
  22:         p = p1;
  23:     else if ( t == SPACE )
  24:         p = "\\ ";
  25:     else if ( t == THIN )
  26:         p = "\\|";
  27:     else if ( t == TAB )
  28:         p = "\\t";
  29:     else if ((tp = lookup(&restbl, p1, NULL)) != NULL)
  30:         p = tp->defn;
  31:     else {
  32:         lf = rf = 0;
  33:         for (csp=psp=0; (c=p1[psp++])!='\0';) {
  34:             rf = trans(c, p1);
  35:             if (lf == 0)
  36:                 lf = rf;    /* save first */
  37:             if (csp>CSSIZE)
  38:                 error(FATAL,"converted token %.25s... too long",p1);
  39:         }
  40:         cs[csp] = '\0';
  41:         p = cs;
  42:         lfont[yyval] = lf;
  43:         rfont[yyval] = rf;
  44:     }
  45:     if(dbg)printf(".\t%dtext: S%d <- %s; b=%d,h=%d,lf=%c,rf=%c\n",
  46:         t, yyval, p, ebase[yyval], eht[yyval], lfont[yyval], rfont[yyval]);
  47:     printf(".ds %d \"%s\n", yyval, p);
  48: }
  49: 
  50: trans(c,p1) int c; char *p1; {
  51:     int f;
  52:     f = ROM;
  53:     switch( c) {
  54:     case '0': case '1': case '2': case '3': case '4':
  55:     case '5': case '6': case '7': case '8': case '9':
  56:     case ':': case ';': case '!': case '%':
  57:     case '(': case '[': case ')': case ']':
  58:     case ',':
  59:         if (rf == ITAL)
  60:             shim();
  61:         roman(c); break;
  62:     case '.':
  63:         if (rf == ROM)
  64:             roman(c);
  65:         else
  66:             cs[csp++] = c;
  67:         f = rf;
  68:         break;
  69:     case '|':
  70:         if (rf == ITAL)
  71:             shim();
  72:         shim(); roman(c); shim(); break;
  73:     case '=':
  74:         if (rf == ITAL)
  75:             shim();
  76:         name4('e','q');
  77:         break;
  78:     case '+':
  79:         if (rf == ITAL)
  80:             shim();
  81:         name4('p', 'l');
  82:         break;
  83:     case '>': case '<':
  84:         if (rf == ITAL)
  85:             shim();
  86:         if (p1[psp]=='=') { /* look ahead for == <= >= */
  87:             name4(c,'=');
  88:             psp++;
  89:         } else {
  90:             cs[csp++] = c;
  91:         }
  92:         break;
  93:     case '-':
  94:         if (rf == ITAL)
  95:             shim();
  96:         if (p1[psp]=='>') {
  97:             name4('-','>'); psp++;
  98:         } else {
  99:             name4('m','i');
 100:         }
 101:         break;
 102:     case '/':
 103:         if (rf == ITAL)
 104:             shim();
 105:         name4('s','l');
 106:         break;
 107:     case '~': case ' ':
 108:         shim(); shim(); break;
 109:     case '^':
 110:         shim(); break;
 111:     case '\\':  /* troff - pass 2 or 3 more chars */
 112:         if (rf == ITAL)
 113:             shim();
 114:         cs[csp++] = c; cs[csp++] = c = p1[psp++]; cs[csp++] = p1[psp++];
 115:         if (c=='(') cs[csp++] = p1[psp++];
 116:         if (c=='*' && cs[csp-1] == '(') {
 117:             cs[csp++] = p1[psp++];
 118:             cs[csp++] = p1[psp++];
 119:         }
 120:         break;
 121:     case '\'':
 122:         cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = rf==ITAL ? ITAL : ROM;
 123:         name4('f','m');
 124:         cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = 'P';
 125:         f = rf==ITAL ? ITAL : ROM;
 126:         break;
 127: 
 128:     case 'f':
 129:         if (ft == ITAL) {
 130:             cs[csp++] = '\\'; cs[csp++] = '^';
 131:             cs[csp++] = 'f';
 132:             cs[csp++] = '\\'; cs[csp++] = '|';  /* trying | instead of ^ */
 133:             f = ITAL;
 134:         }
 135:         else
 136:             cs[csp++] = 'f';
 137:         break;
 138:     case 'j':
 139:         if (ft == ITAL) {
 140:             cs[csp++] = '\\'; cs[csp++] = '^';
 141:             cs[csp++] = 'j';
 142:             f = ITAL;
 143:         }
 144:         else
 145:             cs[csp++] = 'j';
 146:         break;
 147:     default:
 148:         cs[csp++] = c;
 149:         f = ft==ITAL ? ITAL : ROM;
 150:         break;
 151:     }
 152:     return(f);
 153: }
 154: 
 155: shim() {
 156:     cs[csp++] = '\\'; cs[csp++] = '|';
 157: }
 158: 
 159: roman(c) int c; {
 160:     cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = ROM;
 161:     cs[csp++] = c;
 162:     cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = 'P';
 163: }
 164: 
 165: name4(c1,c2) int c1,c2; {
 166:     cs[csp++] = '\\';
 167:     cs[csp++] = '(';
 168:     cs[csp++] = c1;
 169:     cs[csp++] = c2;
 170: }

Defined functions

name4 defined in line 165; used 7 times
roman defined in line 159; used 3 times
shim defined in line 155; used 13 times
text defined in line 11; used 10 times
trans defined in line 50; used 1 times
  • in line 34

Defined variables

cs defined in line 7; used 41 times
csp defined in line 4; used 42 times
lf defined in line 9; used 4 times
psp defined in line 5; used 11 times
rf defined in line 9; used 16 times

Defined macros

CSSIZE defined in line 6; used 1 times
  • in line 37
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 916
Valid CSS Valid XHTML 1.0 Strict