Changeset 69016 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Oct 9, 2017 2:31:58 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformatrt.cpp
r66734 r69016 849 849 { 850 850 int i; 851 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s%0*p %04x:", off ? "\n" : "", sizeof(pu8) * 2, (uintptr_t)pu8, off); 851 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 852 "%s%0*p %04x:", off ? "\n" : "", sizeof(pu8) * 2, (uintptr_t)pu8, off); 852 853 for (i = 0; i < cchWidth && off + i < cchPrecision ; i++) 853 854 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 854 off + i < cchPrecision ? !(i & 7) && i ? "-%02x" : " %02x" : " ", pu8[i]); 855 off + i < cchPrecision ? !(i & 7) && i ? "-%02x" : " %02x" : " ", 856 pu8[i]); 855 857 while (i++ < cchWidth) 856 858 cch += pfnOutput(pvArgOutput, " ", 3); … … 863 865 cch += pfnOutput(pvArgOutput, u8 < 127 && u8 >= 32 ? (const char *)&u8 : ".", 1); 864 866 } 867 868 /* next */ 869 pu8 += cchWidth; 870 off += cchWidth; 871 } 872 return cch; 873 } 874 875 /* 876 * Regular hex dump with dittoing. 877 */ 878 case 'D': 879 { 880 int offEndDupCheck; 881 int cDuplicates = 0; 882 int off = 0; 883 cch = 0; 884 885 if (cchWidth <= 0) 886 cchWidth = 16; 887 offEndDupCheck = cchPrecision - cchWidth; 888 889 while (off < cchPrecision) 890 { 891 int i; 892 if ( off >= offEndDupCheck 893 || off <= 0 894 || memcmp(pu8, pu8 - cchWidth, cchWidth) != 0 895 || ( cDuplicates == 0 896 && ( off + cchWidth >= offEndDupCheck 897 || memcmp(pu8 + cchWidth, pu8, cchWidth) != 0)) ) 898 { 899 if (cDuplicates > 0) 900 { 901 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 902 "\n%.*s **** <ditto x %u>", 903 sizeof(pu8) * 2, "****************", cDuplicates); 904 cDuplicates = 0; 905 } 906 907 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 908 "%s%0*p %04x:", off ? "\n" : "", sizeof(pu8) * 2, (uintptr_t)pu8, off); 909 for (i = 0; i < cchWidth && off + i < cchPrecision ; i++) 910 cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 911 off + i < cchPrecision ? !(i & 7) && i 912 ? "-%02x" : " %02x" : " ", 913 pu8[i]); 914 while (i++ < cchWidth) 915 cch += pfnOutput(pvArgOutput, " ", 3); 916 917 cch += pfnOutput(pvArgOutput, " ", 1); 918 919 for (i = 0; i < cchWidth && off + i < cchPrecision; i++) 920 { 921 uint8_t u8 = pu8[i]; 922 cch += pfnOutput(pvArgOutput, u8 < 127 && u8 >= 32 ? (const char *)&u8 : ".", 1); 923 } 924 } 925 else 926 cDuplicates++; 865 927 866 928 /* next */
Note:
See TracChangeset
for help on using the changeset viewer.