1: #define PLOT    006 /* ack */
   2: #define BEL    007     /* exit plot mode */
   3: #define ESC 033 /* escape */
   4: #define HFWD    '9'
   5: #define HREV    '8'
   6: #define FREV    '7'
   7: #define SO  016 /* shift out - enter greek */
   8: #define SI  017 /* shift in */
   9: #define UP  013
  10: #define DN  012
  11: #define RT  ' '
  12: #define LF  '\b'
  13: 
  14: int restore();
  15: int svmode, mode[3];
  16: 
  17: main(argc,argv) int argc; char **argv; {
  18:     int c, textmode;
  19:     extern int fin,fout;
  20:     fin = dup(0);
  21:     fout = dup(1);
  22:     if ((signal(2, 1) & 01) == 0)
  23:         signal(2, &restore);
  24:     gtty(1, mode);
  25:     svmode = mode[2];
  26:     mode[2] =& 0777757; /* turn off cr-lf  */
  27:     mode[2] =| 03;  /* turn off delays, tabs */
  28:     stty(1, mode);
  29:     textmode = 1;
  30:     while( (c=getchar()) != '\0' ){
  31:         if( c==SO ){
  32:             special();
  33:             continue;
  34:         }
  35:         if (c== PLOT) textmode = 1-textmode;
  36:         if (c==BEL) textmode = 1;
  37:         if( c=='\n' && textmode )
  38:             putchar(015);   /* CR */
  39:         if( c!=ESC ){
  40:             putchar(c);
  41:             continue;
  42:         }
  43:         putchar(PLOT);
  44:         c = getchar();
  45:         if( c == HREV )
  46:             nplot(4,UP);
  47:         else if( c == HFWD )
  48:             nplot(4,DN);
  49:         else if( c == FREV )
  50:             nplot(8,UP);
  51:         putchar(PLOT);
  52:     }
  53:     flush();
  54:     restore();
  55: }
  56: 
  57: restore(){
  58:     mode[2] = svmode;
  59:     stty(1, mode);
  60:     exit();
  61: }
  62: 
  63: int tab[]{
  64:     'A',    /* alpha */
  65:     'B',    /* beta */
  66:     'D',    /* delta */
  67:     'W',    /* DELTA */
  68:     'S',    /* epsilon */
  69:     'N',    /* eta */
  70:     '\\',   /* gamma */
  71:     'G',    /* GAMMA */
  72:     'o',    /* infinity - not in M37 */
  73:     '^',    /* integral */
  74:     'L',    /* lambda */
  75:     'E',    /* LAMBDA */
  76:     'M',    /* mu */
  77:     '[',    /* nabla (del) */
  78:     '_',    /* not */
  79:     '@',    /* nu */
  80:     'C',    /* omega */
  81:     'Z',    /* OMEGA */
  82:     ']',    /* partial */
  83:     'U',    /* phi */
  84:     'F',    /* PHI */
  85:     'V',    /* psi */
  86:     'H',    /* PSI */
  87:     'J',    /* pi */
  88:     'P',    /* PI */
  89:     'K',    /* rho */
  90:     'Y',    /* sigma */
  91:     'R',    /* SIGMA */
  92:     'I',    /* tau */
  93:     'T',    /* theta */
  94:     'O',    /* THETA */
  95:     'X',    /* xi */
  96:     'Q',    /* zeta */
  97:     0
  98: };
  99: int trans[]{
 100:     alpha,
 101:     beta,
 102:     delta,
 103:     DELTA,
 104:     epsilon,
 105:     eta,
 106:     gamma,
 107:     GAMMA,
 108:     infinity,
 109:     integral,
 110:     lambda,
 111:     LAMBDA,
 112:     mu,
 113:     nabla,
 114:     not,
 115:     nu,
 116:     omega,
 117:     OMEGA,
 118:     partial,
 119:     phi,
 120:     PHI,
 121:     psi,
 122:     PSI,
 123:     pi,
 124:     PI,
 125:     rho,
 126:     sigma,
 127:     SIGMA,
 128:     tau,
 129:     theta,
 130:     THETA,
 131:     xi,
 132:     zeta,
 133:     0
 134: };
 135: 
 136: int alpha[] {LF,'c',RT,RT,'(',LF,0};
 137: int beta[]  {'B',LF,LF,DN,DN,'|',RT,RT,UP,UP,0};
 138: int delta[] {'o',UP,UP,'<',DN,DN,0};
 139: int DELTA[] {LF,LF,'/',-3,DN,'-',-4,RT,'-',-3,UP,'\\',LF,LF,0};
 140: int epsilon[]   {'<','-',0};
 141: int eta[]   {'n',RT,RT,DN,DN,'|',LF,LF,UP,UP,0};
 142: int gamma[] {')',RT,'/',LF,0};
 143: int GAMMA[] {LF,LF,'|',RT,RT,-3,UP,'-',-3,DN,RT,RT,'`',LF,LF,0};
 144: int infinity[]  {LF,LF,'c',-4,RT,'o',LF,LF,0};
 145: int integral[]  {'|','\'',RT,RT,'`',-3,LF,-6,DN,'\'',LF,'`',RT,RT,-6,UP,0};
 146: int lambda[]    {'\\',-4,DN,LF,'\'',DN,LF,'\'',-5,UP,RT,RT,0};
 147: int LAMBDA[]    {LF,LF,'/',-4,RT,'\\',LF,LF,0};
 148: int mu[]    {'u',LF,LF,',',RT,RT,0};
 149: int nabla[] {LF,LF,'\\',-3,UP,'-',-4,RT,'-',-3,DN,'/',LF,LF,0};
 150: int not[]   {'-',-2,RT,UP,',',DN,-2,LF,0};
 151: int nu[]    {LF,'(',-3,RT,'/',LF,LF,0};
 152: int omega[] {LF,'u',-3,RT,'u',LF,LF,0};
 153: int OMEGA[] {'O',DN,DN,LF,'-',RT,RT,'-',LF,UP,UP,0};
 154: int partial[]   {'o',RT,DN,'`',LF,UP,'`',LF,UP,'`',RT,DN,0};
 155: int phi[]   {'o','/',0};
 156: int PHI[]   {'o','[',']',0};
 157: int psi[]   {'/','-',DN,DN,RT,RT,'\'',-4,LF,'\'',RT,RT,UP,UP,0};
 158: int PSI[]   {'[',']','-',DN,DN,RT,RT,'\'',-4,LF,'`',RT,RT,UP,UP,0};
 159: int pi[]    {UP,'-',-3,DN,'"',DN,'"',-3,UP,0};
 160: int PI[]    {LF,LF,'[',']',-4,RT,'[',']',LF,LF,-3,UP,'-',-3,DN,0};
 161: int rho[]   {'o',LF,LF,DN,DN,'|',UP,UP,RT,RT,0};
 162: int sigma[] {'o',DN,RT,RT,'~',UP,LF,LF,0};
 163: int SIGMA[] {'>',-2,DN,'-',-5,UP,'-',-3,DN,0};
 164: int tau[]   {'t',DN,RT,RT,'~',LF,LF,LF,'~',RT,UP,0};
 165: int theta[] {'O','-',0};
 166: int THETA[] {'O','=',0};
 167: int xi[]    {'c',RT,DN,',',LF,-3,UP,'c',LF,DN,'`',RT,DN,0};
 168: int zeta[]  {'c',RT,DN,',',LF,-3,UP,'<',DN,DN,0};
 169: 
 170: special(){
 171:     int c,i,j,t;
 172:    loop:
 173:     if( (c=getchar()) == SI )
 174:         return;
 175:     for( i=0; tab[i]!=0; i++)
 176:         if( c==tab[i] ){
 177:             plot(trans[i]);
 178:             goto loop;
 179:         }
 180:     putchar(c);
 181:     goto loop;
 182: }
 183: 
 184: plot(s) int *s; {
 185:     int i,c;
 186:     putchar(PLOT);
 187:     for( i=0; (c=s[i])!=0; i++ )
 188:         if( c<0 )
 189:             nplot(-c,s[++i]);
 190:         else
 191:             putchar(c);
 192:     putchar(PLOT);
 193:     putchar(' ');
 194: }
 195: 
 196: nplot(n,c) int n,c; {
 197:     while(n--)
 198:         putchar(c);
 199: }

Defined functions

main defined in line 17; never used
nplot defined in line 196; used 4 times
plot defined in line 184; used 1 times
restore defined in line 57; used 3 times
special defined in line 170; used 1 times
  • in line 32

Defined variables

DELTA defined in line 139; used 1 times
GAMMA defined in line 143; used 1 times
LAMBDA defined in line 147; used 1 times
OMEGA defined in line 153; used 1 times
PHI defined in line 156; used 1 times
PI defined in line 160; used 1 times
PSI defined in line 158; used 1 times
SIGMA defined in line 163; used 1 times
THETA defined in line 166; used 1 times
alpha defined in line 136; used 1 times
beta defined in line 137; used 1 times
delta defined in line 138; used 1 times
epsilon defined in line 140; used 1 times
eta defined in line 141; used 1 times
gamma defined in line 142; used 1 times
infinity defined in line 144; used 1 times
integral defined in line 145; used 1 times
lambda defined in line 146; used 1 times
mode defined in line 15; used 7 times
mu defined in line 148; used 1 times
nabla defined in line 149; used 1 times
not defined in line 150; used 1 times
nu defined in line 151; used 1 times
omega defined in line 152; used 1 times
partial defined in line 154; used 1 times
phi defined in line 155; used 1 times
pi defined in line 159; used 1 times
psi defined in line 157; used 1 times
rho defined in line 161; used 1 times
sigma defined in line 162; used 1 times
svmode defined in line 15; used 2 times
tab defined in line 63; used 2 times
tau defined in line 164; used 1 times
theta defined in line 165; used 1 times
trans defined in line 99; used 1 times
xi defined in line 167; used 1 times
zeta defined in line 168; used 1 times

Defined macros

BEL defined in line 2; used 1 times
  • in line 36
DN defined in line 10; used 37 times
ESC defined in line 3; used 1 times
  • in line 39
FREV defined in line 6; used 1 times
  • in line 49
HFWD defined in line 4; used 1 times
  • in line 47
HREV defined in line 5; used 1 times
  • in line 45
LF defined in line 12; used 60 times
PLOT defined in line 1; used 5 times
RT defined in line 11; used 49 times
SI defined in line 8; used 1 times
SO defined in line 7; used 1 times
  • in line 31
UP defined in line 9; used 32 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1492
Valid CSS Valid XHTML 1.0 Strict