Annotation of researchv10no/cmd/mk/src/word.c, revision 1.1.1.1

1.1       root        1: #include       "mk.h"
                      2: 
                      3: Word *
                      4: newword(s)
                      5:        char *s;
                      6: {
                      7:        register Word *w = (Word *)Malloc(sizeof(Word));
                      8: 
                      9:        w->s = strdup(s);
                     10:        w->next = 0;
                     11:        return(w);
                     12: }
                     13: 
                     14: Word *
                     15: stow(s)
                     16:        char *s;
                     17: {
                     18:        char save;
                     19:        register char *t;
                     20:        Word *head, *w;
                     21: 
                     22:        w = head = newword("");
                     23:        while(*s){
                     24:                while(SEP(*s))
                     25:                        s++;
                     26:                if(*s == 0) break;
                     27:                for(t = s; *t && !SEP(*t); t++)
                     28:                        ;
                     29:                save = *t;
                     30:                *t = 0;
                     31:                w->next = newword(s);
                     32:                w = w->next;
                     33:                *t = save;
                     34:                s = t;
                     35:        }
                     36:        w = head->next;
                     37:        delword(head);
                     38:        return(w);
                     39: }
                     40: 
                     41: char *
                     42: wtos(w)
                     43:        register Word *w;
                     44: {
                     45:        static char buf[BIGBLOCK];
                     46:        register char *s = buf;
                     47:        register char *t;
                     48: 
                     49:        for(; w; w = w->next){
                     50:                for(t = w->s; *t;)
                     51:                        *s++ = *t++;
                     52:                if(w->next)
                     53:                        *s++ = ' ';
                     54:        }
                     55:        *s = 0;
                     56:        return(strdup(buf));
                     57: }
                     58: 
                     59: delword(w)
                     60:        Word *w;
                     61: {
                     62:        free(w->s);
                     63:        free((char *)w);
                     64: }
                     65: 
                     66: dumpw(s, w)
                     67:        char *s;
                     68:        Word *w;
                     69: {
                     70:        Fprint(1, "%s", s);
                     71:        for(; w; w = w->next)
                     72:                Fprint(1, " '%s'", w->s);
                     73:        Fputc(1, '\n');
                     74: }

unix.superglobalmegacorp.com

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