|
|
1.1 ! root 1: #include <stdio.h> ! 2: ! 3: #define DBL 0200 ! 4: /* ! 5: C version of pti ! 6: */ ! 7: ! 8: char *ap; ! 9: int esc; ! 10: int escd; ! 11: int verd; ! 12: int esct; ! 13: int osize = 02; ! 14: int size = 02; ! 15: int leadtot; ! 16: int railmag; ! 17: int lead; ! 18: int mcase; ! 19: int stab[] = {010,0,01,07,02,03,04,05,0211,06,0212,0213,0214,0215,0216,0217}; ! 20: int rtab[] = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 36, 18}; ! 21: ! 22: char *asctab[128] = { ! 23: "(blank)", /*blank*/ ! 24: "h", /*h*/ ! 25: "t", /*t*/ ! 26: "n", /*n*/ ! 27: "m", /*m*/ ! 28: "l", /*l*/ ! 29: "i", /*i*/ ! 30: "z", /*z*/ ! 31: "s", /*s*/ ! 32: "d", /*d*/ ! 33: "b", /*b*/ ! 34: "x", /*x*/ ! 35: "f", /*f*/ ! 36: "j", /*j*/ ! 37: "u", /*u*/ ! 38: "k", /*k*/ ! 39: "(blank)", /*blank*/ ! 40: "p", /*p*/ ! 41: "em dash", /*3/4 em dash*/ ! 42: ";", /*;*/ ! 43: "(blank)", /*blank*/ ! 44: "a", /*a*/ ! 45: "_ (baseline)", /*rule*/ ! 46: "c", /*c*/ ! 47: "` (open)", /*` open*/ ! 48: "e", /*e*/ ! 49: "' (close)", /*' close*/ ! 50: "o", /*o*/ ! 51: "1/4", /*1/4*/ ! 52: "r", /*r*/ ! 53: "1/2", /*1/2*/ ! 54: "v", /*v*/ ! 55: "hyphen", /*- hyphen*/ ! 56: "w", /*w*/ ! 57: "q", /*q*/ ! 58: "/", /*/*/ ! 59: ".", /*.*/ ! 60: "g", /*g*/ ! 61: "3/4", /*3/4*/ ! 62: ",", /*,*/ ! 63: "&", /*&*/ ! 64: "y", /*y*/ ! 65: "(blank)", /*blank*/ ! 66: "%", /*%*/ ! 67: "(blank)", /*blank*/ ! 68: "Q", /*Q*/ ! 69: "T", /*T*/ ! 70: "O", /*O*/ ! 71: "H", /*H*/ ! 72: "N", /*N*/ ! 73: "M", /*M*/ ! 74: "L", /*L*/ ! 75: "R", /*R*/ ! 76: "G", /*G*/ ! 77: "I", /*I*/ ! 78: "P", /*P*/ ! 79: "C", /*C*/ ! 80: "V", /*V*/ ! 81: "E", /*E*/ ! 82: "Z", /*Z*/ ! 83: "D", /*D*/ ! 84: "B", /*B*/ ! 85: "S", /*S*/ ! 86: "Y", /*Y*/ ! 87: "(blank)", /*blank*/ ! 88: "F", /*F*/ ! 89: "X", /*X*/ ! 90: "A", /*A*/ ! 91: "W", /*W*/ ! 92: "J", /*J*/ ! 93: "U", /*U*/ ! 94: "K", /*K*/ ! 95: "0", /*0*/ ! 96: "1", /*1*/ ! 97: "2", /*2*/ ! 98: "3", /*3*/ ! 99: "4", /*4*/ ! 100: "5", /*5*/ ! 101: "6", /*6*/ ! 102: "7", /*7*/ ! 103: "8", /*8*/ ! 104: "9", /*9*/ ! 105: "*", /***/ ! 106: "-", /*minus*/ ! 107: "fi", /*fi*/ ! 108: "fl", /*fl*/ ! 109: "ff", /*ff*/ ! 110: "cent", /*cent sign*/ ! 111: "ffl", /*ffl*/ ! 112: "ffi", /*ffi*/ ! 113: "(", /*(*/ ! 114: ")", /*)*/ ! 115: "[", /*[*/ ! 116: "]", /*]*/ ! 117: "degree", /*degree*/ ! 118: "dagger", /*dagger*/ ! 119: "=", /*=*/ ! 120: "registered", /*registered*/ ! 121: ":", /*:*/ ! 122: "+", /*+*/ ! 123: "(blank)", /*blank*/ ! 124: "!", /*!*/ ! 125: "bullet", /*bullet*/ ! 126: "?", /*?*/ ! 127: "' (foot)", /*foot mark*/ ! 128: "|", /*|*/ ! 129: "(blank)", /*blank*/ ! 130: "copyright", /*copyright*/ ! 131: "[]", /*square*/ ! 132: "$" }; /*$*/ ! 133: ! 134: char *spectab[128] = { ! 135: "(blank)", /*blank*/ ! 136: "psi", /*psi*/ ! 137: "theta", /*theta*/ ! 138: "nu", /*nu*/ ! 139: "mu", /*mu*/ ! 140: "lambda", /*lambda*/ ! 141: "iota", /*iota*/ ! 142: "zeta", /*zeta*/ ! 143: "sigma", /*sigma*/ ! 144: "delta", /*delta*/ ! 145: "beta", /*beta*/ ! 146: "xi", /*xi*/ ! 147: "eta", /*eta*/ ! 148: "phi", /*phi*/ ! 149: "upsilon", /*upsilon*/ ! 150: "kappa", /*kappa*/ ! 151: "(blank)", /*blank*/ ! 152: "pi", /*pi*/ ! 153: "@", /*at-sign*/ ! 154: "down arrow", /*down arrow*/ ! 155: "(blank)", /*blank*/ ! 156: "alpha", /*alpha*/ ! 157: "| or", /*or*/ ! 158: "chi", /*chi*/ ! 159: "\"", /*"*/ ! 160: "epsilon", /*epsilon*/ ! 161: "= math", /*=*/ ! 162: "omicron", /*omicron*/ ! 163: "left arrow", /*left arrow*/ ! 164: "rho", /*rho*/ ! 165: "up arrow", /*up arrow*/ ! 166: "tau", /*tau*/ ! 167: "_ (under)", /*underrule*/ ! 168: "\\", /*\*/ ! 169: "Psi", /*Psi*/ ! 170: "bell system sign", /*bell system sign*/ ! 171: "infinity", /*infinity*/ ! 172: "gamma", /*gamma*/ ! 173: "improper superset", /*improper superset*/ ! 174: "proportional to", /*proportional to*/ ! 175: "right hand", /*right hand*/ ! 176: "omega", /*omega*/ ! 177: "(blank)", /*blank*/ ! 178: "gradient", /*gradient*/ ! 179: "(blank)", /*blank*/ ! 180: "Phi", /*Phi*/ ! 181: "Theta", /*Theta*/ ! 182: "Omega", /*Omega*/ ! 183: "cup (union)", /*cup (union)*/ ! 184: "root en", /*root en*/ ! 185: "terminal sigma", /*terminal sigma*/ ! 186: "Lambda", /*Lambda*/ ! 187: "- math", /*minus*/ ! 188: "Gamma", /*Gamma*/ ! 189: "integral sign", /*integral sign*/ ! 190: "Pi", /*Pi*/ ! 191: "subset of", /*subset of*/ ! 192: "superset of", /*superset of*/ ! 193: "approximates", /*approximates*/ ! 194: "partial", /*partial derivative*/ ! 195: "Delta", /*Delta*/ ! 196: "square root", /*square root*/ ! 197: "Sigma", /*Sigma*/ ! 198: "approx =", /*approx =*/ ! 199: "(blank)", /*blank*/ ! 200: ">", /*>*/ ! 201: "Xi", /*Xi*/ ! 202: "<", /*<*/ ! 203: "/ (match \\)", /*slash (longer)*/ ! 204: "cap (intersection)", /*cap (intersection)*/ ! 205: "Upsilon", /*Upsilon*/ ! 206: "not", /*not*/ ! 207: "right ceiling", /*right ceiling (rt of ")*/ ! 208: "left top curly", /*left top (of big curly)*/ ! 209: "bold vertical", /*bold vertical*/ ! 210: "left center curley", /*left center of big curly bracket*/ ! 211: "left bottom curley", /*left bottom*/ ! 212: "right top curley", /*right top*/ ! 213: "right center curley", /*right center of big curly bracket*/ ! 214: "right bottom curley", /*right bot*/ ! 215: "right floor", /*right floor (rb of ")*/ ! 216: "left floor", /*left floor (left bot of big sq bract)*/ ! 217: "left ceiling", /*left ceiling (lt of ")*/ ! 218: "multiply", /*multiply*/ ! 219: "divide", /*divide*/ ! 220: "+-", /*plus-minus*/ ! 221: "<=", /*<=*/ ! 222: ">=", /*>=*/ ! 223: "==", /*identically equal*/ ! 224: "not equal", /*not equal*/ ! 225: "{", /*{*/ ! 226: "}", /*}*/ ! 227: "'", /*' acute accent*/ ! 228: "`", /*` grave accent*/ ! 229: "^", /*^*/ ! 230: "#", /*sharp*/ ! 231: "left hand", /*left hand*/ ! 232: "member of", /*member of*/ ! 233: "~", /*~*/ ! 234: "empty set", /*empty set*/ ! 235: "(blank)", /*blank*/ ! 236: "dbl dagger", /*dbl dagger*/ ! 237: "| (box rule)", /*box rule*/ ! 238: "*", /*asterisk*/ ! 239: "improper subset", /*improper subset*/ ! 240: "circle", /*circle*/ ! 241: "(blank)", /*blank*/ ! 242: "+ math", /*eqn plus*/ ! 243: "right arrow", /*right arrow*/ ! 244: "section mark" }; /*section mark*/ ! 245: ! 246: long offset; ! 247: int lflg; ! 248: ! 249: main(argc,argv) ! 250: int argc; ! 251: char **argv; ! 252: { ! 253: register i, j; ! 254: register char *k; ! 255: extern ex(); ! 256: ! 257: while((--argc > 0) && ((++argv)[0][0]=='-')){ ! 258: switch(argv[0][1]){ ! 259: case 'l': ! 260: lflg++; ! 261: continue; ! 262: default: ! 263: ap = &argv[0][1]; ! 264: while(((j = *ap++ - '0') >= 0) ! 265: && (j <= 9))offset = 8*offset +j; ! 266: continue; ! 267: } ! 268: } ! 269: if(argc){ ! 270: if (freopen(argv[0], "r", stdin) == NULL) { ! 271: printf("Cannot open: %s\n",argv[0]); ! 272: exit(1); ! 273: } ! 274: } ! 275: if (offset) ! 276: fseek(stdin, offset, 0); ! 277: while((i = getchar()) != EOF){ ! 278: if(i & 0200){ ! 279: if(!lflg)printf("%o ",i); ! 280: esc += (~i) & 0177; ! 281: continue; ! 282: } ! 283: if(esc){ ! 284: if(escd){ ! 285: if(!lflg)printf("< %d\n",esc); ! 286: esc = -esc; ! 287: }else{ ! 288: if(!lflg)printf("> %d\n",esc); ! 289: } ! 290: esct += esc; ! 291: esc = 0; ! 292: } ! 293: if(!lflg)printf("%o ",i); ! 294: if(!i){if(!lflg)printf("\n"); continue;} ! 295: switch(i){ ! 296: case 0100: /*init*/ ! 297: escd = verd = mcase = railmag = 0; ! 298: if(!lflg)printf("Initialize\n"); ! 299: continue; ! 300: case 0101: /*lower rail*/ ! 301: railmag &= ~01; ! 302: if(!lflg)printf("Lower rail\n"); ! 303: continue; ! 304: case 0102: /*upper rail*/ ! 305: railmag |= 01; ! 306: if(!lflg)printf("Upper rail\n"); ! 307: continue; ! 308: case 0103: /*upper mag*/ ! 309: railmag |= 02; ! 310: if(!lflg)printf("Upper mag\n"); ! 311: continue; ! 312: case 0104: /*lower mag*/ ! 313: railmag &= ~02; ! 314: if(!lflg)printf("Lower mag\n"); ! 315: continue; ! 316: case 0105: /*lower case*/ ! 317: mcase = 0; ! 318: if(!lflg)printf("Lower case\n"); ! 319: continue; ! 320: case 0106: /*upper case*/ ! 321: mcase = 0100; ! 322: if(!lflg)printf("Upper case\n"); ! 323: continue; ! 324: case 0107: /*escape forward*/ ! 325: escd = 0; ! 326: if(!lflg)printf("> mode, %d\n",esct); ! 327: continue; ! 328: case 0110: /*escape backward*/ ! 329: escd = 1; ! 330: if(!lflg)printf("< mode, %d\n",esct); ! 331: continue; ! 332: case 0111: /*stop*/ ! 333: if(!lflg)printf("STOP\n"); ! 334: continue; ! 335: case 0112: /*lead forward*/ ! 336: verd = 0; ! 337: if(!lflg)printf("Lead forward, %d\n",leadtot); ! 338: continue; ! 339: case 0114: /*lead backward*/ ! 340: verd = 1; ! 341: if(!lflg)printf("Lead backward, %d\n",leadtot); ! 342: continue; ! 343: case 0115: /*undefined*/ ! 344: case 0116: ! 345: case 0117: ! 346: case 0113: ! 347: if(!lflg)printf("Undefined code\n"); ! 348: continue; ! 349: } ! 350: if((i & 0340) == 0140){ /*leading*/ ! 351: lead = (~i) & 037; ! 352: if(!lflg)printf("Lead %d\n",lead); ! 353: if(verd)lead = -lead; ! 354: leadtot += lead; ! 355: continue; ! 356: } ! 357: if((i & 0360) == 0120){ /*size change*/ ! 358: i &= 017; ! 359: for(j = 0; i != (stab[j] & 017); j++); ! 360: osize = size; ! 361: size = stab[j]; ! 362: if(!lflg){ ! 363: printf("Size %d",rtab[j]); ! 364: if(!(osize & DBL) && (size & DBL))printf(", double\n"); ! 365: else if((osize & DBL) && !(size & DBL))printf(", single\n"); ! 366: else printf("\n"); ! 367: } ! 368: continue; ! 369: } ! 370: if(i & 0300)continue; ! 371: i = (i & 077) | mcase; ! 372: if(railmag != 03)k = asctab[i]; ! 373: else k = spectab[i]; ! 374: if(!lflg)printf("%s\n",k); ! 375: continue; ! 376: } ! 377: ex(); ! 378: } ! 379: ex(){ ! 380: printf("Total lead %d\n",leadtot); ! 381: exit(0); ! 382: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.