- Print short ASCII strings without the "..."

- Make printing for Unicode strings more similar to ASCII.
This commit is contained in:
Richard Cohen 2003-08-07 02:56:35 +00:00 committed by Alexandre Julliard
parent ad302ff7dd
commit 387ca9ba89
2 changed files with 30 additions and 30 deletions

View File

@ -336,6 +336,8 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
} }
} }
#define CHARBUFSIZE 16
/****************************************************************** /******************************************************************
* DEBUG_PrintStringA * DEBUG_PrintStringA
* *
@ -346,38 +348,43 @@ void DEBUG_ExamineMemory( const DBG_VALUE *_value, int count, char format )
int DEBUG_PrintStringA(int chnl, const DBG_ADDR* address, int len) int DEBUG_PrintStringA(int chnl, const DBG_ADDR* address, int len)
{ {
char* lin = (void*)DEBUG_ToLinear(address); char* lin = (void*)DEBUG_ToLinear(address);
char ach[16+1]; char ch[CHARBUFSIZE+1];
int i, l; int written = 0;
if (len == -1) len = 32767; /* should be big enough */ if (len == -1) len = 32767; /* should be big enough */
for (i = len; i > 0; i -= l) while (written < len)
{ {
l = min(sizeof(ach) - 1, i); int to_write = min(CHARBUFSIZE, len - written );
DEBUG_READ_MEM_VERBOSE(lin, ach, l); if (!DEBUG_READ_MEM_VERBOSE(lin, ch, to_write)) break;
ach[l] = '\0'; /* protect from displaying junk */ ch[to_write] = '\0'; /* protect from displaying junk */
l = strlen(ach); to_write = lstrlenA(ch);
DEBUG_OutputA(chnl, ach, l); DEBUG_OutputA(chnl, ch, to_write);
if (l < sizeof(ach) - 1) break; lin += to_write;
lin += l; written += to_write;
if (to_write < CHARBUFSIZE) break;
} }
return len - i; /* number of actually written chars */ return written; /* number of actually written chars */
} }
int DEBUG_PrintStringW(int chnl, const DBG_ADDR* address, int len) int DEBUG_PrintStringW(int chnl, const DBG_ADDR* address, int len)
{ {
char* lin = (void*)DEBUG_ToLinear(address); char* lin = (void*)DEBUG_ToLinear(address);
WCHAR wch; WCHAR ch[CHARBUFSIZE+1];
int ret = 0; int written = 0;
if (len == -1) len = 32767; /* should be big enough */ if (len == -1) len = 32767; /* should be big enough */
while (len--)
while (written < len)
{ {
if (!DEBUG_READ_MEM_VERBOSE(lin, &wch, sizeof(wch)) || !wch) int to_write = min(CHARBUFSIZE, len - written );
break; if (!DEBUG_READ_MEM_VERBOSE(lin, ch, to_write * sizeof(WCHAR))) break;
lin += sizeof(wch); ch[to_write] = 0; /* protect from displaying junk */
DEBUG_OutputW(chnl, &wch, 1); to_write = lstrlenW(ch);
ret++; DEBUG_OutputW(chnl, ch, to_write);
lin += to_write;
written += to_write;
if (to_write < CHARBUFSIZE) break;
} }
return ret; return written; /* number of actually written chars */
} }

View File

@ -36,7 +36,7 @@
#define NR_TYPE_HASH 521 #define NR_TYPE_HASH 521
int DEBUG_nchar; int DEBUG_nchar;
static int DEBUG_maxchar = 1024; static const int DEBUG_maxchar = 1024;
struct en_values struct en_values
{ {
@ -890,20 +890,14 @@ DEBUG_Print( const DBG_VALUE *value, int count, char format, int level )
switch (value->cookie) switch (value->cookie)
{ {
case DV_TARGET: case DV_TARGET:
clen = DEBUG_PrintStringA(DBG_CHN_MESG, &value->addr, clen); DEBUG_nchar += DEBUG_PrintStringA(DBG_CHN_MESG, &value->addr, clen);
break; break;
case DV_HOST: case DV_HOST:
DEBUG_OutputA(DBG_CHN_MESG, pnt, clen); DEBUG_OutputA(DBG_CHN_MESG, pnt, clen);
break; break;
default: assert(0); default: assert(0);
} }
DEBUG_nchar += clen; DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, (len > clen) ? "...\"" : "\"");
if (clen != len)
{
DEBUG_Printf(DBG_CHN_MESG, "...\"");
goto leave;
}
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\"");
break; break;
} }
val1 = *value; val1 = *value;
@ -943,7 +937,6 @@ leave:
{ {
DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\n"); DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "\n");
} }
return;
} }
static void DEBUG_DumpAType(struct datatype* dt, BOOL deep) static void DEBUG_DumpAType(struct datatype* dt, BOOL deep)