ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmdHist.c File Reference
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "cmd.h"
#include "cmdInt.h"
Include dependency graph for cmdHist.c:

Go to the source code of this file.

Macros

#define ABC_USE_HISTORY   1
 DECLARATIONS ///.
 

Functions

void Cmd_HistoryAddCommand (Abc_Frame_t *p, const char *command)
 FUNCTION DEFINITIONS ///.
 
void Cmd_HistoryRead (Abc_Frame_t *p)
 
void Cmd_HistoryWrite (Abc_Frame_t *p, int Limit)
 
void Cmd_HistoryPrint (Abc_Frame_t *p, int Limit)
 

Macro Definition Documentation

◆ ABC_USE_HISTORY

#define ABC_USE_HISTORY   1

DECLARATIONS ///.

CFile****************************************************************

FileName [cmdHist.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures working with history.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmdHist.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 33 of file cmdHist.c.

Function Documentation

◆ Cmd_HistoryAddCommand()

void Cmd_HistoryAddCommand ( Abc_Frame_t * p,
const char * command )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file cmdHist.c.

51{
52 int nLastLooked = 10; // do not add history if the same entry appears among the last entries
53 int nLastSaved = 10000; // when saving a file, save no more than this number of last entries
54 char Buffer[ABC_MAX_STR];
55 int Len;
56 if ( p->fBatchMode )
57 return;
58 Len = strlen(command);
59 strcpy( Buffer, command );
60 if ( Len > 0 && Buffer[Len-1] == '\n' )
61 Buffer[Len-1] = 0;
62 if ( strlen(Buffer) > 3 &&
63 strncmp(Buffer,"set",3) &&
64 strncmp(Buffer,"unset",5) &&
65 strncmp(Buffer,"time",4) &&
66 strncmp(Buffer,"quit",4) &&
67 strncmp(Buffer,"alias",5) &&
68 strncmp(Buffer,"source abc.rc",13) &&
69 strncmp(Buffer,"source ..\\abc.rc",16) &&
70 strncmp(Buffer,"history",7) && strncmp(Buffer,"hi ", 3) && strcmp(Buffer,"hi") &&
71 Buffer[strlen(Buffer)-1] != '?' )
72 {
73 char * pStr = NULL;
74 int i, Start = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory) - nLastLooked );
75 // do not enter if the same command appears among nLastLooked commands
76 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Start )
77 if ( !strcmp(pStr, Buffer) )
78 break;
79 if ( i == Vec_PtrSize(p->aHistory) )
80 { // add new entry
81 Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
82 Cmd_HistoryWrite( p, nLastSaved );
83 }
84 else
85 { // put at the end
86 Vec_PtrRemove( p->aHistory, pStr );
87 Vec_PtrPush( p->aHistory, pStr );
88 }
89 }
90}
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition cmdHist.c:134
#define Len
Definition deflate.h:78
Cube * p
Definition exorList.c:222
char * Extra_UtilStrsav(const char *s)
#define ABC_MAX_STR
Definition mainInt.h:52
int strncmp()
int strlen()
int strcmp()
char * strcpy()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_HistoryPrint()

void Cmd_HistoryPrint ( Abc_Frame_t * p,
int Limit )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file cmdHist.c.

165{
166#if defined(ABC_USE_HISTORY)
167 char * pStr;
168 int i;
169 Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
170 printf( "================== Command history ==================\n" );
171 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
172 printf( "%s\n", pStr );
173 printf( "=====================================================\n" );
174#endif
175}
Here is the caller graph for this function:

◆ Cmd_HistoryRead()

void Cmd_HistoryRead ( Abc_Frame_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file cmdHist.c.

104{
105#if defined(ABC_USE_HISTORY)
106 char Buffer[ABC_MAX_STR];
107 FILE * pFile;
108 assert( Vec_PtrSize(p->aHistory) == 0 );
109 pFile = fopen( "abc.history", "rb" );
110 if ( pFile == NULL )
111 return;
112 while ( fgets( Buffer, ABC_MAX_STR, pFile ) != NULL )
113 {
114 int Len = strlen(Buffer);
115 if ( Buffer[Len-1] == '\n' )
116 Buffer[Len-1] = 0;
117 Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
118 }
119 fclose( pFile );
120#endif
121}
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_HistoryWrite()

void Cmd_HistoryWrite ( Abc_Frame_t * p,
int Limit )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file cmdHist.c.

135{
136#if defined(ABC_USE_HISTORY)
137 FILE * pFile;
138 char * pStr;
139 int i;
140 pFile = fopen( "abc.history", "wb" );
141 if ( pFile == NULL )
142 {
143 Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" );
144 return;
145 }
146 Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
147 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
148 fprintf( pFile, "%s\n", pStr );
149 fclose( pFile );
150#endif
151}
Here is the caller graph for this function: