1: /*
   2:  * pi - Pascal interpreter code translator
   3:  *
   4:  * Charles Haley, Bill Joy UCB
   5:  * Version 1.2 January 1979
   6:  *
   7:  *
   8:  * pxp - Pascal execution profiler
   9:  *
  10:  * Bill Joy UCB
  11:  * Version 1.2 January 1979
  12:  */
  13: 
  14: #include "0.h"
  15: 
  16: #ifndef PI1
  17: /*
  18:  * Does the string fp end in '.' and the character c ?
  19:  */
  20: dotted(fp, c)
  21:     register char *fp;
  22:     char c;
  23: {
  24:     register int i;
  25: 
  26:     i = strlen(fp);
  27:     return (i > 1 && fp[i - 2] == '.' && fp[i - 1] == c);
  28: }
  29: 
  30: /*
  31:  * Toggle the option c.
  32:  */
  33: togopt(c)
  34:     char c;
  35: {
  36:     register char *tp;
  37: 
  38:     tp = &opts[c-'a'];
  39:     *tp = 1 - *tp;
  40: }
  41: 
  42: /*
  43:  * Set the time vector "tvec" to the
  44:  * modification time stamp of the current file.
  45:  */
  46: gettime()
  47: {
  48:     int stbuf[18];
  49: 
  50:     stat(filename, stbuf);
  51:     tvec[0] = stbuf[16];
  52:     tvec[1] = stbuf[17];
  53: }
  54: 
  55: /*
  56:  * Convert a "ctime" into a Pascal styple time line
  57:  */
  58: myctime(tv)
  59:     int *tv;
  60: {
  61:     register char *cp, *dp;
  62:     char *cpp;
  63:     register i;
  64:     static char mycbuf[26];
  65: 
  66:     cpp = ctime(tv);
  67:     dp = mycbuf;
  68:     cp = cpp;
  69:     cpp[16] = 0;
  70:     while (*dp++ = *cp++);
  71:     dp--;
  72:     cp = cpp+19;
  73:     cpp[24] = 0;
  74:     while (*dp++ = *cp++);
  75:     return (mycbuf);
  76: }
  77: 
  78: /*
  79:  * Is "fp" in the command line list of names ?
  80:  */
  81: inpflist(fp)
  82:     char *fp;
  83: {
  84:     register i, *pfp;
  85: 
  86:     pfp = pflist;
  87:     for (i = pflstc; i > 0; i--)
  88:         if (strcmp(fp, *pfp++) == 0)
  89:             return (1);
  90:     return (0);
  91: }
  92: #endif
  93: 
  94: extern  int errno;
  95: extern  char *sys_errlist[];
  96: 
  97: /*
  98:  * Boom!
  99:  */
 100: Perror(file, error)
 101:     char *file, *error;
 102: {
 103: 
 104:     errno = 0;
 105:     sys_errlist[0] = error;
 106:     perror(file);
 107: }
 108: 
 109: calloc(num, size)
 110:     int num, size;
 111: {
 112:     register int p1, *p2, nbyte;
 113: 
 114:     nbyte = (num*size+1) & ~01;
 115:     if ((p1 = alloc(nbyte)) == -1 || p1==0)
 116:         return (-1);
 117:     p2 = p1;
 118:     nbyte =>> 1;        /* 2 bytes/word */
 119:     do {
 120:         *p2++ = 0;
 121:     } while (--nbyte);
 122:     return (p1);
 123: }
 124: 
 125: /*
 126:  * Compare strings:  s1>s2: >0  s1==s2: 0  s1<s2: <0
 127:  */
 128: strcmp(s1, s2)
 129:     register char *s1, *s2;
 130: {
 131: 
 132:     while (*s1 == *s2++)
 133:         if (*s1++=='\0')
 134:             return (0);
 135:     return (*s1 - *--s2);
 136: }
 137: 
 138: /*
 139:  * Copy string s2 to s1.
 140:  * S1 must be large enough.
 141:  * Return s1.
 142:  */
 143: strcpy(s1, s2)
 144:     register char *s1, *s2;
 145: {
 146:     register os1;
 147: 
 148:     os1 = s1;
 149:     while (*s1++ = *s2++)
 150:         continue;
 151:     return (os1);
 152: }
 153: 
 154: /*
 155:  * Strlen is currently a freebie of perror
 156:  * Take the length of a string.
 157:  * Note that this does not include the trailing null!
 158: strlen(cp)
 159: 	register char *cp;
 160: {
 161: 	register int i;
 162: 
 163: 	for (i = 0; *cp != 0; cp++)
 164: 		i++;
 165: 	return (i);
 166: }
 167:  */
 168: copy(to, from, bytes)
 169:     register char *to, *from;
 170:     register int bytes;
 171: {
 172: 
 173:     if (bytes != 0)
 174:         do
 175:             *to++ = *from++;
 176:         while (--bytes);
 177: }
 178: 
 179: /*
 180:  * Is ch one of the characters in the string cp ?
 181:  */
 182: any(cp, ch)
 183:     register char *cp;
 184:     char ch;
 185: {
 186: 
 187:     while (*cp)
 188:         if (*cp++ == ch)
 189:             return (1);
 190:     return (0);
 191: }
 192: 
 193: opush(c)
 194:     register CHAR c;
 195: {
 196: 
 197:     c =- 'a';
 198:     optstk[c] =<< 1;
 199:     optstk[c] =| opts[c];
 200:     opts[c] = 1;
 201: #ifdef PI0
 202:     send(ROPUSH, c);
 203: #endif
 204: }
 205: 
 206: opop(c)
 207:     register CHAR c;
 208: {
 209: 
 210:     c =- 'a';
 211:     opts[c] = optstk[c] & 1;
 212:     optstk[c] =>> 1;
 213: #ifdef PI0
 214:     send(ROPOP, c);
 215: #endif
 216: }

Defined functions

any defined in line 182; used 5 times
calloc defined in line 109; used 1 times
dotted defined in line 20; used 4 times
gettime defined in line 46; used 1 times
inpflist defined in line 81; used 5 times
myctime defined in line 58; used 2 times
opop defined in line 206; used 2 times
opush defined in line 193; used 2 times
strcmp defined in line 128; used 2 times
togopt defined in line 33; used 3 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 879
Valid CSS Valid XHTML 1.0 Strict