abc/src/bool/lucky/luckyRead.c
// determine the number of variables by reading the first line
// determine the number of functions by counting the lines
determine the number of variables by reading the first line
determine the number of functions by counting the lines
determine the number of variables by reading the first line determine the number of functions by counting the lines
static void Abc_TruthGetParams( char * pFileName, int * pnVars, int * pnTruths )
{
    char * pContents;
    int i, nVars, nLines;
    if ( pnVars )
        *pnVars = 0;
    if ( pnTruths )
        *pnTruths = 0;
    pContents = Abc_FileRead( pFileName );
    if ( pContents == NULL )
        return;
    for ( i = 0; pContents[i]; i++ )
        if ( pContents[i] == ' ' || pContents[i] == '\n' || pContents[i] == '\r' )
            break;
    if ( pContents[i] == 0 )
        printf( "Strange, the input file does not have spaces and new-lines...\n" );
    if ( pContents[0] == '0' && pContents[1] == 'x' )
        i = i - 2;
    for ( nVars = 0; nVars < 32; nVars++ )
        if ( 4 * i == (1 << nVars) ) 
            break;
    if ( nVars < 2 || nVars > 16 )
    {
        printf( "Does not look like the input file contains truth tables...\n" );
        return;
    }
    if ( pnVars )
        *pnVars = nVars;
    nLines = 0;
    for ( i = 0; pContents[i]; i++ )
        nLines += (pContents[i] == '\n');
    if ( pnTruths )
        *pnTruths = nLines;
}
static void Abc_TruthGetParams ( char * pFileName , int * pnVars , int * pnTruths ) { char * pContents ; int i , nVars , nLines ; if ( pnVars ) * pnVars = 0 ; if ( pnTruths ) * pnTruths = 0 ; pContents = Abc_FileRead ( pFileName ) ; if ( pContents == NULL ) return ; for ( i = 0 ; pContents [ i ] ; i ++ ) if ( pContents [ i ] == ' ' || pContents [ i ] == ' \n ' || pContents [ i ] == ' \r ' ) break ; if ( pContents [ i ] == 0 ) printf ( " \n " ) ; if ( pContents [ 0 ] == ' ' && pContents [ 1 ] == ' ' ) i = i - 2 ; for ( nVars = 0 ; nVars < 32 ; nVars ++ ) if ( 4 * i == ( 1 << nVars ) ) break ; if ( nVars < 2 || nVars > 16 ) { printf ( " \n " ) ; return ; } if ( pnVars ) * pnVars = nVars ; nLines = 0 ; for ( i = 0 ; pContents [ i ] ; i ++ ) nLines += ( pContents [ i ] == ' \n ' ) ; if ( pnTruths ) * pnTruths = nLines ; }
determine the number of variables by reading the first line
determine the number of functions by counting the lines
determine the number of variables by reading the first line determine the number of functions by counting the lines
// prepare the output  // read data from file // count the number of symbols before the first space or new-line // (note that on Windows symbols '\r' can be inserted before each '\n') // account for the fact that truth tables may have "0x" at the beginning of each line // determine the number of variables // the number of bits equal to the size of truth table // determine the number of functions by counting the lines