Alexandre Julliard : winedbg: Properly handle EOF on input.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 26 10:23:54 CDT 2007


Module: wine
Branch: master
Commit: 55a57c21306577c3ec82b8d638f19819602cfdb7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=55a57c21306577c3ec82b8d638f19819602cfdb7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Apr 26 14:25:32 2007 +0200

winedbg: Properly handle EOF on input.

---

 programs/winedbg/dbg.y    |    7 ++++---
 programs/winedbg/debug.l  |    7 ++++---
 programs/winedbg/symbol.c |    1 +
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y
index aea48bd..4679986 100644
--- a/programs/winedbg/dbg.y
+++ b/programs/winedbg/dbg.y
@@ -472,7 +472,8 @@ int      input_fetch_entire_line(const char* pfx, char** line)
     do
     {
         if (!ReadFile(dbg_parser_input, &ch, 1, &nread, NULL) || nread == 0)
-            break;
+            return -1;
+
         if (len + 2 > alloc)
         {
             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)
 {
     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 */
     if (len > 0 && line[len - 1] == '\n') len--;
     len = min(size - 1, len);
diff --git a/programs/winedbg/debug.l b/programs/winedbg/debug.l
index 6be0f4c..d3b3b36 100644
--- a/programs/winedbg/debug.l
+++ b/programs/winedbg/debug.l
@@ -33,9 +33,9 @@
 
 static int read_input(const char* pfx, char* buf, int size)
 {
-    size_t      len;
-static char*  last_line = NULL;
-static size_t last_line_idx = 0;
+    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)
@@ -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' */
         lexeme_flush();
         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
          * reallocating a new one for each line
          */
diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c
index 15e7093..d33e9e8 100644
--- a/programs/winedbg/symbol.c
+++ b/programs/winedbg/symbol.c
@@ -360,6 +360,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno,
                     if (i < 1 || i > sgv.num)
                         dbg_printf("Invalid choice %d\n", i);
                 }
+                else return sglv_aborted;
             } while (i < 1 || i > sgv.num);
 
             /* The array is 0-based, but the choices are 1..n, 




More information about the wine-cvs mailing list