winedbg: Properly handle EOF on input.
This commit is contained in:
parent
87e8204365
commit
55a57c2130
|
@ -472,7 +472,8 @@ int input_fetch_entire_line(const char* pfx, char** line)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!ReadFile(dbg_parser_input, &ch, 1, &nread, NULL) || nread == 0)
|
if (!ReadFile(dbg_parser_input, &ch, 1, &nread, NULL) || nread == 0)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
if (len + 2 > alloc)
|
if (len + 2 > alloc)
|
||||||
{
|
{
|
||||||
while (len + 2 > alloc) alloc *= 2;
|
while (len + 2 > alloc) alloc *= 2;
|
||||||
|
@ -489,9 +490,9 @@ int input_fetch_entire_line(const char* pfx, char** line)
|
||||||
int input_read_line(const char* pfx, char* buf, int size)
|
int input_read_line(const char* pfx, char* buf, int size)
|
||||||
{
|
{
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
len = input_fetch_entire_line(pfx, &line);
|
int len = input_fetch_entire_line(pfx, &line);
|
||||||
|
if (len < 0) return 0;
|
||||||
/* remove trailing \n */
|
/* remove trailing \n */
|
||||||
if (len > 0 && line[len - 1] == '\n') len--;
|
if (len > 0 && line[len - 1] == '\n') len--;
|
||||||
len = min(size - 1, len);
|
len = min(size - 1, len);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
static int read_input(const char* pfx, char* buf, int size)
|
static int read_input(const char* pfx, char* buf, int size)
|
||||||
{
|
{
|
||||||
size_t len;
|
int len;
|
||||||
static char* last_line = NULL;
|
static char* last_line = NULL;
|
||||||
static size_t last_line_idx = 0;
|
static size_t last_line_idx = 0;
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ static size_t last_line_idx = 0;
|
||||||
/* no remaining chars to be read from last line, grab a brand new line up to '\n' */
|
/* no remaining chars to be read from last line, grab a brand new line up to '\n' */
|
||||||
lexeme_flush();
|
lexeme_flush();
|
||||||
len = input_fetch_entire_line(pfx, &tmp);
|
len = input_fetch_entire_line(pfx, &tmp);
|
||||||
|
if (len < 0) return 0; /* eof */
|
||||||
/* FIXME: should have a pair of buffers, and switch between the two, instead of
|
/* FIXME: should have a pair of buffers, and switch between the two, instead of
|
||||||
* reallocating a new one for each line
|
* reallocating a new one for each line
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -360,6 +360,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
|
||||||
if (i < 1 || i > sgv.num)
|
if (i < 1 || i > sgv.num)
|
||||||
dbg_printf("Invalid choice %d\n", i);
|
dbg_printf("Invalid choice %d\n", i);
|
||||||
}
|
}
|
||||||
|
else return sglv_aborted;
|
||||||
} while (i < 1 || i > sgv.num);
|
} while (i < 1 || i > sgv.num);
|
||||||
|
|
||||||
/* The array is 0-based, but the choices are 1..n,
|
/* The array is 0-based, but the choices are 1..n,
|
||||||
|
|
Loading…
Reference in New Issue