diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2005-09-05 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2005-09-05 08:01:00 -0700 |
commit | 1260d20cc05fe2d21088cc047c460e85ccdb3b14 (patch) | |
tree | f10ccc3333f78b6e2e089a88c8cf61a47b2f2dcd /src/base/cmd/cmdUtils.c | |
parent | 33012d9530c40817e1fc5230b3e663f7690b2e94 (diff) | |
download | abc-1260d20cc05fe2d21088cc047c460e85ccdb3b14.tar.gz abc-1260d20cc05fe2d21088cc047c460e85ccdb3b14.tar.bz2 abc-1260d20cc05fe2d21088cc047c460e85ccdb3b14.zip |
Version abc50905
Diffstat (limited to 'src/base/cmd/cmdUtils.c')
-rw-r--r-- | src/base/cmd/cmdUtils.c | 65 |
1 files changed, 58 insertions, 7 deletions
diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 67a290a2..71396d3e 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -110,7 +110,7 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) // get the backup network if the command is going to change the network if ( pCommand->fChange ) { - if ( pAbc->pNtkCur ) + if ( pAbc->pNtkCur && Abc_FrameIsFlagEnabled( "backup" ) ) { pNetCopy = Abc_NtkDup( pAbc->pNtkCur ); Abc_FrameSetCurrentNetwork( pAbc, pNetCopy ); @@ -122,15 +122,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) // execute the command clk = util_cpu_time(); - pFunc = ( int (*)( Abc_Frame_t *, int, char ** ) ) pCommand->pFunc; + pFunc = (int (*)(Abc_Frame_t *, int, char **))pCommand->pFunc; fError = (*pFunc)( pAbc, argc, argv ); pAbc->TimeCommand += (util_cpu_time() - clk); -// if ( !fError && pCommand->fChange && pAbc->pNtkCur ) -// { -// Cmd_HistoryAddSnapshot(pAbc, pAbc->pNet); -// } - // automatic execution of arbitrary command after each command // usually this is a passive command ... if ( fError == 0 && !pAbc->fAutoexac ) @@ -592,6 +587,62 @@ int CmdCommandPrintCompare( Abc_Command ** ppC1, Abc_Command ** ppC2 ) assert( 0 ); return 0; } + +/**Function************************************************************* + + Synopsis [Comparision function used for sorting commands.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int CmdNamePrintCompare( char ** ppC1, char ** ppC2 ) +{ + return strcmp( *ppC1, *ppC2 ); +} + +/**Function************************************************************* + + Synopsis [Comparision function used for sorting commands.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void CmdPrintTable( st_table * tTable, int fAliases ) +{ + st_generator * gen; + char ** ppNames; + char * key, * value; + int nNames, i; + + // collect keys in the array + ppNames = ALLOC( char *, st_count(tTable) ); + nNames = 0; + st_foreach_item( tTable, gen, &key, &value ) + ppNames[nNames++] = key; + + // sort array by name + qsort( (void *)ppNames, nNames, sizeof(char *), + (int (*)(const void *, const void *))CmdNamePrintCompare ); + + // print in this order + for ( i = 0; i < nNames; i++ ) + { + st_lookup( tTable, ppNames[i], &value ); + if ( fAliases ) + CmdCommandAliasPrint( Abc_FrameGetGlobalFrame(), (Abc_Alias *)value ); + else + fprintf( stdout, "%-15s %-15s\n", ppNames[i], value ); + } + free( ppNames ); +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// |