1: /*	@(#)string.c	2.3	SCCS id keyword	*/
   2: /* Copyright (c) 1979 Regents of the University of California */
   3: #
   4: /*
   5:  * pi - Pascal interpreter code translator
   6:  *
   7:  * Charles Haley, Bill Joy UCB
   8:  * Version 1.2 November 1978
   9:  *
  10:  * pxp - Pascal execution profiler
  11:  *
  12:  * Bill Joy UCB
  13:  * Version 1.2 November 1978
  14:  */
  15: 
  16: #include "whoami"
  17: #include "0.h"
  18: #ifndef PI01
  19: #ifndef PXP
  20: #include "send.h"
  21: #endif
  22: #endif
  23: 
  24: /*
  25:  * STRING SPACE DECLARATIONS
  26:  *
  27:  * Strng is the base of the current
  28:  * string space and strngp the
  29:  * base of the free area therein.
  30:  * Strp is the array of descriptors.
  31:  */
  32: #ifndef PI0
  33: STATIC  char strings[STRINC];
  34: STATIC  char *strng = strings;
  35: STATIC  char *strngp = strings;
  36: #else
  37: char    *strng, *strngp;
  38: #endif
  39: #ifndef PI01
  40: #ifndef PXP
  41: STATIC  char *strp[20];
  42: STATIC  char **stract strp;
  43: int strmax;
  44: #endif
  45: #endif
  46: 
  47: #ifndef PI01
  48: #ifndef PXP
  49: #ifndef PI0
  50: initstring()
  51: #else
  52: initstring(strings)
  53:     char *strings;
  54: #endif
  55: {
  56: 
  57:     *stract++ = strings;
  58: #ifdef PI0
  59:     strng = strngp = strings;
  60: #endif
  61:     strmax = STRINC * 2;
  62: }
  63: #endif
  64: #endif
  65: 
  66: /*
  67:  * Copy a string into the string area.
  68:  */
  69: char *
  70: savestr(cp)
  71:     register char *cp;
  72: {
  73:     register int i;
  74: 
  75:     i = strlen(cp) + 1;
  76:     if (strngp + i >= strng + STRINC) {
  77:         strngp = malloc(STRINC);
  78:         if (strngp == 0) {
  79:             yerror("Ran out of memory (string)");
  80:             pexit(DIED);
  81:         }
  82: #ifndef PI01
  83: #ifndef PXP
  84:         *stract++ = strngp;
  85:         strmax += STRINC;
  86: #endif
  87: #endif
  88:         strng = strngp;
  89:     }
  90:     strcpy(strngp, cp);
  91:     cp = strngp;
  92:     strngp = cp + i;
  93: #ifdef PI0
  94:     send(RSTRING, cp);
  95: #endif
  96:     return (cp);
  97: }
  98: 
  99: #ifndef PI1
 100: #ifndef PXP
 101: esavestr(cp)
 102:     char *cp;
 103: {
 104: 
 105: #ifdef PI0
 106:     send(REVENIT);
 107: #endif
 108:     strngp = ( (char *) ( ( (int) (strngp + 1) ) &~ 1 ) );
 109:     return (savestr(cp));
 110: }
 111: #endif
 112: #endif
 113: 
 114: #ifndef PI01
 115: #ifndef PXP
 116: soffset(cp)
 117:     register char *cp;
 118: {
 119:     register char **sp;
 120:     register int i;
 121: 
 122:     if (cp == NIL || cp == OCT || cp == HEX)
 123:         return (-cp);
 124:     for (i = STRINC, sp = strp; sp < stract; sp++) {
 125:         if (cp >= *sp && cp < (*sp + STRINC))
 126:             return (i + (cp - *sp));
 127:         i += STRINC;
 128:     }
 129:     i = nlfund(cp);
 130:     if (i != 0)
 131:         return (i);
 132:     panic("soffset");
 133: }
 134: #ifdef PI1
 135: sreloc(i)
 136:     register int i;
 137: {
 138: 
 139:     if (i == 0 || i == -OCT || i == -HEX)
 140:         return (-i);
 141:     if (i < STRINC) {
 142:         if (i >= INL)
 143:             panic("sreloc INL");
 144:         i = nl[i].symbol;
 145:         if (i == 0)
 146:             panic("sreloc nl[i]");
 147:         return (i);
 148:     }
 149:     if (i > strmax || i < 0)
 150:         panic("sreloc");
 151:     return (strp[(i / STRINC) - 1] + (i % STRINC));
 152: }
 153: 
 154: evenit()
 155: {
 156: 
 157:     strngp = (strngp + 1) &~ 1;
 158: }
 159: #endif
 160: #endif
 161: #endif

Defined functions

esavestr defined in line 101; used 1 times
evenit defined in line 154; never used
initstring defined in line 50; never used
soffset defined in line 116; never used
sreloc defined in line 135; never used

Defined variables

stract defined in line 42; used 3 times
strings defined in line 33; used 6 times
strmax defined in line 43; used 3 times
strng defined in line 37; used 3 times
strngp defined in line 37; used 13 times
strp defined in line 42; used 2 times
Last modified: 1986-06-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2236
Valid CSS Valid XHTML 1.0 Strict