1: #
   2: /*
   3:  * pxp - Pascal execution profiler
   4:  *
   5:  * Bill Joy UCB
   6:  * Version 1.2 January 1979
   7:  */
   8: 
   9: #include "0.h"
  10: 
  11: #define noprint() nopflg
  12: 
  13: int pplev[3];   /* STAT, DECL, PRFN */
  14: int nopflg;
  15: 
  16: setprint()
  17: {
  18: 
  19:     if (profile == 0) {
  20:         if (table)
  21:             nopflg = 1;
  22:         else
  23:             nopflg = 0;
  24:         return;
  25:     }
  26:     nopflg = !all && nowcnt() == 0 || !opt('z');
  27: }
  28: 
  29: printon()
  30: {
  31: 
  32:     if (profile == 0) {
  33:         if (table)
  34:             nopflg = 1;
  35:         return;
  36:     }
  37:     nopflg = 0;
  38: }
  39: 
  40: printoff()
  41: {
  42: 
  43:     nopflg = 1;
  44: }
  45: 
  46: ppkw(s)
  47:     register char *s;
  48: {
  49:     register char *cp, i;
  50: 
  51:     if (noprint())
  52:         return;
  53:     /*
  54: 	 * First real thing printed
  55: 	 * is always a keyword
  56: 	 * or includes an "id" (if a comment)
  57: 	 * (See ppnl below)
  58: 	 */
  59:     hadsome = 1;
  60:     if (underline) {
  61:         for (cp = s; *cp; cp++)
  62:             putchar('_');
  63:         for (cp = s; *cp; cp++)
  64:             putchar('\b');
  65:     }
  66:     printf(s);
  67: }
  68: 
  69: ppid(s)
  70:     register char *s;
  71: {
  72: 
  73:     if (noprint())
  74:         return;
  75:     hadsome = 1;
  76:     if (s == NIL)
  77:         s = "{identifier}";
  78:     printf(s);
  79: }
  80: 
  81: ppbra(s)
  82:     register char *s;
  83: {
  84: 
  85:     if (noprint())
  86:         return;
  87:     if (s != NIL)
  88:         printf(s);
  89: }
  90: 
  91: ppsep(s)
  92:     char *s;
  93: {
  94: 
  95:     if (noprint())
  96:         return;
  97:     printf(s);
  98: }
  99: 
 100: ppket(s)
 101:     char *s;
 102: {
 103: 
 104:     if (noprint())
 105:         return;
 106:     if (s != NIL)
 107:         printf(s);
 108: }
 109: 
 110: char    killsp;
 111: 
 112: ppunspac()
 113: {
 114: 
 115:     killsp = 1;
 116: }
 117: 
 118: ppspac()
 119: {
 120: 
 121:     if (killsp) {
 122:         killsp = 0;
 123:         return;
 124:     }
 125:     if (noprint())
 126:         return;
 127:     putchar(' ');
 128: }
 129: 
 130: ppitem()
 131: {
 132: 
 133:     if (noprint())
 134:         return;
 135:     ppnl();
 136:     indent();
 137: }
 138: 
 139: int owenl, owenlb;
 140: 
 141: ppsnlb()
 142: {
 143: 
 144:     if (nopflg)
 145:         return;
 146:     owenlb++;
 147: }
 148: 
 149: ppsnl()
 150: {
 151: 
 152:     if (nopflg)
 153:         return;
 154:     owenl++;
 155: }
 156: 
 157: pppay()
 158: {
 159: 
 160:     while (owenl || owenlb) {
 161:         putchar('\n');
 162:         if (owenlb) {
 163:             putchar(' ');
 164:             owenlb--;
 165:         } else
 166:             owenl--;
 167:     }
 168: }
 169: 
 170: ppnl()
 171: {
 172: 
 173:     if (noprint())
 174:         return;
 175:     if (hadsome == 0)
 176:         return;
 177:     pppay();
 178:     putchar('\n');
 179: }
 180: 
 181: indent()
 182: {
 183:     register i;
 184: 
 185:     if (noprint())
 186:         return;
 187:     linopr();
 188:     if (profile == 0) {
 189:         indent1(pplev[PRFN] + pplev[DECL] + pplev[STAT]);
 190:         return;
 191:     }
 192:     indent1(pplev[PRFN] + pplev[STAT]);
 193:     switch (i = shudpcnt()) {
 194:         case 1:
 195:             printf("%7.7ld.", nowcnt());
 196:             dashes('-');
 197:             putchar('|');
 198:             break;
 199:         case 0:
 200:         case -1:
 201:             printf("        ");
 202:             dashes(' ');
 203:             putchar(i == 0 ? '|' : ' ');
 204:             break;
 205:     }
 206:     indent1(pplev[DECL]);
 207: }
 208: 
 209: dashes(c)
 210:     char c;
 211: {
 212:     register i;
 213: 
 214:     for (i = unit - 1; i != 0; i--)
 215:         putchar(c);
 216: }
 217: 
 218: indent1(in)
 219:     int in;
 220: {
 221:     register i;
 222: 
 223:     if (noprint())
 224:         return;
 225:     i = in;
 226:     if (profile == 0)
 227:         while (i >= 8) {
 228:             putchar('\t');
 229:             i -= 8;
 230:         }
 231:     while (i > 0) {
 232:         putchar(' ');
 233:         i--;
 234:     }
 235: }
 236: 
 237: linopr()
 238: {
 239: 
 240:     if (noprint())
 241:         return;
 242:     if (profile) {
 243:         if (line < 0)
 244:             line = -line;
 245:         printf("%6d  ", line);
 246:     }
 247: }
 248: 
 249: indentlab()
 250: {
 251: 
 252:     indent1(pplev[PRFN]);
 253: }
 254: 
 255: ppop(s)
 256:     char *s;
 257: {
 258: 
 259:     if (noprint())
 260:         return;
 261:     printf(s);
 262: }
 263: 
 264: ppnumb(s)
 265:     char *s;
 266: {
 267: 
 268:     if (noprint())
 269:         return;
 270:     if (s == NIL)
 271:         s = "{number}";
 272:     printf(s);
 273: }
 274: 
 275: ppgoin(lv)
 276: {
 277: 
 278:     pplev[lv] += unit;
 279: }
 280: 
 281: ppgoout(lv)
 282: {
 283: 
 284:     pplev[lv] -= unit;
 285:     if (pplev[lv] < 0)
 286:         panic("pplev");
 287: }
 288: 
 289: ppstr(s)
 290:     char *s;
 291: {
 292:     register char *cp;
 293: 
 294:     if (noprint())
 295:         return;
 296:     if (s == NIL) {
 297:         printf("{string}");
 298:         return;
 299:     }
 300:     putchar('\'');
 301:     cp = s;
 302:     while (*cp) {
 303:         putchar(*cp);
 304:         if (*cp == '\'')
 305:             putchar('\'');
 306:         cp++;
 307:     }
 308:     putchar('\'');
 309: }
 310: 
 311: pplab(s)
 312:     char *s;
 313: {
 314: 
 315:     if (noprint())
 316:         return;
 317:     if (s == NIL)
 318:         s = "{integer label}";
 319:     printf(s);
 320: }
 321: 
 322: int fout[259] = { 1 };
 323: extern  int putchar(), flush();
 324: 
 325: int outcol;
 326: 
 327: extern  int werflg;
 328: 
 329: putchar(c)
 330:     char c;
 331: {
 332: 
 333:     werflg = 0;
 334:     putc(c, fout);
 335:     if (werflg)
 336:         outerr();
 337:     switch (c) {
 338:         case '\n':
 339:             outcol = 0;
 340:             flush();
 341:             break;
 342:         case '\t':
 343:             outcol += 8;
 344:             outcol &= ~07;
 345:             break;
 346:         case '\b':
 347:             if (outcol)
 348:                 outcol--;
 349:             break;
 350:         default:
 351:             outcol++;
 352:         case '\f':
 353:             break;
 354:     }
 355: }
 356: 
 357: flush()
 358: {
 359: 
 360:     werflg = 0;
 361:     fflush(fout);
 362:     if (werflg)
 363:         outerr();
 364: }
 365: 
 366: pptab()
 367: {
 368:     register int i;
 369: 
 370:     if (noprint())
 371:         return;
 372:     i = pplev[PRFN] + profile ? 44 + unit : 28;
 373: /*
 374: 	if (outcol > i + 8) {
 375: 		ppnl();
 376: 		i += 8;
 377: 	}
 378: */
 379:     do
 380:         putchar('\t');
 381:     while (outcol < i);
 382: }
 383: 
 384: outerr()
 385: {
 386:     extern int errno;
 387: 
 388:     errno = werflg;
 389:     perror(stdoutn);
 390:     pexit(DIED);
 391: }

Defined functions

dashes defined in line 209; used 2 times
indent1 defined in line 218; used 4 times
indentlab defined in line 249; used 1 times
linopr defined in line 237; used 2 times
outerr defined in line 384; used 2 times
pplab defined in line 311; used 3 times
ppnumb defined in line 264; used 2 times
pppay defined in line 157; used 1 times
ppsnl defined in line 149; used 1 times
ppsnlb defined in line 141; used 1 times
ppstr defined in line 289; used 2 times
pptab defined in line 366; used 1 times
ppunspac defined in line 112; used 1 times
printon defined in line 29; used 2 times
setprint defined in line 16; used 3 times

Defined variables

fout defined in line 322; used 2 times
killsp defined in line 110; used 3 times
nopflg defined in line 14; used 10 times
outcol defined in line 325; used 7 times
owenl defined in line 139; used 3 times
owenlb defined in line 139; used 4 times
pplev defined in line 13; used 11 times

Defined macros

noprint defined in line 11; used 16 times
Last modified: 1986-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1854
Valid CSS Valid XHTML 1.0 Strict