Annotation of 43BSD/usr.bin/refer/hunt3.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char *sccsid = "@(#)hunt3.c     4.2 (Berkeley) 6/28/83";
        !             3: #endif
        !             4: 
        !             5: #include "refer..c"
        !             6: #define BSIZ 250
        !             7: 
        !             8: getq(v)
        !             9: char *v[];
        !            10: {
        !            11:        static char buff[BSIZ];
        !            12:        static int eof = 0;
        !            13:        extern char *sinput;
        !            14:        char *p;
        !            15:        int c, n = 0, las = 0;
        !            16:        if (eof) return(-1);
        !            17:        p = buff;
        !            18:        while ( (c = (sinput ? *sinput++ : getchar()) ) > 0)
        !            19:        {
        !            20:                if (c== '\n')
        !            21:                        break;
        !            22:                if (isalpha(c) || isdigit(c))
        !            23:                {
        !            24:                        if (las==0)
        !            25:                        {
        !            26:                                v[n++] = p;
        !            27:                                las=1;
        !            28:                        }
        !            29:                        if (las++ <= 6)
        !            30:                                *p++ = c;
        !            31:                }
        !            32:                else
        !            33:                {
        !            34:                        if (las>0)
        !            35:                                *p++ = 0;
        !            36:                        las=0;
        !            37:                }
        !            38:        }
        !            39:        *p=0;
        !            40:        if (p > buff + BSIZ)
        !            41:                fprintf(stderr, "query long than %d characters\n", BSIZ);
        !            42:        assert(p < buff + BSIZ);
        !            43:        if (sinput==0 && c<= 0) eof=1;
        !            44: # if D1
        !            45:        fprintf(stderr, "no. keys %d\n",n);
        !            46:        for(c=0; c<n; c++)
        !            47:                fprintf(stderr, "keys X%sX\n", v[c]);
        !            48: # endif
        !            49:        return(n);
        !            50: }

unix.superglobalmegacorp.com

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