Commit aa62165a by Baruch Sterin

main: allow the -c -C -q -f -F -s command line options to be repeated and the…

main: allow the -c -C -q -f -F -s command line options to be repeated and the commands they sepcify be executed in order instead of overriding each other
parent 211c7ebe
...@@ -81,7 +81,8 @@ static int TypeCheck( Abc_Frame_t * pAbc, const char * s); ...@@ -81,7 +81,8 @@ static int TypeCheck( Abc_Frame_t * pAbc, const char * s);
int Abc_RealMain( int argc, char * argv[] ) int Abc_RealMain( int argc, char * argv[] )
{ {
Abc_Frame_t * pAbc; Abc_Frame_t * pAbc;
char sCommandUsr[ABC_MAX_STR] = {0}, sCommandTmp[ABC_MAX_STR], sReadCmd[1000], sWriteCmd[1000]; Vec_Str_t* sCommandUsr = Vec_StrAlloc(1000);
char sCommandTmp[ABC_MAX_STR], sReadCmd[1000], sWriteCmd[1000];
const char * sOutFile, * sInFile; const char * sOutFile, * sInFile;
char * sCommand; char * sCommand;
int fStatus = 0; int fStatus = 0;
...@@ -143,32 +144,56 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -143,32 +144,56 @@ int Abc_RealMain( int argc, char * argv[] )
while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:S:hf:F:o:st:T:xb")) != EOF) { while ((c = Extra_UtilGetopt(argc, argv, "c:q:C:S:hf:F:o:st:T:xb")) != EOF) {
switch(c) { switch(c) {
case 'c': case 'c':
strcpy( sCommandUsr, globalUtilOptarg ); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrAppend(sCommandUsr, globalUtilOptarg );
fBatch = BATCH; fBatch = BATCH;
break; break;
case 'q': case 'q':
strcpy( sCommandUsr, globalUtilOptarg ); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrAppend(sCommandUsr, globalUtilOptarg );
fBatch = BATCH_QUIET; fBatch = BATCH_QUIET;
break; break;
case 'C': case 'C':
strcpy( sCommandUsr, globalUtilOptarg ); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrAppend(sCommandUsr, globalUtilOptarg );
fBatch = BATCH_THEN_INTERACTIVE; fBatch = BATCH_THEN_INTERACTIVE;
break; break;
case 'S': case 'S':
strcpy( sCommandUsr, globalUtilOptarg ); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrAppend(sCommandUsr, globalUtilOptarg );
fBatch = BATCH_SMT; fBatch = BATCH_SMT;
break; break;
case 'f': case 'f':
sprintf(sCommandUsr, "source %s", globalUtilOptarg); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrPrintF(sCommandUsr, "source %s", globalUtilOptarg );
fBatch = BATCH; fBatch = BATCH;
break; break;
case 'F': case 'F':
sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); if( Vec_StrSize(sCommandUsr) > 0 )
{
Vec_StrAppend(sCommandUsr, " ; ");
}
Vec_StrPrintF(sCommandUsr, "source -x %s", globalUtilOptarg );
fBatch = BATCH; fBatch = BATCH;
break; break;
...@@ -230,9 +255,11 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -230,9 +255,11 @@ int Abc_RealMain( int argc, char * argv[] )
} }
} }
Vec_StrPush(sCommandUsr, '\0');
if ( fBatch == BATCH_SMT ) if ( fBatch == BATCH_SMT )
{ {
Wlc_StdinProcessSmt( pAbc, sCommandUsr ); Wlc_StdinProcessSmt( pAbc, Vec_StrArray(sCommandUsr) );
Abc_Stop(); Abc_Stop();
return 0; return 0;
} }
...@@ -242,8 +269,8 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -242,8 +269,8 @@ int Abc_RealMain( int argc, char * argv[] )
extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit ); extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit );
pAbc->pGia = Gia_ManFromBridge( stdin, NULL ); pAbc->pGia = Gia_ManFromBridge( stdin, NULL );
} }
else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && sCommandUsr[0] ) else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && Vec_StrSize(sCommandUsr)>0 )
Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr ); Abc_Print( 1, "ABC command line: \"%s\".\n\n", Vec_StrArray(sCommandUsr) );
if ( fBatch!=INTERACTIVE ) if ( fBatch!=INTERACTIVE )
{ {
...@@ -280,7 +307,7 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -280,7 +307,7 @@ int Abc_RealMain( int argc, char * argv[] )
if ( fStatus == 0 ) if ( fStatus == 0 )
{ {
/* cmd line contains `source <file>' */ /* cmd line contains `source <file>' */
fStatus = Cmd_CommandExecute( pAbc, sCommandUsr ); fStatus = Cmd_CommandExecute( pAbc, Vec_StrArray(sCommandUsr) );
if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile ) if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile )
{ {
sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile ); sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile );
...@@ -292,9 +319,10 @@ int Abc_RealMain( int argc, char * argv[] ) ...@@ -292,9 +319,10 @@ int Abc_RealMain( int argc, char * argv[] )
fBatch = INTERACTIVE; fBatch = INTERACTIVE;
pAbc->fBatchMode = 0; pAbc->fBatchMode = 0;
} }
} }
Vec_StrFreeP(&sCommandUsr);
if ( fBatch==INTERACTIVE ) if ( fBatch==INTERACTIVE )
{ {
// start interactive mode // start interactive mode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment