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

Defined functions

Perror defined in line 103; never used
any defined in line 186; never used
calloc defined in line 112; never used
copy defined in line 172; never used
dotted defined in line 22; never used
gettime defined in line 48; never used
inpflist defined in line 84; never used
myctime defined in line 60; never used
opop defined in line 210; never used
opush defined in line 197; never used
strcmp defined in line 132; used 1 times
  • in line 91
strcpy defined in line 147; never used
togopt defined in line 35; never used
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 822
Valid CSS Valid XHTML 1.0 Strict