diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-15 08:01:00 -0800 |
commit | 0871bffae307e0553e0c5186336189e8b55cf6a6 (patch) | |
tree | 4571d1563fe33a53a57fea1c35fb668b9d33265f /src/base/cmd | |
parent | f936cc0680c98ffe51b3a1716c996072d5dbf76c (diff) | |
download | abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2 abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip |
Version abc90215
Diffstat (limited to 'src/base/cmd')
-rw-r--r-- | src/base/cmd/cmd.c | 24 | ||||
-rw-r--r-- | src/base/cmd/cmd.h | 19 | ||||
-rw-r--r-- | src/base/cmd/cmdAlias.c | 8 | ||||
-rw-r--r-- | src/base/cmd/cmdApi.c | 2 | ||||
-rw-r--r-- | src/base/cmd/cmdFlag.c | 6 | ||||
-rw-r--r-- | src/base/cmd/cmdUtils.c | 39 |
6 files changed, 44 insertions, 54 deletions
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index 459d82c9..ca36db10 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -118,7 +118,7 @@ void Cmd_End( Abc_Frame_t * pAbc ) // st_free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree ); // st_free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree ); -// st_free_table( pAbc->tFlags, free, free ); +// st_free_table( pAbc->tFlags, ABC_FREE, ABC_FREE ); st_foreach_item( pAbc->tCommands, gen, (char **)&pKey, (char **)&pValue ) CmdCommandFree( (Abc_Command *)pValue ); @@ -129,11 +129,11 @@ void Cmd_End( Abc_Frame_t * pAbc ) st_free_table( pAbc->tAliases ); st_foreach_item( pAbc->tFlags, gen, (char **)&pKey, (char **)&pValue ) - free( pKey ), free( pValue ); + ABC_FREE( pKey ), ABC_FREE( pValue ); st_free_table( pAbc->tFlags ); for ( i = 0; i < pAbc->aHistory->nSize; i++ ) - free( pAbc->aHistory->pArray[i] ); + ABC_FREE( pAbc->aHistory->pArray[i] ); Vec_PtrFree( pAbc->aHistory ); } @@ -586,7 +586,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) fp = CmdFileOpen( pAbc, argv[lp_file_index], "r", &real_filename, silent ); if ( fp == NULL ) { - FREE( real_filename ); + ABC_FREE( real_filename ); return !silent; /* error return if not silent */ } @@ -677,7 +677,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) } ( void ) fclose( fp ); } - FREE( real_filename ); + ABC_FREE( real_filename ); } while ( ( status == 0 ) && ( lp_count <= 0 ) ); @@ -734,8 +734,8 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) key = argv[1]; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE( key ); - FREE( value ); + ABC_FREE( key ); + ABC_FREE( value ); } flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] ); @@ -832,8 +832,8 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) key = argv[i]; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE( key ); - FREE( value ); + ABC_FREE( key ); + ABC_FREE( value ); } } return 0; @@ -1108,7 +1108,7 @@ extern long _findfirst( char *filespec, struct _finddata_t *fileinfo ); extern int _findnext( long handle, struct _finddata_t *fileinfo ); extern int _findclose( long handle ); -extern char * _getcwd( char * buffer, int maxlen ); +//extern char * _getcwd( char * buffer, int maxlen ); extern int _chdir( const char *dirname ); /**Function************************************************************* @@ -1561,7 +1561,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) // set the original spec of the new network if ( pNtk->pSpec ) { - FREE( pNtkNew->pSpec ); + ABC_FREE( pNtkNew->pSpec ); pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); } // replace the current network @@ -1704,7 +1704,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) // set the original spec of the new network if ( pNtk->pSpec ) { - FREE( pNtkNew->pSpec ); + ABC_FREE( pNtkNew->pSpec ); pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); } // replace the current network diff --git a/src/base/cmd/cmd.h b/src/base/cmd/cmd.h index 143f57cd..61c7264b 100644 --- a/src/base/cmd/cmd.h +++ b/src/base/cmd/cmd.h @@ -21,10 +21,6 @@ #ifndef __CMD_H__ #define __CMD_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -40,17 +40,6 @@ extern "C" { typedef struct MvCommand Abc_Command; // one command typedef struct MvAlias Abc_Alias; // one alias -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdAlias.c b/src/base/cmd/cmdAlias.c index 0ec3feea..20ee0694 100644 --- a/src/base/cmd/cmdAlias.c +++ b/src/base/cmd/cmdAlias.c @@ -44,10 +44,10 @@ void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** arg Abc_Alias * pAlias; int fStatus, i; - pAlias = ALLOC(Abc_Alias, 1); + pAlias = ABC_ALLOC(Abc_Alias, 1); pAlias->sName = Extra_UtilStrsav(sName); pAlias->argc = argc; - pAlias->argv = ALLOC(char *, pAlias->argc); + pAlias->argv = ABC_ALLOC(char *, pAlias->argc); for(i = 0; i < argc; i++) pAlias->argv[i] = Extra_UtilStrsav(argv[i]); fStatus = st_insert( pAbc->tAliases, pAlias->sName, (char *) pAlias ); @@ -109,8 +109,8 @@ char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand ) void CmdCommandAliasFree( Abc_Alias * pAlias ) { CmdFreeArgv( pAlias->argc, pAlias->argv ); - FREE(pAlias->sName); - FREE(pAlias); + ABC_FREE(pAlias->sName); + ABC_FREE(pAlias); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdApi.c b/src/base/cmd/cmdApi.c index 71db1846..ae1949a6 100644 --- a/src/base/cmd/cmdApi.c +++ b/src/base/cmd/cmdApi.c @@ -56,7 +56,7 @@ void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFu } // create the new command - pCommand = ALLOC( Abc_Command, 1 ); + pCommand = ABC_ALLOC( Abc_Command, 1 ); pCommand->sName = Extra_UtilStrsav( sName ); pCommand->sGroup = Extra_UtilStrsav( sGroup ); pCommand->pFunc = pFunc; diff --git a/src/base/cmd/cmdFlag.c b/src/base/cmd/cmdFlag.c index 993f2a49..d25861c0 100644 --- a/src/base/cmd/cmdFlag.c +++ b/src/base/cmd/cmdFlag.c @@ -69,7 +69,7 @@ void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value ) newValue = Extra_UtilStrsav(""); // newValue = NULL; if ( st_delete(pAbc->tFlags, &key, &oldValue) ) - FREE(oldValue); + ABC_FREE(oldValue); st_insert( pAbc->tFlags, key, newValue ); } @@ -90,8 +90,8 @@ void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, char * key ) return; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE(key); - FREE(value); + ABC_FREE(key); + ABC_FREE(value); } } diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 8c3fd38c..1e4c7700 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -210,7 +210,7 @@ char * CmdSplitLine( Abc_Frame_t * pAbc, char *sCommand, int *argc, char ***argv if ( start == p ) break; - new_arg = ALLOC( char, p - start + 1 ); + new_arg = ABC_ALLOC( char, p - start + 1 ); j = 0; for ( i = 0; i < p - start; i++ ) { @@ -270,13 +270,13 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) { stopit = 1; } - FREE( argv[0] ); + ABC_FREE( argv[0] ); added = alias->argc - 1; /* shift all the arguments to the right */ if ( added != 0 ) { - argv = REALLOC( char *, argv, argc + added ); + argv = ABC_REALLOC( char *, argv, argc + added ); for ( i = argc - 1; i >= 1; i-- ) { argv[i + added] = argv[i]; @@ -330,7 +330,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) added = newc - 1; if ( added != 0 ) { - argv = REALLOC( char *, argv, argc + added ); + argv = ABC_REALLOC( char *, argv, argc + added ); for ( j = argc - 1; j > offset; j-- ) { argv[j + added] = argv[j]; @@ -341,14 +341,14 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) { argv[j + offset] = newv[j]; } - FREE( newv ); + ABC_FREE( newv ); offset += added; } if ( subst == 1 ) { for ( i = offset; i < argc; i++ ) { - FREE( argv[i] ); + ABC_FREE( argv[i] ); } argc = offset; } @@ -422,12 +422,12 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi sPathAll = Extra_UtilStrsav( sPathUsr ); } else { - sPathAll = ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 ); + sPathAll = ABC_ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 ); sprintf( sPathAll, "%s:%s",sPathUsr, sPathLib ); } if ( sPathAll != NULL ) { sRealName = Extra_UtilFileSearch(sFileName, sPathAll, "r"); - FREE( sPathAll ); + ABC_FREE( sPathAll ); } } if (sRealName == NULL) { @@ -442,7 +442,7 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi if ( pFileNameReal ) *pFileNameReal = sRealName; else - FREE(sRealName); + ABC_FREE(sRealName); return pFile; } @@ -462,8 +462,8 @@ void CmdFreeArgv( int argc, char **argv ) { int i; for ( i = 0; i < argc; i++ ) - FREE( argv[i] ); - FREE( argv ); + ABC_FREE( argv[i] ); + ABC_FREE( argv ); } /**Function************************************************************* @@ -481,8 +481,9 @@ char ** CmdAddToArgv( int argc, char ** argv ) { char ** argv2; int i; - argv2 = ALLOC( char *, argc + 1 ); + argv2 = ABC_ALLOC( char *, argc + 1 ); argv2[0] = Extra_UtilStrsav( "read" ); +// argv2[0] = Extra_UtilStrsav( "&r" ); for ( i = 0; i < argc; i++ ) argv2[i+1] = Extra_UtilStrsav( argv[i] ); return argv2; @@ -501,9 +502,9 @@ char ** CmdAddToArgv( int argc, char ** argv ) ***********************************************************************/ void CmdCommandFree( Abc_Command * pCommand ) { - free( pCommand->sGroup ); - free( pCommand->sName ); - free( pCommand ); + ABC_FREE( pCommand->sGroup ); + ABC_FREE( pCommand->sName ); + ABC_FREE( pCommand ); } @@ -530,7 +531,7 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll ) // put all commands into one array nCommands = st_count( pAbc->tCommands ); - ppCommands = ALLOC( Abc_Command *, nCommands ); + ppCommands = ABC_ALLOC( Abc_Command *, nCommands ); i = 0; st_foreach_item( pAbc->tCommands, gen, &key, &value ) { @@ -580,7 +581,7 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll ) iCom = 1; } fprintf( pAbc->Out, "\n" ); - FREE( ppCommands ); + ABC_FREE( ppCommands ); } /**Function************************************************************* @@ -658,7 +659,7 @@ void CmdPrintTable( st_table * tTable, int fAliases ) int nNames, i; // collect keys in the array - ppNames = ALLOC( char *, st_count(tTable) ); + ppNames = ABC_ALLOC( char *, st_count(tTable) ); nNames = 0; st_foreach_item( tTable, gen, &key, &value ) ppNames[nNames++] = key; @@ -676,7 +677,7 @@ void CmdPrintTable( st_table * tTable, int fAliases ) else fprintf( stdout, "%-15s %-15s\n", ppNames[i], value ); } - free( ppNames ); + ABC_FREE( ppNames ); } //////////////////////////////////////////////////////////////////////// |