lobase

Linux port of OpenBSDs userland.
Log | Files | Refs | README

commit 5c7bc09a5e6c74b51d291ac0fe7a92443b0d7aca
parent a05c8c6f08889b4f71792a859b2689dc99f67e39
Author: Duncaen <mail@duncano.de>
Date:   Fri, 19 May 2017 18:53:03 +0200

usr.bin/hexdump: update to OPENBSD_6_1

Diffstat:
usr.bin/hexdump/display.c | 18+++++++++---------
usr.bin/hexdump/parse.c | 30++++++++++++++++--------------
2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.24 2016/03/15 04:19:13 mmcc Exp $ */ +/* $OpenBSD: display.c,v 1.25 2016/08/24 03:13:45 guenther Exp $ */ /* $NetBSD: display.c,v 1.12 2001/12/07 15:14:29 bjh21 Exp $ */ /* @@ -100,7 +100,7 @@ display(void) for (pr = endfu->nextpr; pr; pr = pr->nextpr) switch(pr->flags) { case F_ADDRESS: - (void)printf(pr->fmt, (quad_t)eaddress); + (void)printf(pr->fmt, (int64_t)eaddress); break; case F_TEXT: (void)printf("%s", pr->fmt); @@ -123,7 +123,7 @@ print(PR *pr, u_char *bp) switch(pr->flags) { case F_ADDRESS: - (void)printf(pr->fmt, (quad_t)address); + (void)printf(pr->fmt, (int64_t)address); break; case F_BPAD: (void)printf(pr->fmt, ""); @@ -149,15 +149,15 @@ print(PR *pr, u_char *bp) case F_INT: switch(pr->bcnt) { case 1: - (void)printf(pr->fmt, (quad_t)*bp); + (void)printf(pr->fmt, (int64_t)*bp); break; case 2: memmove(&s2, bp, sizeof(s2)); - (void)printf(pr->fmt, (quad_t)s2); + (void)printf(pr->fmt, (int64_t)s2); break; case 4: memmove(&s4, bp, sizeof(s4)); - (void)printf(pr->fmt, (quad_t)s4); + (void)printf(pr->fmt, (int64_t)s4); break; case 8: memmove(&s8, bp, sizeof(s8)); @@ -180,15 +180,15 @@ print(PR *pr, u_char *bp) case F_UINT: switch(pr->bcnt) { case 1: - (void)printf(pr->fmt, (u_quad_t)*bp); + (void)printf(pr->fmt, (uint64_t)*bp); break; case 2: memmove(&u2, bp, sizeof(u2)); - (void)printf(pr->fmt, (u_quad_t)u2); + (void)printf(pr->fmt, (uint64_t)u2); break; case 4: memmove(&u4, bp, sizeof(u4)); - (void)printf(pr->fmt, (u_quad_t)u4); + (void)printf(pr->fmt, (uint64_t)u4); break; case 8: memmove(&u8, bp, sizeof(u8)); diff --git a/usr.bin/hexdump/parse.c b/usr.bin/hexdump/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.20 2016/03/15 04:19:13 mmcc Exp $ */ +/* $OpenBSD: parse.c,v 1.22 2016/09/04 16:41:43 tb Exp $ */ /* $NetBSD: parse.c,v 1.12 2001/12/07 13:37:39 bjh21 Exp $ */ /* @@ -30,6 +30,10 @@ * SUCH DAMAGE. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif /* _GNU_SOURCE */ + #include <sys/types.h> #include <sys/file.h> @@ -147,8 +151,7 @@ add(const char *fmt) for (savep = ++p; *p != '"';) if (*p++ == 0) badfmt(fmt); - tfu->fmt = strndup(savep, p - savep); - if (tfu->fmt == NULL) + if ((tfu->fmt = strndup(savep, p - savep)) == NULL) err(1, NULL); escape(tfu->fmt); p++; @@ -217,9 +220,8 @@ rewrite(FS *fs) PR *pr, **nextpr; FU *fu; char *p1, *p2; - char savech, *fmtp, cs[3]; + char savech, *fmtp, cs[4]; int nconv, prec; - size_t len; nextpr = NULL; prec = 0; @@ -295,9 +297,10 @@ rewrite(FS *fs) else pr->flags = F_UINT; - cs[2] = '\0'; - cs[1] = cs[0]; - cs[0] = 'q'; + cs[3] = '\0'; + cs[2] = cs[0]; + cs[1] = 'l'; + cs[0] = 'l'; switch(fu->bcnt) { case 0: case 4: pr->bcnt = 4; @@ -355,9 +358,10 @@ rewrite(FS *fs) ++p2; switch(p1[2]) { case 'd': case 'o': case'x': - cs[0] = 'q'; - cs[1] = p1[2]; - cs[2] = '\0'; + cs[0] = 'l'; + cs[1] = 'l'; + cs[2] = p1[2]; + cs[3] = '\0'; break; default: if (p1[2]) @@ -406,10 +410,8 @@ rewrite(FS *fs) */ savech = *p2; p1[0] = '\0'; - len = strlen(fmtp) + strlen(cs) + 1; - if ((pr->fmt = calloc(1, len)) == NULL) + if (asprintf(&pr->fmt, "%s%s", fmtp, cs) == -1) err(1, NULL); - snprintf(pr->fmt, len, "%s%s", fmtp, cs); *p2 = savech; pr->cchar = pr->fmt + (p1 - fmtp); fmtp = p2;