Changeset 29963 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Jun 1, 2010 4:43:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformatrt.cpp
r28800 r29963 97 97 * Group 3, hex dumpers and other complex stuff which requires more than simple formatting. 98 98 * - \%Rhxd - Takes a pointer to the memory which is to be dumped in typical 99 * hex format. Use the width to specify the length, and the precisionto99 * hex format. Use the precision to specify the length, and the width to 100 100 * set the number of bytes per line. Default width and precision is 16. 101 101 * - \%Rhxs - Takes a pointer to the memory to be displayed as a hex string, 102 102 * i.e. a series of space separated bytes formatted as two digit hex value. 103 * Use the width to specify the length. Default length is 16 bytes. 103 * Use the precision to specify the length. Default length is 16 bytes. 104 * The width, if specified, is ignored. 104 105 * - \%Rrc - Takes an integer iprt status code as argument. Will insert the 105 106 * status code define corresponding to the iprt status code. … … 756 757 { 757 758 uint8_t *pu8 = va_arg(*pArgs, uint8_t *); 758 if (cch Width<= 0)759 cch Width= 16;759 if (cchPrecision <= 0) 760 cchPrecision = 16; 760 761 if (pu8) 761 762 { … … 770 771 int off = 0; 771 772 772 if (cch Precision<= 0)773 cch Precision= 16;774 775 while (off < cch Width)773 if (cchWidth <= 0) 774 cchWidth = 16; 775 776 while (off < cchPrecision) 776 777 { 777 778 int i; 778 779 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s%0*x %04x:", off ? "\n" : "", sizeof(pu8) * 2, (uintptr_t)pu8, off); 779 for (i = 0; i < cch Precision && off + i < cchWidth; i++)780 for (i = 0; i < cchWidth && off + i < cchPrecision ; i++) 780 781 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 781 off + i < cch Width? !(i & 7) && i ? "-%02x" : " %02x" : " ", pu8[i]);782 while (i++ < cch Precision)782 off + i < cchPrecision ? !(i & 7) && i ? "-%02x" : " %02x" : " ", pu8[i]); 783 while (i++ < cchWidth) 783 784 cch += pfnOutput(pvArgOutput, " ", 3); 784 785 785 786 cch += pfnOutput(pvArgOutput, " ", 1); 786 787 787 for (i = 0; i < cch Precision && off + i < cchWidth; i++)788 for (i = 0; i < cchWidth && off + i < cchPrecision; i++) 788 789 { 789 790 uint8_t u8 = pu8[i]; … … 792 793 793 794 /* next */ 794 pu8 += cch Precision;795 off += cch Precision;795 pu8 += cchWidth; 796 off += cchWidth; 796 797 } 797 798 return cch; … … 803 804 case 's': 804 805 { 805 if (cch Width-- > 0)806 if (cchPrecision-- > 0) 806 807 { 807 808 size_t cch = RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%02x", *pu8++); 808 for (; cch Width > 0; cchWidth--, pu8++)809 for (; cchPrecision > 0; cchPrecision--, pu8++) 809 810 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, " %02x", *pu8); 810 811 return cch;
Note:
See TracChangeset
for help on using the changeset viewer.