diff options
| author | Michael Meskes <meskes@debian.org> | 2010-06-04 09:49:50 +0200 |
|---|---|---|
| committer | Michael Meskes <meskes@debian.org> | 2010-06-04 09:49:50 +0200 |
| commit | e13debb062071c46f2707d0d0e59c57675b49360 (patch) | |
| tree | 922f54068563b5cf3274bae8ba8122ce4b4ede1d /src/VBox/Runtime/common/string | |
| parent | abd0051802e55207e88435a185ff8d6e6b8d17d5 (diff) | |
| download | virtualbox-upstream/3.2.2-dfsg.tar.gz | |
Imported Upstream version 3.2.2-dfsgupstream/3.2.2-dfsg
Diffstat (limited to 'src/VBox/Runtime/common/string')
| -rw-r--r-- | src/VBox/Runtime/common/string/strformat.cpp | 11 | ||||
| -rw-r--r-- | src/VBox/Runtime/common/string/strformatrt.cpp | 33 |
2 files changed, 23 insertions, 21 deletions
diff --git a/src/VBox/Runtime/common/string/strformat.cpp b/src/VBox/Runtime/common/string/strformat.cpp index 9c0b7aa9d..11ed8f4f1 100644 --- a/src/VBox/Runtime/common/string/strformat.cpp +++ b/src/VBox/Runtime/common/string/strformat.cpp @@ -1,4 +1,4 @@ -/* $Id: strformat.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: strformat.cpp 29783 2010-05-25 13:13:35Z vboxsync $ */ /** @file * IPRT - String Formatter. */ @@ -351,7 +351,8 @@ static int rtStrFormatNumber(char *psz, KSIZE64 ullValue, unsigned int uiBase, s * @param pszFormat Format string. * @param InArgs Argument list. */ -RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, const char *pszFormat, va_list InArgs) +RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRFORMAT pfnFormat, void *pvArgFormat, + const char *pszFormat, va_list InArgs) { va_list args; KSIZE cch = 0; @@ -832,12 +833,12 @@ RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRF if (*pszFormat != '[') { pszFormat--; - cch += rtstrFormatRt(pfnOutput, pvArgOutput, &pszFormat, &args, cchPrecision, cchWidth, fFlags, chArgSize); + cch += rtstrFormatRt(pfnOutput, pvArgOutput, &pszFormat, &args, cchWidth, cchPrecision, fFlags, chArgSize); } else { pszFormat--; - cch += rtstrFormatType(pfnOutput, pvArgOutput, &pszFormat, &args, cchPrecision, cchWidth, fFlags, chArgSize); + cch += rtstrFormatType(pfnOutput, pvArgOutput, &pszFormat, &args, cchWidth, cchPrecision, fFlags, chArgSize); } break; } @@ -850,7 +851,7 @@ RTDECL(size_t) RTStrFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, PFNSTRF if (pfnFormat) { pszFormat--; - cch += pfnFormat(pvArgFormat, pfnOutput, pvArgOutput, &pszFormat, &args, cchPrecision, cchWidth, fFlags, chArgSize); + cch += pfnFormat(pvArgFormat, pfnOutput, pvArgOutput, &pszFormat, &args, cchWidth, cchPrecision, fFlags, chArgSize); } break; } diff --git a/src/VBox/Runtime/common/string/strformatrt.cpp b/src/VBox/Runtime/common/string/strformatrt.cpp index 69a5b2d0a..21c82e2a6 100644 --- a/src/VBox/Runtime/common/string/strformatrt.cpp +++ b/src/VBox/Runtime/common/string/strformatrt.cpp @@ -1,4 +1,4 @@ -/* $Id: strformatrt.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: strformatrt.cpp 29963 2010-06-01 16:43:09Z vboxsync $ */ /** @file * IPRT - IPRT String Formatter Extensions. */ @@ -96,11 +96,12 @@ * * Group 3, hex dumpers and other complex stuff which requires more than simple formatting. * - \%Rhxd - Takes a pointer to the memory which is to be dumped in typical - * hex format. Use the width to specify the length, and the precision to + * hex format. Use the precision to specify the length, and the width to * set the number of bytes per line. Default width and precision is 16. * - \%Rhxs - Takes a pointer to the memory to be displayed as a hex string, * i.e. a series of space separated bytes formatted as two digit hex value. - * Use the width to specify the length. Default length is 16 bytes. + * Use the precision to specify the length. Default length is 16 bytes. + * The width, if specified, is ignored. * - \%Rrc - Takes an integer iprt status code as argument. Will insert the * status code define corresponding to the iprt status code. * - \%Rrs - Takes an integer iprt status code as argument. Will insert the @@ -755,8 +756,8 @@ size_t rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **p case 'x': { uint8_t *pu8 = va_arg(*pArgs, uint8_t *); - if (cchWidth <= 0) - cchWidth = 16; + if (cchPrecision <= 0) + cchPrecision = 16; if (pu8) { switch (*(*ppszFormat)++) @@ -769,30 +770,30 @@ size_t rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **p size_t cch = 0; int off = 0; - if (cchPrecision <= 0) - cchPrecision = 16; + if (cchWidth <= 0) + cchWidth = 16; - while (off < cchWidth) + while (off < cchPrecision) { int i; cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%s%0*x %04x:", off ? "\n" : "", sizeof(pu8) * 2, (uintptr_t)pu8, off); - for (i = 0; i < cchPrecision && off + i < cchWidth ; i++) + for (i = 0; i < cchWidth && off + i < cchPrecision ; i++) cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, - off + i < cchWidth ? !(i & 7) && i ? "-%02x" : " %02x" : " ", pu8[i]); - while (i++ < cchPrecision) + off + i < cchPrecision ? !(i & 7) && i ? "-%02x" : " %02x" : " ", pu8[i]); + while (i++ < cchWidth) cch += pfnOutput(pvArgOutput, " ", 3); cch += pfnOutput(pvArgOutput, " ", 1); - for (i = 0; i < cchPrecision && off + i < cchWidth; i++) + for (i = 0; i < cchWidth && off + i < cchPrecision; i++) { uint8_t u8 = pu8[i]; cch += pfnOutput(pvArgOutput, u8 < 127 && u8 >= 32 ? (const char *)&u8 : ".", 1); } /* next */ - pu8 += cchPrecision; - off += cchPrecision; + pu8 += cchWidth; + off += cchWidth; } return cch; } @@ -802,10 +803,10 @@ size_t rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **p */ case 's': { - if (cchWidth-- > 0) + if (cchPrecision-- > 0) { size_t cch = RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "%02x", *pu8++); - for (; cchWidth > 0; cchWidth--, pu8++) + for (; cchPrecision > 0; cchPrecision--, pu8++) cch += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, " %02x", *pu8); return cch; } |
