mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 06:55:55 +00:00
history cleanup added
svn path=/trunk/; revision=836
This commit is contained in:
parent
61c3984818
commit
915ff9328d
3 changed files with 45 additions and 11 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cmd.c,v 1.15 1999/12/06 19:26:49 paolopan Exp $
|
/* $Id: cmd.c,v 1.16 1999/12/07 18:17:17 paolopan Exp $
|
||||||
*
|
*
|
||||||
* CMD.C - command-line interface.
|
* CMD.C - command-line interface.
|
||||||
*
|
*
|
||||||
|
@ -1025,6 +1025,7 @@ Initialize (int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
|
/*initialize history*/
|
||||||
InitHistory();
|
InitHistory();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1085,6 +1086,11 @@ static VOID Cleanup (int argc, char *argv[])
|
||||||
FreeLastPath ();
|
FreeLastPath ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FEATURE_HISTORY
|
||||||
|
CleanHistory();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* remove ctrl break handler */
|
/* remove ctrl break handler */
|
||||||
#ifndef __REACTOS__
|
#ifndef __REACTOS__
|
||||||
SetConsoleCtrlHandler (NULL, FALSE);
|
SetConsoleCtrlHandler (NULL, FALSE);
|
||||||
|
|
|
@ -248,6 +248,7 @@ INT cmd_goto (LPTSTR, LPTSTR);
|
||||||
VOID History (INT, LPTSTR);
|
VOID History (INT, LPTSTR);
|
||||||
VOID History_move_to_bottom(VOID);
|
VOID History_move_to_bottom(VOID);
|
||||||
VOID InitHistory(VOID);
|
VOID InitHistory(VOID);
|
||||||
|
VOID CleanHistory(VOID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,14 +74,24 @@ static LPHIST_ENTRY Bottom;
|
||||||
static LPHIST_ENTRY curr_ptr=0;
|
static LPHIST_ENTRY curr_ptr=0;
|
||||||
|
|
||||||
|
|
||||||
|
VOID InitHistory(VOID);
|
||||||
|
VOID History_move_to_bottom(VOID);
|
||||||
|
VOID History (INT dir, LPTSTR commandline);
|
||||||
|
VOID CleanHistory(VOID);
|
||||||
|
|
||||||
|
/*service functions*/
|
||||||
|
VOID del(LPHIST_ENTRY item);
|
||||||
|
VOID add_at_bottom(LPTSTR string);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID InitHistory(VOID)
|
VOID InitHistory(VOID)
|
||||||
{
|
{
|
||||||
size=0;
|
size=0;
|
||||||
|
|
||||||
|
|
||||||
Top = malloc(sizeof(HIST_ENTRY));
|
Top = malloc(sizeof(HIST_ENTRY));
|
||||||
Bottom = malloc(sizeof(HIST_ENTRY));
|
Bottom = malloc(sizeof(HIST_ENTRY));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Top->prev = Bottom;
|
Top->prev = Bottom;
|
||||||
|
@ -94,6 +108,19 @@ VOID InitHistory(VOID)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VOID CleanHistory(VOID)
|
||||||
|
{
|
||||||
|
|
||||||
|
while (Bottom->next!=Top)
|
||||||
|
del(Bottom->next);
|
||||||
|
|
||||||
|
free(Top);
|
||||||
|
free(Bottom);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID del(LPHIST_ENTRY item)
|
VOID del(LPHIST_ENTRY item)
|
||||||
{
|
{
|
||||||
|
@ -101,15 +128,15 @@ VOID del(LPHIST_ENTRY item)
|
||||||
if(item==NULL)
|
if(item==NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/*free string's mem*/
|
||||||
|
if (item->string)
|
||||||
|
free(item->string);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*set links in prev and next item*/
|
/*set links in prev and next item*/
|
||||||
item->next->prev=item->prev;
|
item->next->prev=item->prev;
|
||||||
item->prev->next=item->next;
|
item->prev->next=item->next;
|
||||||
|
|
||||||
|
|
||||||
/*free mem*/
|
|
||||||
if (item->string)
|
|
||||||
free(item->string);
|
|
||||||
|
|
||||||
free(item);
|
free(item);
|
||||||
|
|
||||||
|
@ -183,7 +210,7 @@ VOID History (INT dir, LPTSTR commandline)
|
||||||
|
|
||||||
if(dir<0)/*key up*/
|
if(dir<0)/*key up*/
|
||||||
{
|
{
|
||||||
if (curr_ptr->next==Top || curr_ptr->next==0)
|
if (curr_ptr->next==Top || curr_ptr==Top)
|
||||||
{
|
{
|
||||||
#ifdef WRAP_HISTORY
|
#ifdef WRAP_HISTORY
|
||||||
curr_ptr=Bottom;
|
curr_ptr=Bottom;
|
||||||
|
@ -208,7 +235,7 @@ VOID History (INT dir, LPTSTR commandline)
|
||||||
if(dir>0)
|
if(dir>0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (curr_ptr->prev==Bottom || curr_ptr->prev==0)
|
if (curr_ptr->prev==Bottom || curr_ptr==Bottom)
|
||||||
{
|
{
|
||||||
#ifdef WRAP_HISTORY
|
#ifdef WRAP_HISTORY
|
||||||
curr_ptr=Top;
|
curr_ptr=Top;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue