Changeset 4908 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Sep 20, 2007 7:23:11 AM (17 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/VBox/strformat-vbox.cpp
r4694 r4908 159 159 case 'd': 160 160 { 161 int cch = 0; 162 int off = 0; 163 161 164 if (cchPrecision <= 0) 162 165 cchPrecision = 16; 163 166 164 int cch = 0;165 int off = 0;166 167 while (off < cchWidth) 167 168 { … … 311 312 */ 312 313 int64_t i64 = 0; 314 char szNum[64]; 315 int cch; 316 313 317 ch = *(*ppszFormat)++; 314 318 if (ch == '8') … … 341 345 AssertMsgFailed(("Invalid format %%VI%c.10s\n", ch, *ppszFormat)); 342 346 343 char szNum[64]; 344 int cch = RTStrFormatNumber(szNum, i64, 10, cchWidth, cchPrecision, fFlags | RTSTR_F_VALSIGNED); 347 cch = RTStrFormatNumber(szNum, i64, 10, cchWidth, cchPrecision, fFlags | RTSTR_F_VALSIGNED); 345 348 Assert(cch < (int)sizeof(szNum)); 346 349 return pfnOutput(pvArgOutput, szNum, cch); … … 360 363 */ 361 364 uint64_t u64 = 0; 365 char szNum[64]; 366 int cch; 367 362 368 ch = *(*ppszFormat)++; 363 369 if (ch == '8') … … 390 396 AssertMsgFailed(("Invalid format %%VI%c.10s\n", ch, *ppszFormat)); 391 397 392 char szNum[64]; 393 int cch = RTStrFormatNumber(szNum, u64, iBase, cchWidth, cchPrecision, fFlags); 398 cch = RTStrFormatNumber(szNum, u64, iBase, cchWidth, cchPrecision, fFlags); 394 399 Assert(cch < (int)sizeof(szNum)); 395 400 return pfnOutput(pvArgOutput, szNum, cch); … … 404 409 && (*ppszFormat)[2] == 'd') 405 410 { 411 PRTUUID pUuid = va_arg(*pArgs, PRTUUID); 412 static const char szNull[] = "<NULL>"; 413 406 414 (*ppszFormat) += 3; 407 PRTUUID pUuid = va_arg(*pArgs, PRTUUID);408 415 if (VALID_PTR(pUuid)) 409 416 { … … 424 431 } 425 432 426 static const char szNull[] = "<NULL>";427 433 return pfnOutput(pvArgOutput, szNull, sizeof(szNull) - 1); 428 434 } -
trunk/src/VBox/Runtime/strformatrt.cpp
r4694 r4908 245 245 #undef STRMEM 246 246 }; 247 AssertMsg(!chArgSize, ("Not argument size '%c' for RT types! '%.10s'\n", chArgSize, pszFormatOrg));248 249 /*250 * Lookup the type - binary search.251 */252 247 const char *pszType = *ppszFormat - 1; 253 248 int iStart = 0; 254 249 int iEnd = ELEMENTS(s_aTypes) - 1; 255 250 int i = ELEMENTS(s_aTypes) / 2; 256 for (;;) 257 { 258 int iDiff = strncmp(pszType, s_aTypes[i].sz, s_aTypes[i].cch); 259 if (!iDiff) 260 break; 261 if (iEnd == iStart) 262 { 263 AssertMsgFailed(("Invalid format type '%.10s'!\n", pszFormatOrg)); 264 return 0; 265 } 266 if (iDiff < 0) 267 iEnd = i - 1; 268 else 269 iStart = i + 1; 270 if (iEnd < iStart) 271 { 272 AssertMsgFailed(("Invalid format type '%.10s'!\n", pszFormatOrg)); 273 return 0; 274 } 275 i = iStart + (iEnd - iStart) / 2; 276 } 277 278 /* 279 * Advance the format string and merge flags. 280 */ 281 *ppszFormat += s_aTypes[i].cch - 1; 282 fFlags |= s_aTypes[i].fFlags; 283 284 /* 285 * Fetch the argument. 286 * It's important that a signed value gets sign-extended up to 64-bit. 287 */ 251 288 252 union 289 253 { … … 302 266 PCRTUUID pUuid; 303 267 } u; 268 char szBuf[80]; 269 unsigned cch; 270 271 AssertMsg(!chArgSize, ("Not argument size '%c' for RT types! '%.10s'\n", chArgSize, pszFormatOrg)); 272 273 /* 274 * Lookup the type - binary search. 275 */ 276 for (;;) 277 { 278 int iDiff = strncmp(pszType, s_aTypes[i].sz, s_aTypes[i].cch); 279 if (!iDiff) 280 break; 281 if (iEnd == iStart) 282 { 283 AssertMsgFailed(("Invalid format type '%.10s'!\n", pszFormatOrg)); 284 return 0; 285 } 286 if (iDiff < 0) 287 iEnd = i - 1; 288 else 289 iStart = i + 1; 290 if (iEnd < iStart) 291 { 292 AssertMsgFailed(("Invalid format type '%.10s'!\n", pszFormatOrg)); 293 return 0; 294 } 295 i = iStart + (iEnd - iStart) / 2; 296 } 297 298 /* 299 * Advance the format string and merge flags. 300 */ 301 *ppszFormat += s_aTypes[i].cch - 1; 302 fFlags |= s_aTypes[i].fFlags; 303 304 /* 305 * Fetch the argument. 306 * It's important that a signed value gets sign-extended up to 64-bit. 307 */ 304 308 u.u64 = 0; 305 309 if (fFlags & RTSTR_F_VALSIGNED) … … 363 367 * Format the output. 364 368 */ 365 char szBuf[80];366 unsigned cch;367 369 switch (s_aTypes[i].enmFormat) 368 370 { … … 422 424 case RTSF_UUID: 423 425 { 426 static const char szNull[] = "<NULL>"; 427 424 428 if (VALID_PTR(u.pUuid)) 425 429 { … … 439 443 u.pUuid->Gen.au8Node[5]); 440 444 } 441 442 static const char szNull[] = "<NULL>";443 445 return pfnOutput(pvArgOutput, szNull, sizeof(szNull) - 1); 444 446 } … … 496 498 case 'd': 497 499 { 500 size_t cch = 0; 501 int off = 0; 502 498 503 if (cchPrecision <= 0) 499 504 cchPrecision = 16; 500 505 501 size_t cch = 0;502 int off = 0;503 506 while (off < cchWidth) 504 507 { … … 661 664 #undef STRMEM 662 665 }; 663 664 AssertMsg(!chArgSize, ("Not argument size '%c' for RT types! '%.10s'\n", chArgSize, pszFormatOrg));665 666 /*667 * Lookup the type - binary search.668 */669 666 const char *pszType = *ppszFormat - 1; 670 667 int iStart = 0; 671 668 int iEnd = ELEMENTS(s_aTypes) - 1; 672 669 int i = ELEMENTS(s_aTypes) / 2; 670 671 union 672 { 673 const void *pv; 674 uint64_t u64; 675 PCRTTIMESPEC pTimeSpec; 676 } u; 677 678 AssertMsg(!chArgSize, ("Not argument size '%c' for RT types! '%.10s'\n", chArgSize, pszFormatOrg)); 679 680 /* 681 * Lookup the type - binary search. 682 */ 673 683 for (;;) 674 684 { … … 697 707 * Fetch the argument. 698 708 */ 699 union700 {701 const void *pv;702 uint64_t u64;703 PCRTTIMESPEC pTimeSpec;704 } u;705 709 u.u64 = 0; 706 710 switch (s_aTypes[i].cb)
Note:
See TracChangeset
for help on using the changeset viewer.