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

Defined functions

name4 defined in line 173; used 7 times
roman defined in line 167; used 3 times
shim defined in line 163; used 13 times
text defined in line 15; used 5 times
trans defined in line 58; used 1 times
  • in line 42

Defined variables

cs defined in line 11; used 41 times
csp defined in line 8; used 42 times
lf defined in line 13; used 4 times
psp defined in line 9; used 11 times
rf defined in line 13; used 16 times
sccsid defined in line 2; never used

Defined macros

CSSIZE defined in line 10; used 1 times
  • in line 45
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2566
Valid CSS Valid XHTML 1.0 Strict