1: # define PL 102
   2: # define ESC 033
   3: # define SI 017
   4: # define SO 016
   5: # define LINELN 800
   6: char *page[PL];
   7: char lbuff [LINELN], *line;
   8: main ()
   9: {
  10: int c, i, j, ll, cp, mustwr;
  11:     extern int fin, fout;
  12:     fin = dup(0);
  13:     fout = dup(1);
  14: 
  15: for (ll=0; ll<PL; ll++)
  16:     page[ll] = 0;
  17: 
  18: c = 1;
  19: cp = ll = 0;
  20: line = lbuff;
  21: mustwr = PL;
  22: 
  23: while (c>0)
  24:     switch (c = getchar())
  25:         {
  26:         case '\n':
  27:             store (ll%PL);
  28:             if (++ll >= mustwr)
  29:                 if (page[ll%PL] != 0)
  30:                     {
  31:                     printf ("%s\n",page[ll%PL]);
  32:                     mustwr++;
  33:                     free (page[ll%PL]);
  34:                     page[ll%PL]=0;
  35:                     }
  36:             fetch (ll%PL);
  37:             cp = 0;
  38:             continue;
  39:         case '\0': continue;
  40:         case ESC:
  41:             c = getchar();
  42:             if (c == '7')
  43:                 {
  44:                 store(ll%PL);
  45:                 ll--;
  46:                 fetch (ll%PL);
  47:                 }
  48:             else
  49:                 {
  50:                 outc (ESC, &line);
  51:                 outc (c, &line );
  52:                 }
  53:             continue;
  54:         case '\r':
  55:             line = lbuff;
  56:             continue;
  57:         case '\t':
  58:             outc (' ', &line);
  59:             cp = line-lbuff;
  60:             while (cp++%8)
  61:                 outc(' ', &line);
  62:             continue;
  63:         default:
  64:             outc(c, &line);
  65:         }
  66: for (i=0; i<PL; i++)
  67:    if (page[(mustwr+i)%PL] != 0)
  68:     printf ("%s\n",page[(mustwr+i) % PL]);
  69: flush();
  70: }
  71: outc (c, lp)
  72:     char **lp;
  73: {
  74: int j;
  75: j = 0;
  76: while (j >0 || *(*lp) == '\b' || *(*lp) == ESC || **lp == SI || **lp == SO)
  77:     {
  78:     switch (*(*lp))
  79:         {
  80:         case '\b':
  81:             j++;
  82:             (*lp)++;
  83:             break;
  84:         case '\0':
  85:             *(*lp)++ = ' ';
  86:             j--;
  87:             break;
  88:         case ESC: /* 'escape' */
  89:             (*lp) =+ 2;
  90:             break;
  91:         case SI:
  92:         case SO:
  93:             (*lp)++;
  94:             break;
  95:         default:
  96:             (*lp)++;
  97:             j--;
  98:             break;
  99:         }
 100:     }
 101: if (c != ' ' || *(*lp) == '\0')
 102:     *(*lp) = c;
 103: (*lp)++;
 104: }
 105: store (ll)
 106: {
 107: if (page[ll] != 0)
 108:     free (page[ll]);
 109: page[ll] = alloc ( leng (lbuff) + 2);
 110: copy (page[ll],lbuff);
 111: }
 112: fetch(ll)
 113: {
 114: int i;
 115: for (i=0; i < LINELN; i++)
 116:  lbuff[i] = '\0';
 117: copy (line=lbuff, page[ll]);
 118: }
 119: copy (s,t)
 120:     char *s, *t;
 121: {
 122: if (t == 0)
 123:     return (*s=0);
 124: while (*s++ = *t++);
 125: }
 126: leng (s)
 127:     char *s;
 128: {
 129: int l;
 130: for (l=0; s[l]; l++);
 131: return (l);
 132: }

Defined functions

copy defined in line 119; used 2 times
fetch defined in line 112; used 2 times
leng defined in line 126; used 1 times
main defined in line 8; never used
outc defined in line 71; used 5 times
store defined in line 105; used 2 times

Defined variables

lbuff defined in line 7; used 7 times
line defined in line 7; used 9 times
page defined in line 6; used 12 times

Defined macros

ESC defined in line 2; used 2 times
LINELN defined in line 5; used 2 times
PL defined in line 1; used 14 times
SI defined in line 3; used 1 times
  • in line 76
SO defined in line 4; used 1 times
  • in line 76
Last modified: 1975-06-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1020
Valid CSS Valid XHTML 1.0 Strict