From 2c113e3365d1e75c6d75d9aad0d35d53c2f15c47 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 27 Jan 2009 14:27:10 +0000 Subject: [PATCH] 2009-01-27 15:31 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/common/hbprintf.c ! fixed two bugs in conversions --- harbour/ChangeLog | 4 ++++ harbour/source/common/hbprintf.c | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cc445993e2..f7f1a97937 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,10 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-27 15:31 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/common/hbprintf.c + ! fixed two bugs in conversions + 2009-01-27 10:14 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com) * harbour/contrib/examples/uhttpd/uhttpd.prg * Fixed APP_NAME that causes wrong ini file name and than error diff --git a/harbour/source/common/hbprintf.c b/harbour/source/common/hbprintf.c index c0ab6fc5c1..f70ca6a39d 100644 --- a/harbour/source/common/hbprintf.c +++ b/harbour/source/common/hbprintf.c @@ -725,12 +725,12 @@ static size_t put_hex( char *buffer, size_t bufsize, size_t size, width -= 2; width -= nums; - if( ( flags & _F_LEFTADJUSTED ) == 0 ) + if( ( flags & ( _F_LEFTADJUSTED | _F_ZEROPADED ) ) == 0 ) { while( width > 0 ) { if( size < bufsize ) - buffer[ size ] = ( flags & _F_ZEROPADED ) ? '0' : ' '; + buffer[ size ] = ' '; ++size; --width; } @@ -744,6 +744,16 @@ static size_t put_hex( char *buffer, size_t bufsize, size_t size, buffer[ size ] = upper ? 'X' : 'x'; ++size; } + if( ( flags & _F_LEFTADJUSTED ) == 0 ) + { + while( width > 0 ) + { + if( size < bufsize ) + buffer[ size ] = ( flags & _F_ZEROPADED ) ? '0' : ' '; + ++size; + --width; + } + } if( nums ) { n = nums; @@ -1054,10 +1064,11 @@ int hb_snprintf_c( char * buffer, size_t bufsize, const char * format, ... ) argval.value.as_x_intmax_t = va_arg_n( args, _x_ptrdiff_t, param ); else argval.value.as_x_intmax_t = va_arg_n( args, _x_int, param ); - argval.value.as_x_uintmax_t = argval.value.as_x_intmax_t < 0 - ? -argval.value.as_x_intmax_t : argval.value.as_x_intmax_t; + value = argval.value.as_x_intmax_t < 0; + argval.value.as_x_uintmax_t = value ? -argval.value.as_x_intmax_t : + argval.value.as_x_intmax_t; size = put_dec( buffer, bufsize, size, argval.value.as_x_uintmax_t, - flags, width, precision, argval.value.as_x_intmax_t < 0 ); + flags, width, precision, value ); continue; case 'o': /* unsigned int octal conversion */ case 'u': /* unsigned int decimal conversion */