Changeset 2836 for trunk/kLdr/kLdrHlp.c
- Timestamp:
- Oct 26, 2006, 5:58:53 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/kLdrHlp.c
r2832 r2836 494 494 495 495 496 /** Internal worker for kldrHlpAssertMsg. */ 497 static void int2dec(char *pszLine, unsigned iLine) 498 { 499 do 500 { 501 *pszLine = (iLine % 10) + '0'; 502 iLine /= 10; 503 } while (iLine); 504 *pszLine++ = '\0'; 496 /** 497 * Converts an signed integer to an ascii string. 498 * 499 * @returns psz. 500 * @param psz Pointer to the output buffer. 501 * @param cch The size of the output buffer. 502 * @param lVal The value. 503 * @param iBase The base to format it. (2,8,10 or 16) 504 */ 505 char *kldrHlpInt2Ascii(char *psz, size_t cch, long lVal, unsigned iBase) 506 { 507 static const char s_szDigits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 508 char *pszRet = psz; 509 510 if (cch >= (lVal < 0 ? 3U : 2U) && psz) 511 { 512 /* prefix */ 513 if (lVal < 0) 514 { 515 *psz++ = '-'; 516 cch--; 517 lVal = -lVal; 518 } 519 520 /* the digits */ 521 do 522 { 523 *psz++ = s_szDigits[lVal % iBase]; 524 cch--; 525 lVal /= iBase; 526 } while (lVal && cch > 1); 527 528 /* overflow indicator */ 529 if (lVal) 530 psz[-1] = '+'; 531 } 532 else if (!pszRet) 533 return pszRet; 534 else if (cch < 1 || !pszRet) 535 return pszRet; 536 else 537 *psz++ = '+'; 538 *psz = '\0'; 539 540 return pszRet; 505 541 } 506 542 … … 574 610 kldrHlpAssertWrite(pszFile); 575 611 kldrHlpAssertWrite("("); 576 int2dec(szLine, iLine); 577 kldrHlpAssertWrite(szLine); 612 kldrHlpAssertWrite(kldrHlpInt2Ascii(szLine, sizeof(szLine), iLine, 10)); 578 613 kldrHlpAssertWrite(") "); 579 614 kldrHlpAssertWrite(pszFunction);
Note:
See TracChangeset
for help on using the changeset viewer.