winedbg: fixing the line reading function
Eric Pouech
eric.pouech at wanadoo.fr
Mon Sep 9 14:41:57 CDT 2002
TSIA (ChangeLog as well)
A+
-------------- next part --------------
Name: wd_readline
ChangeLog: fixed some line reading functions
License: X11
GenDate: 2002/09/09 19:37:35 UTC
ModifiedFiles: debugger/debug.l debugger/source.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/debug.l,v
retrieving revision 1.31
diff -u -u -r1.31 debug.l
--- debugger/debug.l 13 Aug 2002 18:04:02 -0000 1.31
+++ debugger/debug.l 2 Sep 2002 19:50:02 -0000
@@ -36,7 +36,7 @@
#define YY_INPUT(buf,result,max_size) \
if ( (result = DEBUG_FetchFromLine("Wine-dbg>", buf, max_size)) < 0 ) \
- YY_FATAL_ERROR( "ReadLine() in flex scanner failed" );
+ YY_FATAL_ERROR( "FetchFromLine() in flex scanner failed" );
#define YY_NO_UNPUT
@@ -227,7 +227,7 @@
do
{
if (!ReadFile(DEBUG_hParserInput, buf_line, sizeof(buf_line) - 1, &nread, NULL) || nread == 0)
- break;
+ break;
buf_line[nread] = '\0';
if (check_nl && len == 0 && nread == 1 && buf_line[0] == '\n')
@@ -246,9 +246,7 @@
{
*line = HeapReAlloc(GetProcessHeap(), 0, *line, *alloc = 1);
**line = '\0';
- strcpy(*line + len, buf_line);
- len += nread;
- } while (nread == 0 || buf_line[nread - 1] != '\n');
+ }
/* Remove leading and trailing whitespace from the line */
stripwhite(*line);
@@ -294,10 +292,14 @@
size_t len = 0;
DEBUG_FetchEntireLine(pfx, &line, &len, FALSE);
- len = min(size, len);
- memcpy(buf, line, len - 1);
+ len = strlen(line);
+ /* remove trailing \n */
+ if (len > 0 && line[len - 1] == '\n') len--;
+ len = min(size - 1, len);
+ memcpy(buf, line, len);
buf[len] = '\0';
- return len - 1;
+ HeapFree(GetProcessHeap(), 0, line);
+ return 1;
}
static char** local_symbols /* = NULL */;
Index: debugger/source.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/source.c,v
retrieving revision 1.25
diff -u -u -r1.25 source.c
--- debugger/source.c 31 Aug 2002 18:45:09 -0000 1.25
+++ debugger/source.c 2 Sep 2002 17:54:57 -0000
@@ -218,11 +218,6 @@
sprintf(zbuf, "Enter path to file '%s': ", sourcefile);
DEBUG_ReadLine(zbuf, tmppath, sizeof(tmppath));
- if ( tmppath[strlen(tmppath)-1] == '\n' )
- {
- tmppath[strlen(tmppath)-1] = '\0';
- }
-
if ( tmppath[strlen(tmppath)-1] != '/' )
{
strcat(tmppath, "/");
More information about the wine-patches
mailing list