Annotation of researchv10no/cmd/mk/export/gen.c, revision 1.1

1.1     ! root        1: #include       "mk.h"
        !             2: 
        !             3: #define        NMATCH  10
        !             4: 
        !             5: gen(buf)
        !             6:        char *buf;
        !             7: {
        !             8:        char buf1[BIGBLOCK];
        !             9:        register char *src, *dest;
        !            10:        register char *s1, *s2, *s3, *s4;
        !            11:        regexp *prog;
        !            12:        regsubexp match[NMATCH];
        !            13:        char c;
        !            14: 
        !            15:        if((s1 = strchr(buf, '@')) == 0)
        !            16:                        return;
        !            17:        patrule = 0;
        !            18:        src = buf;
        !            19:        dest = buf1;
        !            20:        do {
        !            21:                while(src != s1)
        !            22:                        *dest++ = *src++;
        !            23:                if((s2 = strchr(s1+1, '@')) && (s3 = strchr(s2+1, '@'))
        !            24:                && (s4 = strchr(s3+1, '@')))
        !            25:                        ;
        !            26:                else {
        !            27:                        SYNERR(-1); Fprint(2, "expected four @\n");
        !            28:                        break;
        !            29:                }
        !            30:                src = s4+1;
        !            31:                *s2++ = *s3++ = *s4 = 0;
        !            32:                prog = regcomp(s2);
        !            33:                for(s2 = ++s1; ; s2 = s1){
        !            34:                        while((*s2 == ' ')||(*s2 == '\t'))
        !            35:                                s2++;
        !            36:                        if(s1 != s2) *dest++ = ' ';
        !            37:                        if(*s2 == 0) break;
        !            38:                        for(s1 = s2+1; *s1 && (*s1 != ' ') && (*s1 != '\t');)
        !            39:                                s1++;
        !            40:                        c = *s1;
        !            41:                        *s1 = 0;
        !            42:                        if(regexec(prog, s2, match, NMATCH)){
        !            43:                                regsub(s3, dest, match, NMATCH);
        !            44:                                while(*dest) dest++;
        !            45:                        } else
        !            46:                                while(*dest = *s2++)
        !            47:                                        dest++;
        !            48:                        *s1 = c;
        !            49:                }
        !            50:        } while(s1 = strchr(src, '@'));
        !            51:        while(*dest++ = *src++)
        !            52:                ;
        !            53:        memcpy(buf, buf1, (int)(dest-buf1));
        !            54: }

unix.superglobalmegacorp.com

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