Do not confuse the 0 fill magic of wsprintf with the "0x" hex prefix.
diff --git a/misc/wsprintf.c b/misc/wsprintf.c index 96f1efb..9c48305 100644 --- a/misc/wsprintf.c +++ b/misc/wsprintf.c
@@ -237,9 +237,8 @@ break; case WPR_HEXA: len = sprintf( number, - (format->flags & WPRINTF_UPPER_HEX) ? "%X" : "%x", - (UINT)arg->int_view); - if (format->flags & WPRINTF_PREFIX_HEX) len += 2; + (format->flags & WPRINTF_UPPER_HEX) ? "%X" : "%x", + (UINT)arg->int_view); break; default: return 0; @@ -249,6 +248,7 @@ if (format->precision > maxlen) format->precision = maxlen; if ((format->flags & WPRINTF_ZEROPAD) && (format->width > format->precision)) format->precision = format->width; + if (format->flags & WPRINTF_PREFIX_HEX) len += 2; return len; } @@ -351,8 +351,6 @@ *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x'; maxlen -= 2; len -= 2; - format.precision -= 2; - format.width -= 2; } /* fall through */ case WPR_SIGNED: @@ -428,8 +426,6 @@ *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x'; maxlen -= 2; len -= 2; - format.precision -= 2; - format.width -= 2; } /* fall through */ case WPR_SIGNED: @@ -505,8 +501,6 @@ *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x'; maxlen -= 2; len -= 2; - format.precision -= 2; - format.width -= 2; } /* fall through */ case WPR_SIGNED: