Rewrite od(1)

Looking at the old code, it became clear that the desired
functionality with the t-flag could not be added unless the
underlying data-structures were reworked.
Thus the only way to be successful was to rewrite the whole thing.

od(1) allows giving arbitrarily many type-specs per call, both via
-t x1o2... and -t x1 -t o2 and intermixed.
This fortunately is easy to parse.
Now, to be flexible, it should not only support types of integral
length. Erroring out like this is inacceptable:

$ echo -n "shrek"| od -t u3
od: invalid type string ‘u3’;
this system doesn't provide a 3-byte integral type

Thus, this new od(1) just collects the bytes until shortly before
printing, when the numbers are written into a long long with the
proper offset.
The bytes per line are just the lcm of all given type-lengths and >= 16.
They are equal to 16 for all types that are possible to print using
the old od(1)'s.

Endianness is of course also supported, needs some testing though,
especially on Big Endian systems.
This commit is contained in:
FRIGN
2015-10-09 01:46:56 +02:00
committed by sin
parent 7b9988c7ff
commit 092c95b66c
3 changed files with 185 additions and 60 deletions

2
README
View File

@@ -56,7 +56,7 @@ The following tools are implemented:
=*|o nice .
#*|o nl .
=*|o nohup .
od -t
=* o od .
#*|o paste .
=*|x printenv .
#*|o printf .