Annotation of researchv10no/cmd/mk/export/var.c, revision 1.1.1.1

1.1       root        1: #include       "mk.h"
                      2: 
                      3: setvar(name, value)
                      4:        char *name;
                      5:        char *value;
                      6: {
                      7:        symlook(name, S_VAR, value)->value = value;
                      8:        symlook(name, S_MAKEVAR, "");
                      9: }
                     10: 
                     11: static char **nextv;
                     12: 
                     13: static void
                     14: vcopy(s)
                     15:        register Symtab *s;
                     16: {
                     17:        register char **p;
                     18:        extern char *myenv[];
                     19: 
                     20:        if(symlook(s->name, S_NOEXPORT, (char *)0))
                     21:                return;
                     22:        for(p = myenv; *p; p++)
                     23:                if(strcmp(*p, s->name) == 0) return;
                     24:        if(*nextv)
                     25:                free(*nextv);
                     26:        *nextv++ = envpr(s->name, s->value);
                     27: }
                     28: 
                     29: char **
                     30: vardump(p)
                     31:        char **p;
                     32: {
                     33:        nextv = p;
                     34:        symtraverse(S_VAR, vcopy);
                     35:        *nextv = 0;
                     36:        return(nextv);
                     37: }
                     38: 
                     39: static void
                     40: print1(s)
                     41:        register Symtab *s;
                     42: {
                     43:        Fprint(1, "\t%s='%s'\n", s->name, s->value);
                     44: }
                     45: 
                     46: dumpv(s)
                     47:        char *s;
                     48: {
                     49:        Fprint(1, "%s:\n", s);
                     50:        symtraverse(S_VAR, print1);
                     51: }
                     52: 
                     53: char *
                     54: envpr(name, value)
                     55:        register char *name;
                     56:        register char *value;
                     57: {
                     58:        char buf[BIGBLOCK];
                     59: 
                     60:        sprint(buf, "%s=", name);
                     61:        strcpy(strchr(buf, 0), value);
                     62:        return(strdup(buf));
                     63: }
                     64: 
                     65: #include       <ctype.h>
                     66: 
                     67: char *
                     68: shname(s)
                     69:        char *s;
                     70: {
                     71:        register unsigned char *a = (unsigned char *)s;
                     72: 
                     73:        /* always go one !! */
                     74:        a++;
                     75:        while(isalnum(*a) || (*a == '_')) a++;
                     76:        return((char *)a);
                     77: }

unix.superglobalmegacorp.com

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