diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index 4a34f9cfd..d1408b6c1 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -436,7 +436,7 @@ int CmdCommandAbcrc( Abc_Frame_t * pAbc, int argc, char **argv ) ******************************************************************************/ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv ) { - char * pName; + char * pName, * pStr = NULL; int i, c; int nPrints = 20; Extra_UtilGetoptReset(); @@ -453,11 +453,19 @@ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv ) if ( argc > globalUtilOptind + 1 ) goto usage; // get the number from the command line - if ( argc == globalUtilOptind + 1 ) - nPrints = atoi(argv[globalUtilOptind]); + pStr = argc == globalUtilOptind+1 ? argv[globalUtilOptind] : NULL; + if ( pStr && pStr[0] >= '1' && pStr[0] <= '9' ) + nPrints = atoi(pStr), pStr = NULL; // print the commands - Vec_PtrForEachEntryStart( char *, pAbc->aHistory, pName, i, Abc_MaxInt(0, Vec_PtrSize(pAbc->aHistory)-nPrints) ) - fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName ); + if ( pStr == NULL ) { + Vec_PtrForEachEntryStart( char *, pAbc->aHistory, pName, i, Abc_MaxInt(0, Vec_PtrSize(pAbc->aHistory)-nPrints) ) + fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName ); + } + else { + Vec_PtrForEachEntry( char *, pAbc->aHistory, pName, i ) + if ( strstr(pName, pStr) ) + fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName ); + } return 0; usage: diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c index 0aaf6d5cf..b0981630c 100644 --- a/src/base/cmd/cmdHist.c +++ b/src/base/cmd/cmdHist.c @@ -49,8 +49,8 @@ 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 = 1000; // when saving a file, save no more than this number of last entries + 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 char Buffer[ABC_MAX_STR]; int Len; if ( p->fBatchMode )