bug-textutils
[Top][All Lists]
Advanced

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

[textutils-2.0] [od] feature suggestion


From: Roth, Kevin P.
Subject: [textutils-2.0] [od] feature suggestion
Date: Thu, 11 Oct 2001 14:41:35 -0400

My platform:

  $ uname -a
  CYGWIN_NT-5.0 FDYP143578 1.3.3(0.46/3/2) 2001-09-12 23:54 i686 unknown

I was attempting to get od to output hex characters and ascii characters lined up on top of each other, like so:

   0000000  t  h  i  s     i  s     l  i  n  e     o  n  e
           74 68 69 73 20 69 73 20 6c  69 6e 65 20 6f 6e 65

but the closest I could get seemed to be:

   $ od -tcx1 filename
   0000000   t   h   i   s       i   s       l   i   n   e       o   n   e
           74 68 69 73 20 69 73 20 6c 69 6e 65 20 6f 6e 65


So I change the print_ascii function to get me what I wanted. See diff below. If it looks OK, it should most likely be altered to be an alternative within print_ascii (the two options so far would be to print each byte in 3-characters worth of space (along with octal values for non-printables) or in 2-characters worth of space (along with hex values for non-printables).

As for the command-line option to enable the new format, I'll suggest -tcX for hex or -tcO for octal.


$ diff -uP src/od.c.orig  src/od.c
--- src/od.c.orig   Wed Apr 21 22:30:45 1999
+++ src/od.c        Thu Oct 11 14:34:50 2001
@@ -570,11 +570,11 @@
          break;

        default:
-         sprintf (buf, (ISPRINT (c) ? "  %c" : "%03o"), c);
+         sprintf (buf, (ISPRINT (c) ? "  %c" : " %02x"), c); //was %03o
          s = (const char *) buf;
        }

-      printf (" %3s", s);
+      printf ("%3s", s);
       block += sizeof (unsigned char);
     }
 }



--Kevin Roth


reply via email to

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