Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
bffbd05a
Commit
bffbd05a
authored
Aug 25, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added recording history of used commands into file 'abc.history' (Windows only).
parent
19d50b98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
+9
-12
src/base/cmd/cmd.c
+0
-4
src/base/cmd/cmdHist.c
+9
-8
No files found.
src/base/cmd/cmd.c
View file @
bffbd05a
...
...
@@ -79,9 +79,7 @@ void Cmd_Init( Abc_Frame_t * pAbc )
pAbc
->
tAliases
=
st_init_table
(
strcmp
,
st_strhash
);
pAbc
->
tFlags
=
st_init_table
(
strcmp
,
st_strhash
);
pAbc
->
aHistory
=
Vec_PtrAlloc
(
100
);
#if defined(WIN32)
Cmd_HistoryRead
(
pAbc
);
#endif
Cmd_CommandAdd
(
pAbc
,
"Basic"
,
"time"
,
CmdCommandTime
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Basic"
,
"echo"
,
CmdCommandEcho
,
0
);
...
...
@@ -124,9 +122,7 @@ void Cmd_End( Abc_Frame_t * pAbc )
{
st_generator
*
gen
;
char
*
pKey
,
*
pValue
;
#if defined(WIN32)
Cmd_HistoryWrite
(
pAbc
,
ABC_INFINITY
);
#endif
// st_free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree );
// st_free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree );
...
...
src/base/cmd/cmdHist.c
View file @
bffbd05a
...
...
@@ -47,8 +47,8 @@ ABC_NAMESPACE_IMPL_START
***********************************************************************/
void
Cmd_HistoryAddCommand
(
Abc_Frame_t
*
p
,
const
char
*
command
)
{
int
nLastLooked
=
10
;
// defines how many entries back are looked
int
nLastSaved
=
100
;
//
defines how many last entries are saved
int
nLastLooked
=
10
;
// do not add history if the same entry appears among the last entries
int
nLastSaved
=
100
;
//
when saving a file, save no more than this number of last entries
char
Buffer
[
ABC_MAX_STR
];
int
Len
=
strlen
(
command
);
...
...
@@ -61,9 +61,9 @@ void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command )
strncmp
(
Buffer
,
"history"
,
7
)
&&
strncmp
(
Buffer
,
"hi "
,
3
)
&&
strcmp
(
Buffer
,
"hi"
)
)
{
char
*
pStr
;
int
i
;
// do not enter if the same command appears among
the last five
commands
Vec_PtrForEachEntryStart
(
char
*
,
p
->
aHistory
,
pStr
,
i
,
Abc_MaxInt
(
0
,
Vec_PtrSize
(
p
->
aHistory
)
-
nLastLooked
)
)
int
i
,
Start
=
Abc_MaxInt
(
0
,
Vec_PtrSize
(
p
->
aHistory
)
-
nLastLooked
)
;
// do not enter if the same command appears among
nLastLooked
commands
Vec_PtrForEachEntryStart
(
char
*
,
p
->
aHistory
,
pStr
,
i
,
Start
)
if
(
!
strcmp
(
pStr
,
Buffer
)
)
break
;
if
(
i
==
Vec_PtrSize
(
p
->
aHistory
)
)
...
...
@@ -87,15 +87,13 @@ void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command )
***********************************************************************/
void
Cmd_HistoryRead
(
Abc_Frame_t
*
p
)
{
#if defined(WIN32)
char
Buffer
[
ABC_MAX_STR
];
FILE
*
pFile
;
assert
(
Vec_PtrSize
(
p
->
aHistory
)
==
0
);
pFile
=
fopen
(
"abc.history"
,
"rb"
);
if
(
pFile
==
NULL
)
{
// Abc_Print( 0, "Cannot open file \"abc.history\" for reading.\n" );
return
;
}
while
(
fgets
(
Buffer
,
ABC_MAX_STR
,
pFile
)
!=
NULL
)
{
int
Len
=
strlen
(
Buffer
);
...
...
@@ -104,6 +102,7 @@ void Cmd_HistoryRead( Abc_Frame_t * p )
Vec_PtrPush
(
p
->
aHistory
,
Extra_UtilStrsav
(
Buffer
)
);
}
fclose
(
pFile
);
#endif
}
/**Function*************************************************************
...
...
@@ -119,6 +118,7 @@ void Cmd_HistoryRead( Abc_Frame_t * p )
***********************************************************************/
void
Cmd_HistoryWrite
(
Abc_Frame_t
*
p
,
int
Limit
)
{
#if defined(WIN32)
FILE
*
pFile
;
char
*
pStr
;
int
i
;
...
...
@@ -132,6 +132,7 @@ void Cmd_HistoryWrite( Abc_Frame_t * p, int Limit )
Vec_PtrForEachEntryStart
(
char
*
,
p
->
aHistory
,
pStr
,
i
,
Limit
)
fprintf
(
pFile
,
"%s
\n
"
,
pStr
);
fclose
(
pFile
);
#endif
}
////////////////////////////////////////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment