Changeset 23571 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/test.h
- Timestamp:
- Oct 6, 2009 6:07:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/test.h
r19678 r23571 71 71 extern int winetest_get_mainargs( char*** pargv ); 72 72 extern void winetest_wait_child_process( HANDLE process ); 73 74 extern const char *wine_dbgstr_wn( const WCHAR *str, int n ); 75 static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); } 73 76 74 77 #ifdef STANDALONE … … 206 209 int todo_level; /* current todo nesting level */ 207 210 int todo_do_loop; 211 char *str_pos; /* position in debug buffer */ 212 char strings[2000]; /* buffer for debug strings */ 208 213 } tls_data; 209 214 static DWORD tls_index; … … 218 223 if (!data) 219 224 { 220 data=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(tls_data)); 225 data=HeapAlloc(GetProcessHeap(), 0, sizeof(tls_data)); 226 data->todo_level = 0; 227 data->str_pos = data->strings; 221 228 TlsSetValue(tls_index,data); 222 229 } 223 230 SetLastError(last_error); 224 231 return data; 232 } 233 234 /* allocate some tmp space for a string */ 235 static char *get_temp_buffer( size_t n ) 236 { 237 tls_data *data = get_tls_data(); 238 char *res = data->str_pos; 239 240 if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings; 241 data->str_pos = res + n; 242 return res; 243 } 244 245 /* release extra space that we requested in gimme1() */ 246 static void release_temp_buffer( char *ptr, size_t size ) 247 { 248 tls_data *data = get_tls_data(); 249 data->str_pos = ptr + size; 225 250 } 226 251 … … 417 442 } 418 443 444 const char *wine_dbgstr_wn( const WCHAR *str, int n ) 445 { 446 char *dst, *res; 447 size_t size; 448 449 if (!((ULONG_PTR)str >> 16)) 450 { 451 if (!str) return "(null)"; 452 res = get_temp_buffer( 6 ); 453 sprintf( res, "#%04x", LOWORD(str) ); 454 return res; 455 } 456 if (n == -1) 457 { 458 const WCHAR *end = str; 459 while (*end) end++; 460 n = end - str; 461 } 462 if (n < 0) n = 0; 463 size = 12 + min( 300, n * 5 ); 464 dst = res = get_temp_buffer( size ); 465 *dst++ = 'L'; 466 *dst++ = '"'; 467 while (n-- > 0 && dst <= res + size - 10) 468 { 469 WCHAR c = *str++; 470 switch (c) 471 { 472 case '\n': *dst++ = '\\'; *dst++ = 'n'; break; 473 case '\r': *dst++ = '\\'; *dst++ = 'r'; break; 474 case '\t': *dst++ = '\\'; *dst++ = 't'; break; 475 case '"': *dst++ = '\\'; *dst++ = '"'; break; 476 case '\\': *dst++ = '\\'; *dst++ = '\\'; break; 477 default: 478 if (c >= ' ' && c <= 126) 479 *dst++ = c; 480 else 481 { 482 *dst++ = '\\'; 483 sprintf(dst,"%04x",c); 484 dst+=4; 485 } 486 } 487 } 488 *dst++ = '"'; 489 if (n > 0) 490 { 491 *dst++ = '.'; 492 *dst++ = '.'; 493 *dst++ = '.'; 494 } 495 *dst++ = 0; 496 release_temp_buffer( res, dst - res ); 497 return res; 498 } 499 419 500 /* Find a test by name */ 420 501 static const struct test *find_test( const char *name )
Note:
See TracChangeset
for help on using the changeset viewer.