diff options
Diffstat (limited to 'src/base/cmd')
-rw-r--r-- | src/base/cmd/cmdApi.c | 2 | ||||
-rw-r--r-- | src/base/cmd/cmdInt.h | 3 | ||||
-rw-r--r-- | src/base/cmd/cmdUtils.c | 43 |
3 files changed, 42 insertions, 6 deletions
diff --git a/src/base/cmd/cmdApi.c b/src/base/cmd/cmdApi.c index 7167e22b..71db1846 100644 --- a/src/base/cmd/cmdApi.c +++ b/src/base/cmd/cmdApi.c @@ -90,7 +90,7 @@ int Cmd_CommandExecute( Abc_Frame_t * pAbc, char * sCommand ) loop = 0; fStatus = CmdApplyAlias( pAbc, &argc, &argv, &loop ); if ( fStatus == 0 ) - fStatus = CmdCommandDispatch( pAbc, argc, argv ); + fStatus = CmdCommandDispatch( pAbc, &argc, &argv ); CmdFreeArgv( argc, argv ); } while ( fStatus == 0 && *sCommandNext != '\0' ); diff --git a/src/base/cmd/cmdInt.h b/src/base/cmd/cmdInt.h index c082bd94..3a6a2803 100644 --- a/src/base/cmd/cmdInt.h +++ b/src/base/cmd/cmdInt.h @@ -65,12 +65,13 @@ extern void CmdCommandAliasPrint( Abc_Frame_t * pAbc, Abc_Alias * pAlias ) extern char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand ); extern void CmdCommandAliasFree( Abc_Alias * p ); /*=== cmdUtils.c =======================================================*/ -extern int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char ** argv ); +extern int CmdCommandDispatch( Abc_Frame_t * pAbc, int * argc, char *** argv ); extern char * CmdSplitLine( Abc_Frame_t * pAbc, char * sCommand, int * argc, char *** argv ); extern int CmdApplyAlias( Abc_Frame_t * pAbc, int * argc, char *** argv, int * loop ); extern char * CmdHistorySubstitution( Abc_Frame_t * pAbc, char * line, int * changed ); extern FILE * CmdFileOpen( Abc_Frame_t * pAbc, char * sFileName, char * sMode, char ** pFileNameReal, int silent ); extern void CmdFreeArgv( int argc, char ** argv ); +extern char ** CmdAddToArgv( int argc, char ** argv ); extern void CmdCommandFree( Abc_Command * pCommand ); extern void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll ); extern void CmdPrintTable( st_table * tTable, int fAliases ); diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 6b4bdcbe..8c3fd38c 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -85,8 +85,12 @@ int cmdCheckShellEscape( Abc_Frame_t * pAbc, int argc, char ** argv) SeeAlso [] ***********************************************************************/ -int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) +int CmdCommandDispatch( Abc_Frame_t * pAbc, int * pargc, char *** pargv ) { + int argc = *pargc; + char ** argv = *pargv; + char ** argv2; + Abc_Ntk_t * pNetCopy; int (*pFunc) ( Abc_Frame_t *, int, char ** ); Abc_Command * pCommand; @@ -103,8 +107,17 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) // get the command if ( !st_lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) ) { // the command is not in the table - fprintf( pAbc->Err, "** cmd error: unknown command '%s'\n", argv[0] ); - return 1; +// fprintf( pAbc->Err, "** cmd error: unknown command '%s'\n", argv[0] ); +// return 1; + // add command 'read' assuming that this is the file name + argv2 = CmdAddToArgv( argc, argv ); + CmdFreeArgv( argc, argv ); + argc = argc+1; + argv = argv2; + *pargc = argc; + *pargv = argv; + if ( !st_lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) ) + assert( 0 ); } // get the backup network if the command is going to change the network @@ -303,7 +316,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) fError = CmdApplyAlias( pAbc, &newc, &newv, loop ); if ( fError == 0 ) { - fError = CmdCommandDispatch( pAbc, newc, newv ); + fError = CmdCommandDispatch( pAbc, &newc, &newv ); } CmdFreeArgv( newc, newv ); } @@ -455,6 +468,28 @@ void CmdFreeArgv( int argc, char **argv ) /**Function************************************************************* + Synopsis [Frees the previously allocated argv array.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char ** CmdAddToArgv( int argc, char ** argv ) +{ + char ** argv2; + int i; + argv2 = ALLOC( char *, argc + 1 ); + argv2[0] = Extra_UtilStrsav( "read" ); + for ( i = 0; i < argc; i++ ) + argv2[i+1] = Extra_UtilStrsav( argv[i] ); + return argv2; +} + +/**Function************************************************************* + Synopsis [Frees the previously allocated command.] Description [] |