Changeset 40186 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Feb 21, 2012 12:04:21 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 76350
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformat.cpp
r38659 r40186 148 148 * @param fFlags Flags (NTFS_*). 149 149 */ 150 RTDECL(int) RTStrFormatNumber(char *psz, uint64_t u64Value, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, unsigned int fFlags) 150 RTDECL(int) RTStrFormatNumber(char *psz, uint64_t u64Value, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, 151 unsigned int fFlags) 151 152 { 152 153 return rtStrFormatNumber(psz, *(KSIZE64 *)(void *)&u64Value, uiBase, cchWidth, cchPrecision, fFlags); … … 167 168 * @param fFlags Flags (NTFS_*). 168 169 */ 169 static int rtStrFormatNumber(char *psz, KSIZE64 ullValue, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, unsigned int fFlags) 170 static int rtStrFormatNumber(char *psz, KSIZE64 ullValue, unsigned int uiBase, signed int cchWidth, signed int cchPrecision, 171 unsigned int fFlags) 170 172 { 171 173 const char *pachDigits = "0123456789abcdef"; 172 174 char *pszStart = psz; 175 int cchMax; 173 176 int cchValue; 174 177 unsigned long ul; … … 251 254 * width - only if ZEROPAD 252 255 */ 256 cchMax = 64 - (cchValue + i + 1); /* HACK! 64 bytes seems to be the usual buffer size... */ 253 257 cchWidth -= i + cchValue; 254 258 if (fFlags & RTSTR_F_ZEROPAD) 255 while (--cchWidth >= 0 )259 while (--cchWidth >= 0 && i < cchMax) 256 260 { 261 AssertBreak(i < cchMax); 257 262 psz[i++] = '0'; 258 263 cchPrecision--; … … 260 265 else if (!(fFlags & RTSTR_F_LEFT) && cchWidth > 0) 261 266 { 262 for (j = i-1; j >= 0; j--) 267 AssertStmt(cchWidth < cchMax, cchWidth = cchMax - 1); 268 for (j = i - 1; j >= 0; j--) 263 269 psz[cchWidth + j] = psz[j]; 264 270 for (j = 0; j < cchWidth; j++) … … 266 272 i += cchWidth; 267 273 } 268 psz += i;269 270 274 271 275 /* … … 273 277 */ 274 278 while (--cchPrecision >= cchValue) 275 *psz++ = '0'; 279 { 280 AssertBreak(i < cchMax); 281 psz[i++] = '0'; 282 } 283 284 psz += i; 276 285 277 286 /*
Note:
See TracChangeset
for help on using the changeset viewer.