Eric Pouech : winedbg: Move YY_INPUT implementation to dbg.y.
Alexandre Julliard
julliard at winehq.org
Wed Dec 1 15:23:50 CST 2021
Module: wine
Branch: master
Commit: 5ffd0d05a8482bad7cdd182ef16138aeec330849
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5ffd0d05a8482bad7cdd182ef16138aeec330849
Author: Eric Pouech <eric.pouech at gmail.com>
Date: Wed Dec 1 15:29:59 2021 +0100
winedbg: Move YY_INPUT implementation to dbg.y.
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/winedbg/dbg.y | 47 ++++++++++++++++++++++++++++++++++++++++++++-
programs/winedbg/debug.l | 47 +--------------------------------------------
programs/winedbg/debugger.h | 2 +-
3 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y
index 2106b8414e8..ace29039753 100644
--- a/programs/winedbg/dbg.y
+++ b/programs/winedbg/dbg.y
@@ -462,7 +462,7 @@ struct parser_context
static struct parser_context dbg_parser = {NULL, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0};
-int input_fetch_entire_line(const char* pfx, char** line)
+static int input_fetch_entire_line(const char* pfx, char** line)
{
char* buffer;
char ch;
@@ -501,6 +501,51 @@ int input_fetch_entire_line(const char* pfx, char** line)
return len;
}
+size_t input_lex_read_buffer(char* buf, int size)
+{
+ int len;
+ static char* last_line = NULL;
+ static size_t last_line_idx = 0;
+
+ /* try first to fetch the remaining of an existing line */
+ if (last_line_idx == 0)
+ {
+ char* tmp = NULL;
+ /* no remaining chars to be read from last line, grab a brand new line up to '\n' */
+ lexeme_flush();
+ len = input_fetch_entire_line("Wine-dbg>", &tmp);
+ if (len < 0) return 0; /* eof */
+
+ /* remove carriage return in newline */
+ if (len >= 2 && tmp[len - 2] == '\r')
+ {
+ tmp[len - 2] = '\n';
+ tmp[len - 1] = '\0';
+ len--;
+ }
+
+ /* FIXME: should have a pair of buffers, and switch between the two, instead of
+ * reallocating a new one for each line
+ */
+ if (last_line && (len == 0 || (len == 1 && tmp[0] == '\n')))
+ {
+ HeapFree(GetProcessHeap(), 0, tmp);
+ }
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, last_line);
+ last_line = tmp;
+ }
+ }
+
+ len = min(strlen(last_line + last_line_idx), size - 1);
+ memcpy(buf, last_line + last_line_idx, len);
+ buf[len] = '\0';
+ if ((last_line_idx += len) >= strlen(last_line))
+ last_line_idx = 0;
+ return len;
+}
+
int input_read_line(const char* pfx, char* buf, int size)
{
char* line = NULL;
diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l
index 3c9acc5fe60..a497f34e6b0 100644
--- a/programs/winedbg/debug.l
+++ b/programs/winedbg/debug.l
@@ -60,53 +60,8 @@ void lexeme_flush(void)
next_lexeme = 0;
}
-static size_t read_input(const char* pfx, char* buf, int size)
-{
- int len;
- static char* last_line = NULL;
- static size_t last_line_idx = 0;
-
- /* try first to fetch the remaining of an existing line */
- if (last_line_idx == 0)
- {
- char* tmp = NULL;
- /* no remaining chars to be read from last line, grab a brand new line up to '\n' */
- lexeme_flush();
- len = input_fetch_entire_line(pfx, &tmp);
- if (len < 0) return 0; /* eof */
-
- /* remove carriage return in newline */
- if (len >= 2 && tmp[len - 2] == '\r')
- {
- tmp[len - 2] = '\n';
- tmp[len - 1] = '\0';
- len--;
- }
-
- /* FIXME: should have a pair of buffers, and switch between the two, instead of
- * reallocating a new one for each line
- */
- if (last_line && (len == 0 || (len == 1 && tmp[0] == '\n')))
- {
- HeapFree(GetProcessHeap(), 0, tmp);
- }
- else
- {
- HeapFree(GetProcessHeap(), 0, last_line);
- last_line = tmp;
- }
- }
-
- len = min(strlen(last_line + last_line_idx), size - 1);
- memcpy(buf, last_line + last_line_idx, len);
- buf[len] = '\0';
- if ((last_line_idx += len) >= strlen(last_line))
- last_line_idx = 0;
- return len;
-}
-
#define YY_INPUT(buf,result,max_size) \
- (result = read_input("Wine-dbg>", buf, max_size))
+ (result = input_lex_read_buffer(buf, max_size))
static int syntax_error;
%}
diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h
index 8180488d1e5..c511f3f76bc 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -311,7 +311,7 @@ extern int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UI
/* dbg.y */
extern void parser_handle(const char*, HANDLE);
extern int input_read_line(const char* pfx, char* buffer, int size);
-extern int input_fetch_entire_line(const char* pfx, char** line);
+extern size_t input_lex_read_buffer(char* pfx, int size);
extern HANDLE WINAPIV parser_generate_command_file(const char*, ...);
/* debug.l */
More information about the wine-cvs
mailing list