diff options
author | markus <> | 2003-05-12 02:18:40 +0000 |
---|---|---|
committer | markus <> | 2003-05-12 02:18:40 +0000 |
commit | d4fcd82bb7f6d603bd61e19a81ba97337b89dfca (patch) | |
tree | d52e3a0f1f08f65ad283027e560e17ed0d720462 /src/lib/libcrypto/bio/b_print.c | |
parent | 582bbd139cd2afd58d10dc051c5b0b989b441074 (diff) | |
download | openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.gz openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.bz2 openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.zip |
merge 0.9.7b with local changes; crank majors for libssl/libcrypto
Diffstat (limited to 'src/lib/libcrypto/bio/b_print.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_print.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index 80c9cb69db..a9e552f245 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c | |||
@@ -378,7 +378,7 @@ _dopr( | |||
378 | case 'p': | 378 | case 'p': |
379 | value = (long)va_arg(args, void *); | 379 | value = (long)va_arg(args, void *); |
380 | fmtint(sbuffer, buffer, &currlen, maxlen, | 380 | fmtint(sbuffer, buffer, &currlen, maxlen, |
381 | value, 16, min, max, flags); | 381 | value, 16, min, max, flags|DP_F_NUM); |
382 | break; | 382 | break; |
383 | case 'n': /* XXX */ | 383 | case 'n': /* XXX */ |
384 | if (cflags == DP_C_SHORT) { | 384 | if (cflags == DP_C_SHORT) { |
@@ -482,8 +482,9 @@ fmtint( | |||
482 | int flags) | 482 | int flags) |
483 | { | 483 | { |
484 | int signvalue = 0; | 484 | int signvalue = 0; |
485 | char *prefix = ""; | ||
485 | unsigned LLONG uvalue; | 486 | unsigned LLONG uvalue; |
486 | char convert[20]; | 487 | char convert[DECIMAL_SIZE(value)+3]; |
487 | int place = 0; | 488 | int place = 0; |
488 | int spadlen = 0; | 489 | int spadlen = 0; |
489 | int zpadlen = 0; | 490 | int zpadlen = 0; |
@@ -501,6 +502,10 @@ fmtint( | |||
501 | else if (flags & DP_F_SPACE) | 502 | else if (flags & DP_F_SPACE) |
502 | signvalue = ' '; | 503 | signvalue = ' '; |
503 | } | 504 | } |
505 | if (flags & DP_F_NUM) { | ||
506 | if (base == 8) prefix = "0"; | ||
507 | if (base == 16) prefix = "0x"; | ||
508 | } | ||
504 | if (flags & DP_F_UP) | 509 | if (flags & DP_F_UP) |
505 | caps = 1; | 510 | caps = 1; |
506 | do { | 511 | do { |
@@ -508,13 +513,13 @@ fmtint( | |||
508 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") | 513 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
509 | [uvalue % (unsigned) base]; | 514 | [uvalue % (unsigned) base]; |
510 | uvalue = (uvalue / (unsigned) base); | 515 | uvalue = (uvalue / (unsigned) base); |
511 | } while (uvalue && (place < 20)); | 516 | } while (uvalue && (place < sizeof convert)); |
512 | if (place == 20) | 517 | if (place == sizeof convert) |
513 | place--; | 518 | place--; |
514 | convert[place] = 0; | 519 | convert[place] = 0; |
515 | 520 | ||
516 | zpadlen = max - place; | 521 | zpadlen = max - place; |
517 | spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0); | 522 | spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0) - strlen(prefix); |
518 | if (zpadlen < 0) | 523 | if (zpadlen < 0) |
519 | zpadlen = 0; | 524 | zpadlen = 0; |
520 | if (spadlen < 0) | 525 | if (spadlen < 0) |
@@ -536,6 +541,12 @@ fmtint( | |||
536 | if (signvalue) | 541 | if (signvalue) |
537 | doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); | 542 | doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue); |
538 | 543 | ||
544 | /* prefix */ | ||
545 | while (*prefix) { | ||
546 | doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix); | ||
547 | prefix++; | ||
548 | } | ||
549 | |||
539 | /* zeros */ | 550 | /* zeros */ |
540 | if (zpadlen > 0) { | 551 | if (zpadlen > 0) { |
541 | while (zpadlen > 0) { | 552 | while (zpadlen > 0) { |
@@ -641,8 +652,8 @@ fmtfp( | |||
641 | (caps ? "0123456789ABCDEF" | 652 | (caps ? "0123456789ABCDEF" |
642 | : "0123456789abcdef")[intpart % 10]; | 653 | : "0123456789abcdef")[intpart % 10]; |
643 | intpart = (intpart / 10); | 654 | intpart = (intpart / 10); |
644 | } while (intpart && (iplace < 20)); | 655 | } while (intpart && (iplace < sizeof iplace)); |
645 | if (iplace == 20) | 656 | if (iplace == sizeof iplace) |
646 | iplace--; | 657 | iplace--; |
647 | iconvert[iplace] = 0; | 658 | iconvert[iplace] = 0; |
648 | 659 | ||
@@ -653,7 +664,7 @@ fmtfp( | |||
653 | : "0123456789abcdef")[fracpart % 10]; | 664 | : "0123456789abcdef")[fracpart % 10]; |
654 | fracpart = (fracpart / 10); | 665 | fracpart = (fracpart / 10); |
655 | } while (fplace < max); | 666 | } while (fplace < max); |
656 | if (fplace == 20) | 667 | if (fplace == sizeof fplace) |
657 | fplace--; | 668 | fplace--; |
658 | fconvert[fplace] = 0; | 669 | fconvert[fplace] = 0; |
659 | 670 | ||
@@ -692,7 +703,7 @@ fmtfp( | |||
692 | * Decimal point. This should probably use locale to find the correct | 703 | * Decimal point. This should probably use locale to find the correct |
693 | * char to print out. | 704 | * char to print out. |
694 | */ | 705 | */ |
695 | if (max > 0) { | 706 | if (max > 0 || (flags & DP_F_NUM)) { |
696 | doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); | 707 | doapr_outch(sbuffer, buffer, currlen, maxlen, '.'); |
697 | 708 | ||
698 | while (fplace > 0) | 709 | while (fplace > 0) |