diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c index b0981630c..b66f48c88 100644 --- a/src/base/cmd/cmdHist.c +++ b/src/base/cmd/cmdHist.c @@ -50,7 +50,7 @@ ABC_NAMESPACE_IMPL_START void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command ) { int nLastLooked = 10; // do not add history if the same entry appears among the last entries - int nLastSaved = 10000; // when saving a file, save no more than this number of last entries + int nLastSaved = 20000; // when saving a file, save no more than this number of last entries char Buffer[ABC_MAX_STR]; int Len; if ( p->fBatchMode ) @@ -117,6 +117,7 @@ void Cmd_HistoryRead( Abc_Frame_t * p ) Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) ); } fclose( pFile ); + p->iStartHistory = Vec_PtrSize(p->aHistory); #endif } @@ -137,16 +138,32 @@ void Cmd_HistoryWrite( Abc_Frame_t * p, int Limit ) FILE * pFile; char * pStr; int i; - pFile = fopen( "abc.history", "wb" ); - if ( pFile == NULL ) + if ( 1 ) { - Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" ); - return; + pFile = fopen( "abc.history", "ab" ); + if ( pFile == NULL ) + { + Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" ); + return; + } + Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, p->iStartHistory ) + fprintf( pFile, "%s\n", pStr ); + fclose( pFile ); + p->iStartHistory = Vec_PtrSize(p->aHistory); + } + if ( Vec_PtrSize(p->aHistory) > Limit + 1000 ) + { + pFile = fopen( "abc.history", "wb" ); + if ( pFile == NULL ) + { + Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" ); + return; + } + Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit ); + Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit ) + fprintf( pFile, "%s\n", pStr ); + fclose( pFile ); } - Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit ); - Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit ) - fprintf( pFile, "%s\n", pStr ); - fclose( pFile ); #endif } diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index db98fbb3e..73b3ad2dd 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -67,6 +67,7 @@ struct Abc_Frame_t_ st__table * tAliases; // the alias table st__table * tFlags; // the flag table Vec_Ptr_t * aHistory; // the command history + int iStartHistory; // beginning of the new history file // the functionality Abc_Ntk_t * pNtkCur; // the current network Abc_Ntk_t * pNtkBestDelay; // the current network