Annotation of researchv10no/cmd/spitbol/lenfnm.c, revision 1.1

1.1     ! root        1: 
        !             2: /*
        !             3:        lenfnm( scptr ) returns the length of the filename in the
        !             4:        passed scblk.  the filename may take on a number of forms:
        !             5: 
        !             6:        'filename'      'filename options'      ' options'
        !             7: 
        !             8:        '!*commandstring'
        !             9: 
        !            10:        '!*commandstring*'
        !            11: 
        !            12:        '!*command string* options'
        !            13: */
        !            14: 
        !            15: #include "spitblks.h"
        !            16: 
        !            17: int    lenfnm( scptr )
        !            18: 
        !            19: struct scblk   *scptr;
        !            20: 
        !            21: {
        !            22:        int     cnt = 0,
        !            23:                len;
        !            24:        char    *cp, delim;
        !            25: 
        !            26:        len     = scptr -> len;
        !            27:        if ( len == 0 )
        !            28:                return  0;
        !            29: 
        !            30:        cp      = scptr -> str;
        !            31: 
        !            32:        if ( *cp == '!' ) {
        !            33:                if ( len < 3 )
        !            34:                        return  -1;
        !            35:                delim   = *(cp + ++cnt);
        !            36:                if ( *(cp + ++cnt) == delim )
        !            37:                        return  -1;
        !            38:                while ( cnt < len )
        !            39:                        if ( *(cp + cnt++) == delim )
        !            40:                                break;
        !            41:        } else {
        !            42:                if ( *cp == ' ' )
        !            43:                        return  0;
        !            44:                while ( cnt < len )
        !            45:                        if ( *(cp + cnt++) == ' ' )
        !            46:                                break;
        !            47:                if ( cp[cnt - 1] == ' ' )
        !            48:                        --cnt;
        !            49:        }
        !            50:        return  cnt;
        !            51: }
        !            52: 

unix.superglobalmegacorp.com

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