Annotation of 43BSD/ucb/pascal/src/string.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.