# 2.11BSD#431 - /usr/src/usr.bin/roff/nroff/n6.c

##### Functions

    casebd            X
    casecs            X
    casefp            X
    caseft            X
    casefz            X
    caselg            X
    caseps            X
    casess            X
    casevs            X
    find              X
    getlg             X
    hmot              X
    makem             X
    mchbits           X
    mot               X
    setch             X
    setfont           X
    sethl             X
    setps             X
    setwd             X
    vmot              X
    width             X
    xlss              X

##### Variables

    fontlab           X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)n6.c	4.2 11/26/82";
       3: #endif lint
       4:
       5: #include "tdef.h"
       6: extern
       7: #include "d.h"
       8: extern
       9: #include "v.h"
      10: #ifdef NROFF
      11: extern
      12: #include "tw.h"
      13: #endif
      14:
      15: /*
      16: troff6.c
      17:
      18: width functions, sizes and fonts
      19: */
      20:
      21: extern  int     inchar[LNSIZE], *pinchar;       /* XXX */
      22: extern int eschar;
      23: extern int widthp;
      24: extern int ohc;
      25: extern int xfont;
      26: extern int smnt;
      27: extern int setwdf;
      28: extern char trtab[];
      29: extern int chbits;
      30: extern int nonumb;
      31: extern int noscale;
      32: extern int font;
      33: extern int font1;
      34: extern int pts;
      35: extern int sps;
      36: extern int nlflg;
      37: extern int nform;
      38: extern int dfact;
      39: extern int dfactd;
      40: extern int lss;
      41: extern int lss1;
      42: extern int vflag;
      43: extern int ch0;
      44: extern int level;
      45: extern int ch;
      46: extern int res;
      47: extern int xxx;
      48: int fontlab[] = {'R','I','B','S',0};
      49:
      50: width(c)
      51: int c;
      52: {
      53:     register i,j,k;
      54:
      55:     j = c;
      56:     k = 0;
      57:     if(j & MOT){
      58:         if(j & VMOT)goto rtn;
      59:         k = j & ~MOTV;
      60:         if(j & NMOT)k = -k;
      61:         goto rtn;
      62:     }
      63:     if((i = (j & CMASK)) == 010){
      64:         k = -widthp;
      65:         goto rtn;
      66:     }
      67:     if(i == PRESC)i = eschar;
      68:     if((i == ohc) ||
      69:        (i >= 0370))goto rtn;
      70:     if(j & ZBIT)goto rtn;
      71:     i = trtab[i] & BMASK;
      72:     if(i < 040)goto rtn;
      73:     if (t.codetab[i-32])
      74:         k = (*(t.codetab[i-32]) & 0177) * t.Char;
      75:     else
      76:         k = 0;
      77:     widthp = k;
      78: rtn:
      79:     return(k);
      80: }
      81: setch(){
      82:     register i,*j,k;
      83:     extern int chtab[];
      84:
      85:     if((i = getrq()) == 0)return(0);
      86:     for(j=chtab;*j != i;j++)if(*(j++) == 0)return(0);
      87:     k = *(++j) | chbits;
      88:     return(k);
      89: }
      90: find(i,j)
      91: int i,j[];
      92: {
      93:     register k;
      94:
      95:     if(((k = i-'0') >= 1) && (k <= 4) && (k != smnt))return(--k);
      96:     for(k=0; j[k] != i; k++)if(j[k] == 0)return(-1);
      97:     return(k);
      98: }
      99: mchbits(){
     100:     chbits = (((pts)<<2) | font) << (BYTE + 1);
     101:     sps = width(' ' | chbits);
     102: }
     103: setps(){
     104:     register i,j;
     105:
     106:     if((((i=getch() & CMASK) == '+')  || (i == '-')) &&
     107:       (((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9))){
     108:         ch = 0;
     109:         return;
     110:     }
     111:     if((i -= '0') == 0){
     112:         return;
     113:     }
     114:     if((i > 0) && (i <= 9)){
     115:         if((i <= 3) &&
     116:           ((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9)){
     117:             i = 10*i +j;
     118:             ch = 0;
     119:         }
     120:     }
     121: }
     122: caseft(){
     123:     skip();
     124:     setfont(1);
     125: }
     126: setfont(a)
     127: int a;
     128: {
     129:     register i,j;
     130:
     131:     if(a)i = getrq();
     132:         else i = getsn();
     133:     if(!i || (i == 'P')){
     134:         j = font1;
     135:         goto s0;
     136:     }
     137:     if(i == 'S')return;
     138:     if((j = find(i,fontlab))  == -1)return;
     139: s0:
     140:     font1 = font;
     141:     font = j;
     142:     mchbits();
     143: }
     144: setwd(){
     145:     register i, base, wid;
     146:     int delim, em, k;
     147:     int savlevel, savhp, savfont, savfont1;
     148:     int *savpinchar, *p, *q, tempinchar[LNSIZE];    /* XXX */
     149:
     150:     base = v.st = v.sb = wid = v.ct = 0;
     151:     if((delim = getch() & CMASK) & MOT)return;
     152:     savhp = v.hp;
     153:     savpinchar = pinchar;   /* XXX */
     154:     for (p=inchar, q=tempinchar; p < pinchar; ) /* XXX */
     155:         *q++ = *p++;    /* XXX */
     156:     pinchar = inchar;   /* XXX */
     157:     savlevel = level;
     158:     v.hp = level = 0;
     159:     savfont = font;
     160:     savfont1 = font1;
     161:     setwdf++;
     162:     while((((i = getch()) & CMASK) != delim) && !nlflg){
     163:         wid += width(i);
     164:         if(!(i & MOT)){
     165:             em = 2*t.Halfline;
     166:         }else if(i & VMOT){
     167:             k = i & ~MOTV;
     168:             if(i & NMOT)k = -k;
     169:             base -= k;
     170:             em = 0;
     171:         }else continue;
     172:         if(base < v.sb)v.sb = base;
     173:         if((k=base + em) > v.st)v.st = k;
     174:     }
     175:     nform = 0;
     176:     setn1(wid);
     177:     v.hp = savhp;
     178:     pinchar = savpinchar;   /* XXX */
     179:     for (p=inchar, q=tempinchar; p < pinchar; ) /* XXX */
     180:         *p++ = *q++;    /* XXX */
     181:     level = savlevel;
     182:     font = savfont;
     183:     font1 = savfont1;
     184:     mchbits();
     185:     setwdf = 0;
     186: }
     187: vmot(){
     188:     dfact = lss;
     189:     vflag++;
     190:     return(mot());
     191: }
     192: hmot(){
     193:     dfact = EM;
     194:     return(mot());
     195: }
     196: mot(){
     197:     register i, j;
     198:
     199:     j = HOR;
     200:     getch(); /*eat delim*/
     201:     if(i = atoi()){
     202:         if(vflag)j = VERT;
     203:         i = makem(quant(i,j));
     204:     }
     205:     getch();
     206:     vflag = 0;
     207:     dfact = 1;
     208:     return(i);
     209: }
     210: sethl(k)
     211: int k;
     212: {
     213:     register i;
     214:
     215:     i = t.Halfline;
     216:     if(k == 'u')i = -i;
     217:     else if(k == 'r')i = -2*i;
     218:     vflag++;
     219:     i = makem(i);
     220:     vflag = 0;
     221:     return(i);
     222: }
     223: makem(i)
     224: int i;
     225: {
     226:     register j;
     227:
     228:     if((j = i) < 0)j = -j;
     229:     j = (j & ~MOTV) | MOT;
     230:     if(i < 0)j |= NMOT;
     231:     if(vflag)j |= VMOT;
     232:     return(j);
     233: }
     234: casefp(){
     235:     register i, j;
     236:
     237:     skip();
     238:     if(((i = (getch() & CMASK) - '0' -1) < 0) || (i >3))return;
     239:     if(skip() || !(j = getrq()))return;
     240:     fontlab[i] = j;
     241: }
     242: casevs(){
     243:     register i;
     244:
     245:     skip();
     246:     vflag++;
     247:     dfact = INCH; /*default scaling is points!*/
     248:     dfactd = 72;
     249:     res = VERT;
     250:     i = inumb(&lss);
     251:     if(nonumb)i = lss1;
     252:     if(i < VERT)i = VERT;
     253:     lss1 = lss;
     254:     lss = i;
     255: }
     256: xlss(){
     257:     register i, j;
     258:
     259:     getch();
     260:     dfact = lss;
     261:     i = quant(atoi(),VERT);
     262:     dfact = 1;
     263:     getch();
     264:     if((j = i) < 0)j = -j;
     265:     ch0 = ((j & 03700)<<3) | HX;
     266:     if(i < 0)ch0 |= 040000;
     267:     return(((j & 077)<<9) | LX);
     268: }
     269: casefz(){}
     270: caseps(){}
     271: caselg(){}
     272: casecs(){}
     273: casebd(){}
     274: casess(){}
     275: getlg(i)
     276: int i;
     277: {
     278:     return(i);
     279: }

#### Defined functions

casebd defined in line 273; never used
casecs defined in line 272; never used
casefp defined in line 234; never used
caseft defined in line 122; never used
casefz defined in line 269; never used
caselg defined in line 271; never used
caseps defined in line 270; never used
casess defined in line 274; never used
casevs defined in line 242; never used
find defined in line 90; used 1 times

- in line 138

getlg defined in line 275; never used
hmot defined in line 192; never used
makem defined in line 223; used 2 times

- in line 203, 219

mchbits defined in line 99; used 2 times

- in line 142, 184

mot defined in line 196; used 2 times

- in line 190-194(2)

setch defined in line 81; never used
setfont defined in line 126; used 1 times

- in line 124

sethl defined in line 210; never used
setps defined in line 103; never used
setwd defined in line 144; never used
vmot defined in line 187; never used
width defined in line 50; used 2 times

- in line 101, 163

xlss defined in line 256; never used

#### Defined variables

fontlab defined in line 48; used 2 times

- in line 138, 240

sccsid defined in line 2; never used

Last modified: 1983-04-09 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1620 |