# 2.11BSD#431 - /usr/src/usr.bin/ratfor/r2.c

##### Functions

    contcard          X
    flushcom          X
    outcode           X
    outcont           X
    outdon            X
    outgoto           X
    outnum            X
    outtab            X
    ptc               X
    pts               X
    putcom            X

##### Variables

    comment           X
    comptr            X
    cont              X
    contchar          X
    indent            X
    outbuf            X
    outp              X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)r2.c	1.2 (Berkeley) 8/11/83";
       3: #endif
       4:
       5: #include "r.h"
       6:
       7: extern int hollerith;
       8:
       9: char    outbuf[80];
      10: int outp    = 0;
      11: int cont    = 0;
      12: int contchar    = '&';
      13:
      14: char    comment[320];
      15: int comptr  = 0;
      16: int indent  = 0;
      17:
      18: outdon() {
      19:     outbuf[outp] = '\0';
      20:     if (outp > 0)
      21:         fprintf(outfil, "%s\n", outbuf);
      22:     outp = cont = 0;
      23: }
      24:
      25: putcom(s) char *s; {
      26:     if (printcom) {
      27:         ptc('c');
      28:         outtab();
      29:         pts(s);
      30:         outdon();
      31:     }
      32: }
      33:
      34: outcode(xp) char *xp; {
      35:     register c, c1, j;
      36:     char *q, *p;
      37:
      38:     p = (char *) xp;    /* shut lint up */
      39:     if (cont == 0 && comptr > 0)    /* flush comment if not on continuation */
      40:         flushcom();
      41:     while( (c = *p++) ){
      42:         c1 = *p;
      43:         if (type[c] == LET || type[c] == DIG) {
      44:             pts(p-1);
      45:             break;
      46:         }
      47:         switch(c){
      48:
      49:         case '"': case '\'':
      50:             j = 0;
      51:             for (q=p; *q; q++) {
      52:                 if (*q == '\\')
      53:                     q++;
      54:                 j++;
      55:             }
      56:             if (outp+j+2 > 71)
      57:                 contcard();
      58:             if (hollerith) {
      59:                 outnum(--j);
      60:                 ptc('h');
      61:             } else
      62:                 ptc(c);
      63:             while (*p != c) {
      64:                 if (*p == '\\')
      65:                     p++;
      66:                 ptc(*p++);
      67:             }
      68:             if (!hollerith)
      69:                 ptc(c);
      70:             p++;
      71:             break;
      72:         case '$': case '\\':
      73:             if (strlen(p-1)+outp > 71)
      74:                 contcard();
      75:             if (c1 == '"' || c1 == '\'') {
      76:                 ptc(c1);
      77:                 p++;
      78:             } else
      79:                 for (p--; *p; p++)
      80:                     ptc(*p);
      81:             break;
      82:         case '%':
      83:             outp = 0;
      84:             while (*p)
      85:                 ptc(*p++);
      86:             break;
      87:         case '>':
      88:             if( c1=='=' ){
      89:                 pts(".ge."); p++;
      90:             } else
      91:                 pts(".gt.");
      92:             break;
      93:         case '<':
      94:             if( c1=='=' ){
      95:                 pts(".le."); p++;
      96:             } else if( c1=='>' ){
      97:                 pts(".ne."); p++;
      98:             } else
      99:                 pts(".lt.");
     100:             break;
     101:         case '=':
     102:             if( c1=='=' ){
     103:                 pts(".eq."); p++;
     104:             } else
     105:                 ptc('=');
     106:             break;
     107:         case '!': case '^':
     108:             if( c1=='=' ){
     109:                 pts(".ne."); p++;
     110:             } else
     111:                 pts(".not.");
     112:             break;
     113:         case '&':
     114:             if( c1=='&' )
     115:                 p++;
     116:             pts(".and.");
     117:             break;
     118:         case '|':
     119:             if( c1=='|' )
     120:                 p++;
     121:             pts(".or.");
     122:             break;
     123:         case '\t':
     124:             outtab();
     125:             break;
     126:         case '\n':
     127:             ptc(' ');
     128:             break;
     129:         default:
     130:             ptc(c);
     131:             break;
     132:         }
     133:     }
     134: }
     135:
     136: ptc(c) char c; {
     137:     if( outp > 71 )
     138:         contcard();
     139:     outbuf[outp++] = c;
     140: }
     141:
     142: pts(s) char *s; {
     143:     if (strlen(s)+outp > 71)
     144:         contcard();
     145:     while(*s)
     146:         ptc(*s++);
     147: }
     148:
     149: contcard(){
     150:     int n;
     151:     outbuf[outp] = '\0';
     152:     fprintf(outfil, "%s\n", outbuf);
     153:     n = 6;
     154:     if (printcom) {
     155:         n += INDENT * indent + 1;
     156:         if (n > 35) n = 35;
     157:     }
     158:     for( outp=0; outp<n; outbuf[outp++] = ' ' );
     159:     outbuf[contfld-1] = contchar;
     160:     cont++;
     161:     if (cont > 19)
     162:         error("more than 19 continuation cards");
     163: }
     164:
     165: outtab(){
     166:     int n;
     167:     n = 6;
     168:     if (printcom) {
     169:         n += INDENT * indent;
     170:         if (n > 35) n = 35;
     171:     }
     172:     while (outp < n)
     173:         ptc(' ');
     174: }
     175:
     176: outnum(n) int n; {
     177:     int a;
     178:     if( a = n/10 )
     179:         outnum(a);
     180:     ptc(n%10 + '0');
     181: }
     182:
     183: outcont(n) int n; {
     184:     transfer = 0;
     185:     if (n == 0 && outp == 0)
     186:         return;
     187:     if( n > 0 )
     188:         outnum(n);
     189:     outcode("\tcontinue");
     190:     outdon();
     191: }
     192:
     193: outgoto(n) int n; {
     194:     if (transfer != 0)
     195:         return;
     196:     outcode("\tgoto ");
     197:     outnum(n);
     198:     outdon();
     199: }
     200:
     201: flushcom() {
     202:     int i, j;
     203:     if (printcom == 0)
     204:         comptr = 0;
     205:     else if (cont == 0 && comptr > 0) {
     206:         for (i=j=0; i < comptr; i++)
     207:             if (comment[i] == '\n') {
     208:                 comment[i] = '\0';
     209:                 fprintf(outfil, "%s\n", &comment[j]);
     210:                 j = i + 1;
     211:             }
     212:         comptr = 0;
     213:     }
     214: }

#### Defined functions

contcard defined in line 149; used 4 times

- in line 57, 74, 138, 144

flushcom defined in line 201; used 2 times

- in line 40
- in /usr/src/usr.bin/ratfor/rio.c line 124

outcode defined in line 34; used 28 times

- in line 189, 196
- in /usr/src/usr.bin/ratfor/r0.c line 18-20(2), 36-40(3), 53-62(3)
- in /usr/src/usr.bin/ratfor/r1.c line 39-41(2), 54-56(2), 78-80(2), 101, 121, 137, 168, 209, 223-225(2), 257, 274-275(2), 282, 290

outcont defined in line 183; used 15 times

- in /usr/src/usr.bin/ratfor/r0.c line 33, 73, 81-86(2)
- in /usr/src/usr.bin/ratfor/r1.c line 25-29(2), 47, 66-71(2), 89, 182, 204, 263, 302-305(2)

outdon defined in line 18; used 10 times

- in line 30, 190, 198
- in /usr/src/usr.bin/ratfor/r0.c line 22
- in /usr/src/usr.bin/ratfor/r1.c line 139, 201, 258, 277, 283, 297

outgoto defined in line 193; used 12 times

- in /usr/src/usr.bin/ratfor/r0.c line 32, 64, 72
- in /usr/src/usr.bin/ratfor/r1.c line 44, 57-62(2), 81-86(2), 226, 260, 324, 341

outnum defined in line 176; used 11 times

- in line 59, 179, 188, 197
- in /usr/src/usr.bin/ratfor/r0.c line 19, 39
- in /usr/src/usr.bin/ratfor/r1.c line 36, 76, 207, 252, 295

outtab defined in line 165; used 12 times

- in line 28, 124
- in /usr/src/usr.bin/ratfor/r1.c line 37, 53, 77, 136, 196, 208, 256, 273, 281, 289

ptc defined in line 136; used 14 times

- in line 27, 60-69(4), 76-85(3), 105, 127-130(2), 146, 173, 180

pts defined in line 142; used 12 times

- in line 29, 44, 89-103(6), 109-121(4)

putcom defined in line 25; used 8 times

- in /usr/src/usr.bin/ratfor/r0.c line 13, 75
- in /usr/src/usr.bin/ratfor/r1.c line 26, 64, 72, 88, 183, 262

#### Defined variables

comment defined in line 14; used 8 times

- in line 207-209(3)
- in /usr/src/usr.bin/ratfor/r2.c line 207-209(3)
- in /usr/src/usr.bin/ratfor/rio.c line 121-122(2)

comptr defined in line 15; used 12 times

- in line 39, 204-206(3), 212
- in /usr/src/usr.bin/ratfor/r2.c line 39, 204-206(3), 212
- in /usr/src/usr.bin/ratfor/rio.c line 121-122(2)

cont defined in line 11; used 5 times

- in line 22, 39, 160-161(2), 205

contchar defined in line 12; used 3 times

- in line 159
- in /usr/src/usr.bin/ratfor/r2.c line 159
- in /usr/src/usr.bin/ratfor/rlex.c line 70

indent defined in line 16; used 21 times

- in line 155, 169
- in /usr/src/usr.bin/ratfor/r0.c line 24, 35, 65, 74-76(2), 85
- in /usr/src/usr.bin/ratfor/r1.c line 28, 45, 58-65(3), 82-87(2), 245, 261, 298-303(2)
- in /usr/src/usr.bin/ratfor/r2.c line 155, 169

outbuf defined in line 9; used 7 times

- in line 19-21(2), 139, 151-152(2), 158-159(2)

outp defined in line 10; used 15 times

- in line 19-22(3), 56, 73, 83, 137-143(3), 151, 158(3), 172, 185

sccsid defined in line 2; never used

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1305 |