Skip Menu |

This queue is for tickets about the Data-Hexdumper CPAN distribution.

Report information
The Basics
Id: 70152
Status: rejected
Priority: 0/
Queue: Data-Hexdumper

People
Owner: Nobody in particular
Requestors: STEFFENW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3.00
Fixed in: (no value)



Subject: Dumps more then real count of bytes
Look here: http://www.cpantesters.org/cpan/report/798b2e8a-be8d-11e0-aa2e- ba5fa55619fb I use your module to test my Module that produces binary output data. The broken test is a hexdump compared with Test::Differences eq_or_diff. Test::NoWarnings fails on Data-Hexdumper warning about filling with 00. I think, that is not a good idea to fill with 00 because I can not see if it is a real 00 from data or a filled 00 from module. --Steffen
Here the broken Code: http://cpansearch.perl.org/src/STEFFENW/Locale-MO- File-0.01/t/10_simple_data.t
The way out of that problem is to calculate the string length of a formatted number like this. Now you fill like that pack('C', 0) The equivalent length as spaces is ' ' x length( pack('C', 0) ) # result is ' ' Prints the same count as spaces like pack would be print as number. If you pack another format like 'L' it works. ' ' x length( pack('L', 0) ) # result is ' ' Otherwise you have the Hash %num_bytes with the format and length, so you can write ' ' x $num_byts{'%L'} # result is also ' '
On Tue Aug 09 01:46:04 2011, STEFFENW wrote: Show quoted text
> The way out of that problem is to calculate the string length of a > formatted number like this....
The problem comes when you've asked it to format the output as quads (64 bit values) but only have enough data for, for example, 5 of the last 8 bytes. While I agree that padding with zeroes is problematic, anything else means that the last the last line of output will not be formatted as quads. It would be highly misleading to, for example, format it as a 32 bit value and an 8 bit value, especially when you take endian-ness into account. However, what you've been bitten by is the incompatible change in the most recent version, noted here: http://search.cpan.org/~dcantrell/Data-Hexdumper- 3.00/lib/Data/Hexdumper.pm#INCOMPATIBLE_CHANGES which is a result of my switching to a more flexible way of specifying output formats. Unfortunately an implementation detail (number_formats are implemented in terms of the new output_format) means that old-style number_formats now have to be padded to multiples of sixteen bytes. The code will have emitted warnings about that, unless you have suppress_warnings turned on. I would be happy to accept a patch to fix this - at least to fix the problem with padding if using number_format - but it ain't gonna be simple.
Wrote Test::HexDifferences with Test::HexDifferences::HexDump for that problem. This fixed the problems with less bytes than the format. It always prints exactly the count of got bytes, no more and no less for every format. Thank you for inspirating for that module.