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

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

unix.superglobalmegacorp.com

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