abc/src/base/ver/verStream.c
/**Function*************************************************************

  Synopsis    [Returns current word delimited by the set of symbols.]

  Description [Modifies the stream by inserting 0 at the first encounter
  of one of the symbols in the list.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Returns current word delimited by the set of symbols.]

Description [Modifies the stream by inserting 0 at the first encounter
of one of the symbols in the list.]




Function Synopsis [ Returns current word delimited by the set of symbols . ] Description [ Modifies the stream by inserting 0 at the first encounter of one of the symbols in the list . ]
char * Ver_StreamGetWord( Ver_Stream_t * p, char * pCharsToStop )
{
    char * pChar, * pTemp;
    if ( p->fStop )
        return NULL;
    assert( pCharsToStop != NULL );
    if ( p->pBufferCur > p->pBufferStop )
        Ver_StreamReload( p );
    p->nChars = 0;
    for ( pChar = p->pBufferCur; pChar < p->pBufferEnd; pChar++ )
    {
        for ( pTemp = pCharsToStop; *pTemp; pTemp++ )
            if ( *pChar == *pTemp )
                break;
        if ( *pTemp == 0 ) 
        {
            p->pChars[p->nChars++] = *pChar;
            if ( p->nChars == VER_WORD_SIZE )
            {
                printf( "Ver_StreamGetWord(): The buffer size is exceeded.\n" );
                return NULL;
            }
            if ( *pChar == '\n' )
                p->nLineCounter++;
            continue;
        }
        p->pBufferCur = pChar;
        p->pChars[p->nChars] = 0;
        return p->pChars;
    }
    if ( p->pBufferStop == p->pBufferEnd ) 
    {
        p->fStop = 1;
        p->pChars[p->nChars] = 0;
        return p->pChars;
    }
    printf( "Ver_StreamGetWord() failed to parse the file \"%s\".\n", p->pFileName );
    return NULL;
}
char * Ver_StreamGetWord ( Ver_Stream_t * p , char * pCharsToStop ) { char * pChar , * pTemp ; if ( p -> fStop ) return NULL ; assert ( pCharsToStop != NULL ) ; if ( p -> pBufferCur > p -> pBufferStop ) Ver_StreamReload ( p ) ; p -> nChars = 0 ; for ( pChar = p -> pBufferCur ; pChar < p -> pBufferEnd ; pChar ++ ) { for ( pTemp = pCharsToStop ; * pTemp ; pTemp ++ ) if ( * pChar == * pTemp ) break ; if ( * pTemp == 0 ) { p -> pChars [ p -> nChars ++ ] = * pChar ; if ( p -> nChars == VER_WORD_SIZE ) { printf ( " \n " ) ; return NULL ; } if ( * pChar == ' \n ' ) p -> nLineCounter ++ ; continue ; } p -> pBufferCur = pChar ; p -> pChars [ p -> nChars ] = 0 ; return p -> pChars ; } if ( p -> pBufferStop == p -> pBufferEnd ) { p -> fStop = 1 ; p -> pChars [ p -> nChars ] = 0 ; return p -> pChars ; } printf ( " \" \" \n " , p -> pFileName ) ; return NULL ; }
Function
Synopsis    [Returns current word delimited by the set of symbols.]
Function Synopsis [ Returns current word delimited by the set of symbols . ]
// check if the new data should to be loaded // skip the symbols // skip symbols as long as they are NOT in the list // pChar is not found in the list // count the lines // the symbol is found - move the position, set the word end, return the word // the file is finished or the last part continued  // through VER_OFFSET_SIZE chars till the end of the buffer // end of file