Jacek Caban : kernel32: Use IOCTL_CONDRV_GET_INPUT_INFO in CONSOLE_GetNumHistoryEntries.

Alexandre Julliard julliard at winehq.org
Fri Aug 14 16:39:32 CDT 2020


Module: wine
Branch: master
Commit: f54c7205b6ac387ee394c8877245f0d0f3a3cc7a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f54c7205b6ac387ee394c8877245f0d0f3a3cc7a

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Aug 14 13:27:31 2020 +0200

kernel32: Use IOCTL_CONDRV_GET_INPUT_INFO in CONSOLE_GetNumHistoryEntries.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/console.c         | 13 ++++---------
 dlls/kernel32/console_private.h |  2 +-
 dlls/kernel32/editline.c        |  2 +-
 include/wine/condrv.h           |  1 +
 server/console.c                |  1 +
 5 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 032f938a12..44df9463da 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -1009,16 +1009,11 @@ BOOL	CONSOLE_AppendHistory(const WCHAR* ptr)
  *
  *
  */
-unsigned CONSOLE_GetNumHistoryEntries(void)
+unsigned CONSOLE_GetNumHistoryEntries(HANDLE console)
 {
-    unsigned ret = -1;
-    SERVER_START_REQ(get_console_input_info)
-    {
-        req->handle = 0;
-        if (!wine_server_call_err( req )) ret = reply->history_index;
-    }
-    SERVER_END_REQ;
-    return ret;
+    struct condrv_input_info info;
+    BOOL ret = DeviceIoControl( console, IOCTL_CONDRV_GET_INPUT_INFO, NULL, 0, &info, sizeof(info), NULL, NULL );
+    return ret ? info.history_index : ~0;
 }
 
 /******************************************************************
diff --git a/dlls/kernel32/console_private.h b/dlls/kernel32/console_private.h
index 0b033b3550..b0fd2acd92 100644
--- a/dlls/kernel32/console_private.h
+++ b/dlls/kernel32/console_private.h
@@ -24,7 +24,7 @@
 /* console.c */
 extern int      CONSOLE_GetHistory(int idx, WCHAR* buf, int buf_len) DECLSPEC_HIDDEN;
 extern BOOL     CONSOLE_AppendHistory(const WCHAR *p) DECLSPEC_HIDDEN;
-extern unsigned CONSOLE_GetNumHistoryEntries(void) DECLSPEC_HIDDEN;
+extern unsigned CONSOLE_GetNumHistoryEntries(HANDLE) DECLSPEC_HIDDEN;
 extern void     CONSOLE_FillLineUniform(HANDLE hConsoleOutput, int i, int j, int len, LPCHAR_INFO lpFill) DECLSPEC_HIDDEN;
 extern BOOL     CONSOLE_GetEditionMode(HANDLE, int*) DECLSPEC_HIDDEN;
 
diff --git a/dlls/kernel32/editline.c b/dlls/kernel32/editline.c
index 489960aba6..38bc475754 100644
--- a/dlls/kernel32/editline.c
+++ b/dlls/kernel32/editline.c
@@ -408,7 +408,7 @@ static WCHAR* WCEL_GetHistory(WCEL_Context* ctx, int idx)
 
 static void	WCEL_HistoryInit(WCEL_Context* ctx)
 {
-    ctx->histPos  = CONSOLE_GetNumHistoryEntries();
+    ctx->histPos  = CONSOLE_GetNumHistoryEntries(ctx->hConIn);
     ctx->histSize = ctx->histPos + 1;
     ctx->histCurr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR));
 }
diff --git a/include/wine/condrv.h b/include/wine/condrv.h
index d42128f810..c898b094cf 100644
--- a/include/wine/condrv.h
+++ b/include/wine/condrv.h
@@ -74,6 +74,7 @@ struct condrv_input_info
     unsigned int  output_cp;      /* console output codepage */
     unsigned int  history_mode;   /* whether we duplicate lines in history */
     unsigned int  history_size;   /* number of lines in history */
+    unsigned int  history_index;  /* number of used lines in history */
     unsigned int  edition_mode;   /* index to the edition mode flavors */
     unsigned int  input_count;    /* number of available input records */
     condrv_handle_t win;          /* renderer window handle */
diff --git a/server/console.c b/server/console.c
index 890ea609c2..5a71bece9d 100644
--- a/server/console.c
+++ b/server/console.c
@@ -1595,6 +1595,7 @@ static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *
             info.output_cp     = console->output_cp;
             info.history_mode  = console->history_mode;
             info.history_size  = console->history_size;
+            info.history_index = console->history_index;
             info.edition_mode  = console->edition_mode;
             info.input_count   = console->recnum;
             info.win           = console->win;




More information about the wine-cvs mailing list