Subject: bug#16578: Wish: Support for non-native endianness in od

From: Jim Meyering <[email-masked]>
Date: Sat, 8 Feb 2014 17:23:21 -0800

On Sat, Feb 8, 2014 at 2:01 PM, Pádraig Brady <[email-masked]> wrote:
>>> +      if (input_swap && sizeof(T) > 1)                                  \
>>> +        {                                                               \
>>> +          int j;                                                        \

The new patch looks complete.  Thanks to both of you.
One nit: please change the type of "j" here (identical in attached)
to be unsigned, to match that of the upper bound.

>>> +          union {                                                       \
>>> +            T x;                                                        \
>>> +            char b[sizeof(T)];                                          \
>>> +          } u;                                                          \
>>> +          for (j = 0; j < sizeof(T); j++)                               \
>>> +            u.b[j] = ((const char *) p)[sizeof(T) - 1 - j];             \

Re this function in the new test,

> +in_swapped() { printf '%s' "$in" | sed "s/.\{$1\}/&\\n/g" | rev | tr -d '\n'; }

That would be our first use of "rev". Is it ubiquitous enough to depend on?