mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 10:20:03 +00:00
Fixed compiler warnings
svn path=/trunk/; revision=900
This commit is contained in:
parent
a7a23b4dc3
commit
128cfc8af0
|
@ -5,7 +5,7 @@ double atan2 (double __y, double __x)
|
||||||
register double __value;
|
register double __value;
|
||||||
__asm __volatile__
|
__asm __volatile__
|
||||||
("fpatan\n\t"
|
("fpatan\n\t"
|
||||||
"fldl %%st(0)"
|
"fld %%st(0)"
|
||||||
: "=t" (__value) : "0" (__x), "u" (__y));
|
: "=t" (__value) : "0" (__x), "u" (__y));
|
||||||
|
|
||||||
return __value;
|
return __value;
|
||||||
|
|
|
@ -27,7 +27,7 @@ double exp (double __x)
|
||||||
__asm __volatile__
|
__asm __volatile__
|
||||||
("fldl2e # e^x = 2^(x * log2(e))\n\t"
|
("fldl2e # e^x = 2^(x * log2(e))\n\t"
|
||||||
"fmul %%st(1) # x * log2(e)\n\t"
|
"fmul %%st(1) # x * log2(e)\n\t"
|
||||||
"fstl %%st(1)\n\t"
|
"fst %%st(1)\n\t"
|
||||||
"frndint # int(x * log2(e))\n\t"
|
"frndint # int(x * log2(e))\n\t"
|
||||||
"fxch\n\t"
|
"fxch\n\t"
|
||||||
"fsub %%st(1) # fract(x * log2(e))\n\t"
|
"fsub %%st(1) # fract(x * log2(e))\n\t"
|
||||||
|
|
|
@ -64,7 +64,7 @@ double pow (double __x, double __y)
|
||||||
}
|
}
|
||||||
__asm __volatile__
|
__asm __volatile__
|
||||||
("fmul %%st(1) # y * log2(x)\n\t"
|
("fmul %%st(1) # y * log2(x)\n\t"
|
||||||
"fstl %%st(1)\n\t"
|
"fst %%st(1)\n\t"
|
||||||
"frndint # int(y * log2(x))\n\t"
|
"frndint # int(y * log2(x))\n\t"
|
||||||
"fxch\n\t"
|
"fxch\n\t"
|
||||||
"fsub %%st(1) # fract(y * log2(x))\n\t"
|
"fsub %%st(1) # fract(y * log2(x))\n\t"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: init.c,v 1.6 1999/12/06 00:25:14 ekohl Exp $
|
/* $Id: init.c,v 1.7 1999/12/24 17:17:51 ekohl Exp $
|
||||||
*
|
*
|
||||||
* init.c - Session Manager initialization
|
* init.c - Session Manager initialization
|
||||||
*
|
*
|
||||||
|
@ -87,9 +87,9 @@ InitSessionManager (
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Status = NtCreatePort (&SmApiPort,
|
Status = NtCreatePort (&SmApiPort,
|
||||||
0,
|
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
0,
|
0,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -243,9 +243,9 @@ InitSessionManager (
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Status = NtCreatePort (&DbgSsApiPort,
|
Status = NtCreatePort (&DbgSsApiPort,
|
||||||
0,
|
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
0,
|
0,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -266,9 +266,9 @@ InitSessionManager (
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Status = NtCreatePort (&DbgUiApiPort,
|
Status = NtCreatePort (&DbgUiApiPort,
|
||||||
0,
|
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
0,
|
0,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#define CMD_VER "0.1 pre 6"
|
#define CMD_VER "0.1 pre 7"
|
||||||
#define CMD_VER_RC CMD_VER"\0"
|
#define CMD_VER_RC CMD_VER"\0"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* $Id: copy.c,v 1.6 1999/12/24 17:20:54 ekohl Exp $
|
||||||
|
*
|
||||||
* COPY.C -- copy internal command.
|
* COPY.C -- copy internal command.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
* Replaced CRT io functions by Win32 io functions.
|
* Replaced CRT io functions by Win32 io functions.
|
||||||
*
|
*
|
||||||
* 27-Oct-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 27-Oct-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Disabled prompting then used in batch mode.
|
* Disabled prompting when used in batch mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -283,7 +284,8 @@ ParseCommand (LPFILES f, int argc, char **arg, LPDWORD lpdwFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID DeleteFileList (LPFILES f)
|
static VOID
|
||||||
|
DeleteFileList (LPFILES f)
|
||||||
{
|
{
|
||||||
LPFILES temp;
|
LPFILES temp;
|
||||||
|
|
||||||
|
@ -738,11 +740,12 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
||||||
copied = setup_copy (sources->next, p, bMultiple, drive_d, dir_d, file_d, ext_d, &append, &dwFlags) + 1;
|
copied = setup_copy (sources->next, p, bMultiple, drive_d, dir_d, file_d, ext_d, &append, &dwFlags) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteFileList (start);
|
DeleteFileList (sources);
|
||||||
DeleteFileList (sources);
|
|
||||||
freep (p);
|
freep (p);
|
||||||
ConOutPrintf (_T(" %d file(s) copied\n"), copied);
|
ConOutPrintf (_T(" %d file(s) copied\n"), copied);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif /* INCLUDE_CMD_COPY */
|
#endif /* INCLUDE_CMD_COPY */
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
|
@ -42,7 +42,6 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
TCHAR directory[MAX_PATH];
|
TCHAR directory[MAX_PATH];
|
||||||
LPCOMMAND cmds_ptr;
|
LPCOMMAND cmds_ptr;
|
||||||
|
|
||||||
|
|
||||||
/* expand current file name */
|
/* expand current file name */
|
||||||
count = charcount - 1;
|
count = charcount - 1;
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
|
@ -95,7 +94,7 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* ignore "." and ".." */
|
/* ignore "." and ".." */
|
||||||
if (!_tcscmp (file.cFileName, _T(".")) ||
|
if (!_tcscmp (file.cFileName, _T(".")) ||
|
||||||
!_tcscmp (file.cFileName, _T("..")))
|
!_tcscmp (file.cFileName, _T("..")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -139,24 +138,19 @@ VOID CompleteFilename (LPTSTR str, INT charcount)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found - search for internal command */
|
||||||
|
for (cmds_ptr = cmds; cmds_ptr->name; cmds_ptr++)
|
||||||
/*interanl commands serch*/
|
|
||||||
|
|
||||||
for(cmds_ptr=cmds;cmds_ptr->name;cmds_ptr++)
|
|
||||||
{
|
{
|
||||||
if(!_tcsnicmp(&str[start],cmds_ptr->name,
|
if (!_tcsnicmp (&str[start], cmds_ptr->name,
|
||||||
_tcslen(&str[start])))
|
_tcslen (&str[start])))
|
||||||
{
|
{
|
||||||
/*return the mach only if it is uniq*/
|
/* return the mach only if it is unique */
|
||||||
if(_tcsnicmp(&str[start],(cmds_ptr+1)->name,_tcslen(&str[start])))
|
if (_tcsnicmp (&str[start], (cmds_ptr+1)->name, _tcslen (&str[start])))
|
||||||
_tcscpy(&str[start],cmds_ptr->name);
|
_tcscpy (&str[start], cmds_ptr->name);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
Beep (440, 50);
|
Beep (440, 50);
|
||||||
#else
|
#else
|
||||||
|
@ -181,8 +175,6 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
TCHAR path[MAX_PATH];
|
TCHAR path[MAX_PATH];
|
||||||
TCHAR fname[MAX_PATH];
|
TCHAR fname[MAX_PATH];
|
||||||
TCHAR directory[MAX_PATH];
|
TCHAR directory[MAX_PATH];
|
||||||
LPCOMMAND cmds_ptr;
|
|
||||||
|
|
||||||
|
|
||||||
/* expand current file name */
|
/* expand current file name */
|
||||||
count = charcount - 1;
|
count = charcount - 1;
|
||||||
|
@ -265,8 +257,6 @@ BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no match found */
|
/* no match found */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
Beep (440, 50);
|
Beep (440, 50);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* $Id: history.c,v 1.8 1999/12/24 17:19:20 ekohl Exp $
|
||||||
|
*
|
||||||
* HISTORY.C - command line history.
|
* HISTORY.C - command line history.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
@ -24,8 +25,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HISTORY.C - command line history. Second version
|
* HISTORY.C - command line history. Second version
|
||||||
*
|
*
|
||||||
|
@ -35,18 +34,11 @@
|
||||||
* 06/12/99 (Paolo Pantaleo <paolopan@freemail.it>)
|
* 06/12/99 (Paolo Pantaleo <paolopan@freemail.it>)
|
||||||
* started.
|
* started.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef FEATURE_HISTORY
|
#ifdef FEATURE_HISTORY
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -62,70 +54,51 @@ typedef struct tagHISTORY
|
||||||
LPTSTR string;
|
LPTSTR string;
|
||||||
} HIST_ENTRY, * LPHIST_ENTRY;
|
} HIST_ENTRY, * LPHIST_ENTRY;
|
||||||
|
|
||||||
static INT size,
|
static INT size;
|
||||||
max_size=10;
|
static INT max_size=10; /* for now not configurable */
|
||||||
/*for now not configurable*/
|
|
||||||
|
|
||||||
|
|
||||||
static LPHIST_ENTRY Top;
|
static LPHIST_ENTRY Top;
|
||||||
static LPHIST_ENTRY Bottom;
|
static LPHIST_ENTRY Bottom;
|
||||||
|
|
||||||
|
|
||||||
static LPHIST_ENTRY curr_ptr=0;
|
static LPHIST_ENTRY curr_ptr=0;
|
||||||
|
|
||||||
|
/* service functions */
|
||||||
VOID InitHistory(VOID);
|
static VOID del (LPHIST_ENTRY item);
|
||||||
VOID History_move_to_bottom(VOID);
|
static VOID add_at_bottom (LPTSTR string);
|
||||||
VOID History (INT dir, LPTSTR commandline);
|
|
||||||
VOID CleanHistory(VOID);
|
|
||||||
VOID History_del_current_entry(LPTSTR str);
|
|
||||||
|
|
||||||
/*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));
|
|
||||||
Bottom = malloc(sizeof(HIST_ENTRY));
|
|
||||||
|
|
||||||
|
Top = malloc(sizeof(HIST_ENTRY));
|
||||||
|
Bottom = malloc(sizeof(HIST_ENTRY));
|
||||||
|
|
||||||
Top->prev = Bottom;
|
Top->prev = Bottom;
|
||||||
Top->next = NULL;
|
Top->next = NULL;
|
||||||
Top->string = NULL;
|
Top->string = NULL;
|
||||||
|
|
||||||
|
|
||||||
Bottom->prev = NULL;
|
Bottom->prev = NULL;
|
||||||
Bottom->next = Top;
|
Bottom->next = Top;
|
||||||
Bottom->string = NULL;
|
Bottom->string = NULL;
|
||||||
|
|
||||||
curr_ptr=Bottom;
|
curr_ptr=Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID CleanHistory (VOID)
|
||||||
|
|
||||||
VOID CleanHistory(VOID)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
while (Bottom->next!=Top)
|
while (Bottom->next!=Top)
|
||||||
del(Bottom->next);
|
del (Bottom->next);
|
||||||
|
|
||||||
free(Top);
|
|
||||||
free(Bottom);
|
|
||||||
|
|
||||||
|
free (Top);
|
||||||
|
free (Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID History_del_current_entry(LPTSTR str)
|
VOID History_del_current_entry(LPTSTR str)
|
||||||
{
|
{
|
||||||
LPHIST_ENTRY tmp;
|
LPHIST_ENTRY tmp;
|
||||||
|
|
||||||
if (size==0)
|
if (size==0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -135,100 +108,77 @@ VOID History_del_current_entry(LPTSTR str)
|
||||||
if(curr_ptr==Top)
|
if(curr_ptr==Top)
|
||||||
curr_ptr=Top->prev;
|
curr_ptr=Top->prev;
|
||||||
|
|
||||||
|
tmp=curr_ptr;
|
||||||
tmp=curr_ptr;
|
|
||||||
curr_ptr=curr_ptr->prev;
|
curr_ptr=curr_ptr->prev;
|
||||||
del(tmp);
|
del(tmp);
|
||||||
History(-1,str);
|
History(-1,str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID del(LPHIST_ENTRY item)
|
VOID del(LPHIST_ENTRY item)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( item==NULL || item==Top || item==Bottom )
|
if( item==NULL || item==Top || item==Bottom )
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
DebugPrintf("del in " __FILE__ ": retrning\n"
|
DebugPrintf("del in " __FILE__ ": retrning\n"
|
||||||
"item is 0x%08x (Bottom is0x%08x)\n",
|
"item is 0x%08x (Bottom is0x%08x)\n",
|
||||||
item, Bottom);
|
item, Bottom);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*free string's mem*/
|
/*free string's mem*/
|
||||||
if (item->string)
|
if (item->string)
|
||||||
free(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(item);
|
free(item);
|
||||||
|
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID add_at_bottom(LPTSTR string)
|
VOID add_at_bottom(LPTSTR string)
|
||||||
{
|
{
|
||||||
{
|
LPHIST_ENTRY tmp;
|
||||||
|
|
||||||
LPHIST_ENTRY tmp;
|
/*delete first entry if maximum number of entries is reached*/
|
||||||
|
if(size==max_size)
|
||||||
|
del(Top->prev);
|
||||||
|
|
||||||
|
/*fill bottom with string*/
|
||||||
/*delete first entry if maximum number of entries is reached*/
|
Bottom->string=malloc(_tcslen(string)+1);
|
||||||
if(size==max_size)
|
_tcscpy(Bottom->string,string);
|
||||||
del(Top->prev);
|
|
||||||
|
|
||||||
|
/*save Bottom value*/
|
||||||
|
tmp=Bottom;
|
||||||
|
|
||||||
|
/*create new void Bottom*/
|
||||||
/*fill bottom with string*/
|
Bottom=malloc(sizeof(HIST_ENTRY));
|
||||||
Bottom->string=malloc(_tcslen(string)+1);
|
Bottom->next=tmp;
|
||||||
_tcscpy(Bottom->string,string);
|
Bottom->prev=NULL;
|
||||||
|
Bottom->string=NULL;
|
||||||
|
|
||||||
/*save Bottom value*/
|
tmp->prev=Bottom;
|
||||||
tmp=Bottom;
|
|
||||||
|
|
||||||
|
|
||||||
/*create new void Bottom*/
|
|
||||||
Bottom=malloc(sizeof(HIST_ENTRY));
|
|
||||||
Bottom->next=tmp;
|
|
||||||
Bottom->prev=NULL;
|
|
||||||
Bottom->string=NULL;
|
|
||||||
|
|
||||||
tmp->prev=Bottom;
|
|
||||||
|
|
||||||
/*set new size*/
|
|
||||||
size++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*set new size*/
|
||||||
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID History_move_to_bottom(VOID)
|
VOID History_move_to_bottom(VOID)
|
||||||
{
|
{
|
||||||
curr_ptr=Bottom;
|
curr_ptr=Bottom;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID History (INT dir, LPTSTR commandline)
|
VOID History (INT dir, LPTSTR commandline)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(dir==0)
|
if(dir==0)
|
||||||
{
|
{
|
||||||
add_at_bottom(commandline);
|
add_at_bottom(commandline);
|
||||||
|
@ -242,37 +192,29 @@ VOID History (INT dir, LPTSTR commandline)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(dir<0)/*key up*/
|
if(dir<0)/*key up*/
|
||||||
{
|
{
|
||||||
if (curr_ptr->next==Top || curr_ptr==Top)
|
if (curr_ptr->next==Top || curr_ptr==Top)
|
||||||
{
|
{
|
||||||
#ifdef WRAP_HISTORY
|
#ifdef WRAP_HISTORY
|
||||||
curr_ptr=Bottom;
|
curr_ptr=Bottom;
|
||||||
#else
|
#else
|
||||||
curr_ptr=Top;
|
curr_ptr=Top;
|
||||||
commandline[0]=_T('\0');
|
commandline[0]=_T('\0');
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
curr_ptr = curr_ptr->next;
|
curr_ptr = curr_ptr->next;
|
||||||
if(curr_ptr->string)
|
if(curr_ptr->string)
|
||||||
_tcscpy(commandline,curr_ptr->string);
|
_tcscpy(commandline,curr_ptr->string);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(dir>0)
|
if(dir>0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (curr_ptr->prev==Bottom || curr_ptr==Bottom)
|
if (curr_ptr->prev==Bottom || curr_ptr==Bottom)
|
||||||
{
|
{
|
||||||
#ifdef WRAP_HISTORY
|
#ifdef WRAP_HISTORY
|
||||||
curr_ptr=Top;
|
curr_ptr=Top;
|
||||||
#else
|
#else
|
||||||
curr_ptr=Bottom;
|
curr_ptr=Bottom;
|
||||||
|
@ -281,123 +223,11 @@ VOID History (INT dir, LPTSTR commandline)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_ptr=curr_ptr->prev;
|
curr_ptr=curr_ptr->prev;
|
||||||
if(curr_ptr->string)
|
if(curr_ptr->string)
|
||||||
_tcscpy(commandline,curr_ptr->string);
|
_tcscpy(commandline,curr_ptr->string);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* FEATURE_HISTORY */
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
LPTSTR history = NULL; /*buffer to sotre all the lines*/
|
|
||||||
LPTSTR lines[MAXLINES]; /*array of pointers to each line(entry)*/
|
|
||||||
/*located in history buffer*/
|
|
||||||
|
|
||||||
INT curline = 0; /*the last line recalled by user*/
|
|
||||||
INT numlines = 0; /*number of entries, included the last*/
|
|
||||||
/*empty one*/
|
|
||||||
|
|
||||||
INT maxpos = 0; /*index of last byte of last entry*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID History (INT dir, LPTSTR commandline)
|
|
||||||
{
|
|
||||||
|
|
||||||
INT count; /*used in for loops*/
|
|
||||||
INT length; /*used in the same loops of count*/
|
|
||||||
/*both to make room when is full
|
|
||||||
either history or lines*/
|
|
||||||
|
|
||||||
/*first time History is called allocate mem*/
|
|
||||||
if (!history)
|
|
||||||
{
|
|
||||||
history = malloc (history_size * sizeof (TCHAR));
|
|
||||||
lines[0] = history;
|
|
||||||
history[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dir > 0)
|
|
||||||
{
|
|
||||||
/* next command */
|
|
||||||
if (curline < numlines)
|
|
||||||
{
|
|
||||||
curline++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curline == numlines)
|
|
||||||
{
|
|
||||||
commandline[0] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_tcscpy (commandline, lines[curline]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (dir < 0)
|
|
||||||
{
|
|
||||||
/* prev command */
|
|
||||||
if (curline > 0)
|
|
||||||
{
|
|
||||||
curline--;
|
|
||||||
}
|
|
||||||
|
|
||||||
_tcscpy (commandline, lines[curline]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* add to history */
|
|
||||||
/* remove oldest string until there's enough room for next one */
|
|
||||||
/* strlen (commandline) must be less than history_size! */
|
|
||||||
while ((maxpos + (INT)_tcslen (commandline) + 1 > history_size) || (numlines >= MAXLINES))
|
|
||||||
{
|
|
||||||
length = _tcslen (lines[0]) + 1;
|
|
||||||
|
|
||||||
for (count = 0; count < maxpos && count + (lines[1] - lines[0]) < history_size; count++)
|
|
||||||
{
|
|
||||||
history[count] = history[count + length];
|
|
||||||
}
|
|
||||||
|
|
||||||
maxpos -= length;
|
|
||||||
|
|
||||||
for (count = 0; count <= numlines && count < MAXLINES; count++)
|
|
||||||
{
|
|
||||||
lines[count] = lines[count + 1] - length;
|
|
||||||
}
|
|
||||||
|
|
||||||
numlines--;
|
|
||||||
#ifdef DEBUG
|
|
||||||
ConOutPrintf (_T("Reduced size: %ld lines\n"), numlines);
|
|
||||||
|
|
||||||
for (count = 0; count < numlines; count++)
|
|
||||||
{
|
|
||||||
ConOutPrintf (_T("%d: %s\n"), count, lines[count]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*copy entry in the history bufer*/
|
|
||||||
_tcscpy (lines[numlines], commandline);
|
|
||||||
numlines++;
|
|
||||||
|
|
||||||
/*set last lines[numlines] pointer next the end of last, valid,
|
|
||||||
just setted entry (the two lines above)*/
|
|
||||||
lines[numlines] = lines[numlines - 1] + _tcslen (commandline) + 1;
|
|
||||||
maxpos += _tcslen (commandline) + 1;
|
|
||||||
/* last line, empty */
|
|
||||||
|
|
||||||
curline = numlines;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif //#if 0
|
|
Loading…
Reference in a new issue