[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding hex+zero-index offsets output to cmp (freebsd -x option)?

From: JD Fenech
Subject: Adding hex+zero-index offsets output to cmp (freebsd -x option)?
Date: Sun, 2 Jan 2022 16:55:36 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

I'm not sure how you guys do things here, so I'll keep it brief.

The version of cmp included with my version of Mint is 3.7, so I downloaded the official source tarball of 3.8 and built it. Easy enough. However, it does not include any option to output values and offsets as zero-indexed offsets and hexadecimal base. The offsets are one-indexed and printed as decimal, while the values of differing bytes are given in octal. Not really a showstopper, but also not especially convenient for programmers who prefer/are used to working with hexadecimal, zero-indexed offsets and working with hexadecimal values.

Obviously cmp has been around for awhile, so I'm not asking to change the default behavior. However, in looking into why things are what they are, I noticed that the freebsd version includes an -x option (exactly the same option name I would have picked, too) that does exactly what I want, but the mainstream ones do not. It should be quite a simple matter to include this as an option without breaking compatibility, I suspect. I was able to modify my own copy (without adding the command line switch, I just tweaked the output) to display the values in hex and the location as a zero-index offset. No clue why the location is converted to a string for output yet, but it's still in decimal.

So I can't imagine it would be much more work to add the option to tweak the output and copy a few lines with a different format string, or even port the analogous line from the freebsd version (the freebsd license doesn't seem to forbid this, but I'm not an expert on it).

Is this something that someone would be interested in 1) adding for the next version or 2) incorporating if I added it myself and provided a diff? I'm willing to get my hands dirty adding it if there's a reasonable chance it will get included.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]