From: Hugo van der Sanden Date: Sun, 2 Nov 1997 13:31:54 +0000 (+0000) Subject: [win32] still another maintpatch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c10ed8b9e8edf0b40762507fd9f81cf68f67e9b2;p=p5sagit%2Fp5-mst-13.2.git [win32] still another maintpatch Message-Id: <199711021331.NAA01826@crypt.compulink.co.uk> Subject: [PATCH] assorted sprintf bugs p4raw-id: //depot/win32/perl@631 --- diff --git a/sv.c b/sv.c index 2c5f4df..d4edad4 100644 --- a/sv.c +++ b/sv.c @@ -4573,6 +4573,8 @@ sv_vcatpvfn(SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, switch (base) { unsigned dig; case 16: + if (!uv) + alt = FALSE; p = (c == 'X') ? "0123456789ABCDEF" : "0123456789abcdef"; do { dig = uv & 15; @@ -4599,8 +4601,12 @@ sv_vcatpvfn(SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, break; } elen = (ebuf + sizeof ebuf) - eptr; - if (has_precis && precis > elen) - zeros = precis - elen; + if (has_precis) { + if (precis > elen) + zeros = precis - elen; + else if (precis == 0 && elen == 1 && *eptr == '0') + elen = 0; + } break; /* FLOATING POINT */ diff --git a/t/op/sprintf.t b/t/op/sprintf.t index 1450ae3..7556c80 100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -14,8 +14,8 @@ $SIG{__WARN__} = sub { }; $w = 0; -$x = sprintf("%3s %-4s%%foo %5d%c%3.1f","hi",123,456,65,3.0999); -if ($x eq ' hi 123 %foo 456A3.1' && $w == 0) { +$x = sprintf("%3s %-4s%%foo %.0d%5d %#x%c%3.1f","hi",123,0,456,0,65,3.0999); +if ($x eq ' hi 123 %foo 456 0A3.1' && $w == 0) { print "ok 1\n"; } else { print "not ok 1 '$x'\n";