Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
dd0abb8a
Commit
dd0abb8a
authored
Jul 22, 2002
by
Eric Pouech
Committed by
Alexandre Julliard
Jul 22, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed very long line reading (and some buffering bugs).
Removed the static limit in array for symbols parsing.
parent
d84875ce
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
59 deletions
+87
-59
debug.l
debugger/debug.l
+84
-56
debugger.h
debugger/debugger.h
+1
-1
hash.c
debugger/hash.c
+1
-1
source.c
debugger/source.c
+1
-1
No files found.
debugger/debug.l
View file @
dd0abb8a
...
...
@@ -28,8 +28,11 @@
#include "y.tab.h"
#undef YY_INPUT
static int DEBUG_FetchFromLine(const char* pfx, char* buf, int size);
#define YY_INPUT(buf,result,max_size) \
if ( (result = DEBUG_
ReadLine("Wine-dbg>", buf, max_size, TRUE, TRUE
)) <= 0 ) \
if ( (result = DEBUG_
FetchFromLine("Wine-dbg>", buf, max_size
)) <= 0 ) \
YY_FATAL_ERROR( "ReadLine() in flex scanner failed" );
...
...
@@ -188,90 +191,115 @@ int yywrap(void) { return 1; }
/* Strip whitespace from the start and end of STRING. */
static void stripwhite
(char *string)
static void stripwhite(char *string)
{
register int i = 0;
while (whitespace (string[i]))
i++;
if (i)
strcpy (string, string + i);
int i, last;
i = strlen (string) - 1;
for (i = 0; whitespace(string[i]); i++);
if (i) strcpy(string, string + i);
while (i > 0 && whitespace (string[i]))
i--;
last = i = strlen(string) - 1;
i
f (string[last] == '\n') i
--;
while (i > 0 && whitespace(string[i])) i--;
if (string[last] == '\n')
string[++i] = '\n';
string[++i] = '\0';
}
int DEBUG_ReadLine(const char* pfx, char * buf, int size, int flush_sym, int keep_hist
)
static int DEBUG_FetchEntireLine(const char* pfx, char** line, size_t* alloc, BOOL check_nl
)
{
char buf_line[256];
char* ptr;
int len;
DWORD nread;
size_t len;
for (;;)
{
if (flush_sym) DEBUG_FlushSymbols();
/* as of today, console handles can be file handles... so better use file APIs rather than
* consoles
*/
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pfx, strlen(pfx), &nread
, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pfx, strlen(pfx), NULL
, NULL);
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf_line, sizeof(buf_line), &nread, NULL))
len = 0;
do
{
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf_line, sizeof(buf_line) - 1, &nread, NULL))
break;
/* FIXME: should be rewritten not to remove and then add the trailing '\n' */
if (nread > 0 && buf_line[nread - 1] == '\n') nread--;
buf_line[nread] = 0;
/* Remove leading and trailing whitespace from the line */
stripwhite (buf_line);
buf_line[nread] = '\0';
if (keep_hist)
{
static char last_line[256] = "";
/* If there is anything left, add it to the history list
and execute it. Otherwise, re-execute last command. */
if (check_nl && len == 0 && nread == 1 && buf_line[0] == '\n')
return 0;
if (*buf_line)
/* store stuff at the end of last_line */
if (len + nread + 1 > *alloc)
{
strncpy( last_line, buf_line, sizeof(last_line) - 1 );
last_line[sizeof(last_line) - 1] = '\0';
}
ptr = last_line;
*line = HeapReAlloc(GetProcessHeap(), 0, *line, *alloc += nread + 1);
}
else
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);
return 1;
}
static int DEBUG_FetchFromLine(const char* pfx, char* buf, int size)
{
size_t len;
static char* last_line = NULL;
static size_t last_line_size = 0;
static size_t last_line_idx = 0;
/* first alloc of our current buffer */
if (!last_line)
{
/* I should also tweak with the undoc functions to remove this line from the console
* history... */
ptr = buf_line;
last_line = HeapAlloc(GetProcessHeap(), 0, last_line_size = 2);
assert(last_line);
last_line[0] = '\n';
last_line[1] = '\0';
}
if ((len = strlen(ptr)) > 0)
{
if (size < len + 1)
/* try first to fetch the remaining of an existing line */
if (last_line_idx == 0)
{
DEBUG_Printf(DBG_CHN_MESG, "Fatal readline goof.\n");
DEBUG_Exit(0);
}
strcpy(buf, ptr);
buf[len] = '\n';
buf[len+1] = 0;
return len + 1;
}
/* no remaining chars to be read from last line, grab a brand new line up to '\n' */
DEBUG_FlushSymbols();
DEBUG_FetchEntireLine(pfx, &last_line, &last_line_size, TRUE);
}
return 0;
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;
}
static char *local_symbols[30];
static int next_symbol;
int DEBUG_ReadLine(const char* pfx, char* buf, int size)
{
char* line = NULL;
size_t len = 0;
DEBUG_FetchEntireLine(pfx, &line, &len, FALSE);
len = min(size, len);
memcpy(buf, line, len - 1);
buf[len] = '\0';
return len - 1;
}
char * DEBUG_MakeSymbol(const char * symbol)
static char** local_symbols /* = NULL */;
static int next_symbol /* = 0 */;
static int alloc_symbol /* = 0 */;
char* DEBUG_MakeSymbol(const char* symbol)
{
assert(0 <= next_symbol && next_symbol < (sizeof(local_symbols) / sizeof(local_symbols[0])));
assert(0 <= next_symbol && next_symbol < alloc_symbol + 1);
if (next_symbol >= alloc_symbol)
{
local_symbols = HeapReAlloc(GetProcessHeap(), 0, local_symbols,
(alloc_symbol += 32) * sizeof(local_symbols[0]));
assert(local_symbols);
}
return local_symbols[next_symbol++] = DBG_strdup(symbol);
}
...
...
debugger/debugger.h
View file @
dd0abb8a
...
...
@@ -312,7 +312,7 @@ extern void DEBUG_Exit( DWORD );
/* debugger/debug.l */
extern
void
DEBUG_FlushSymbols
(
void
);
extern
char
*
DEBUG_MakeSymbol
(
const
char
*
);
extern
int
DEBUG_ReadLine
(
const
char
*
pfx
,
char
*
buffer
,
int
size
,
int
flush_sym
,
int
keep_hist
);
extern
int
DEBUG_ReadLine
(
const
char
*
pfx
,
char
*
buffer
,
int
size
);
/* debugger/display.c */
extern
int
DEBUG_DoDisplay
(
void
);
...
...
debugger/hash.c
View file @
dd0abb8a
...
...
@@ -427,7 +427,7 @@ BOOL DEBUG_GetSymbolValue( const char * name, const int lineno,
}
do
{
i
=
0
;
if
(
DEBUG_ReadLine
(
"=> "
,
buffer
,
sizeof
(
buffer
)
,
FALSE
,
FALSE
))
if
(
DEBUG_ReadLine
(
"=> "
,
buffer
,
sizeof
(
buffer
)))
{
i
=
atoi
(
buffer
);
if
(
i
<
1
||
i
>
num
)
...
...
debugger/source.c
View file @
dd0abb8a
...
...
@@ -203,7 +203,7 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
* Still couldn't find it. Ask user for path to add.
*/
sprintf
(
zbuf
,
"Enter path to file '%s': "
,
sourcefile
);
DEBUG_ReadLine
(
zbuf
,
tmppath
,
sizeof
(
tmppath
)
,
FALSE
,
FALSE
);
DEBUG_ReadLine
(
zbuf
,
tmppath
,
sizeof
(
tmppath
));
if
(
tmppath
[
strlen
(
tmppath
)
-
1
]
==
'\n'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment