[hackers] [sbase] od: Don't modify bytes in the line for the 'a' type || Michael Forney

From: <git_AT_suckless.org>
Date: Mon, 26 Feb 2018 08:02:54 +0100 (CET)

commit f83c468b558d87ca27e99d7d8559eec3281a33c6
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Sun Feb 25 12:56:36 2018 -0800
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Sun Feb 25 23:01:00 2018 -0800

    od: Don't modify bytes in the line for the 'a' type
    
    Subsequent types should still print the full 8-bit value.

diff --git a/od.c b/od.c
index e5dde83..eb63318 100644
--- a/od.c
+++ b/od.c
_AT_@ -36,11 +36,12 @@ printaddress(off_t addr)
 }
 
 static void
-printchunk(unsigned char *s, unsigned char format, size_t len)
+printchunk(const unsigned char *s, unsigned char format, size_t len)
 {
         long long res, basefac;
         size_t i;
         char fmt[] = " %#*ll#";
+ unsigned char c;
 
         const char *namedict[] = {
                 "nul", "soh", "stx", "etx", "eot", "enq", "ack",
_AT_@ -58,11 +59,11 @@ printchunk(unsigned char *s, unsigned char format, size_t len)
 
         switch (format) {
         case 'a':
- *s &= ~128; /* clear high bit as required by standard */
- if (*s < LEN(namedict) || *s == 127) {
- printf(" %3s", (*s == 127) ? "del" : namedict[*s]);
+ c = *s & ~128; /* clear high bit as required by standard */
+ if (c < LEN(namedict) || c == 127) {
+ printf(" %3s", (c == 127) ? "del" : namedict[c]);
                 } else {
- printf(" %3c", *s);
+ printf(" %3c", c);
                 }
                 break;
         case 'c':
_AT_@ -91,7 +92,7 @@ printchunk(unsigned char *s, unsigned char format, size_t len)
 }
 
 static void
-printline(unsigned char *line, size_t len, off_t addr)
+printline(const unsigned char *line, size_t len, off_t addr)
 {
         struct type *t = NULL;
         size_t i;
Received on Mon Feb 26 2018 - 08:02:54 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 26 2018 - 08:12:29 CET