misc/hexdump.rb in metasm-1.0.2 vs misc/hexdump.rb in metasm-1.0.3
- old
+ new
@@ -27,11 +27,11 @@
ctx[:lastdup] = false
print '%04x ' % ctx[:pos]
print s.unpack('C*').map { |b| '%02x' % b }.join(' ').ljust(3*16-1) + ' ' if fmt.include? 'c'
print s.unpack('v*').map { |b| '%04x' % b }.join(' ').ljust(5*8-1) + ' ' if fmt.include? 'w'
print s.unpack('L*').map { |b| '%08x' % b }.join(' ').ljust(9*4-1) + ' ' if fmt.include? 'd'
- print s.tr("\0-\x1f\x7f-\xff", '.') if fmt.include? 'a'
+ print s.tr("\0-\x1f\x7f-\xff".force_encoding('BINARY'), '.') if fmt.include? 'a'
puts
elsif not ctx[:lastdup]
ctx[:lastdup] = true
puts '*'
end
@@ -48,9 +48,9 @@
fmt = []
fmt << 'c' if ARGV.delete '-C'
fmt << 'w' if ARGV.delete '-W'
fmt << 'd' if ARGV.delete '-D'
fmt << 'a' if ARGV.delete '-A'
- fmt = ['c', 'd', 'a'] if ARGV.delete '-a'
+ fmt = ['c', 'd', 'a'] if ARGV.delete '-a' or fmt.empty?
infd = ARGV.empty? ? $stdin : File.open(ARGV.first, 'rb')
infd.hexdump(:fmt => fmt)
end