Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hexd for openSUSE:Factory checked in at 2022-02-25 21:25:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hexd (Old) and /work/SRC/openSUSE:Factory/.hexd.new.1958 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hexd" Fri Feb 25 21:25:10 2022 rev:3 rq:957506 version:1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/hexd/hexd.changes 2018-02-18 11:45:40.670463820 +0100 +++ /work/SRC/openSUSE:Factory/.hexd.new.1958/hexd.changes 2022-02-25 21:25:40.963644850 +0100 @@ -1,0 +2,11 @@ +Thu Feb 24 20:35:21 UTC 2022 - Martin Hauke <mar...@gmx.de> + +- Update to version 1.1.0 + * default to colours/formatting based on whether output is a TTY + * add verbose option to show all bytes (and not omit repeated + lines) + * add -h as an option to show usage + * fix misaligned output in case -w width doesn't divide BUFSIZ + * fix downcasting issue from off_t to a potentially smaller size + +------------------------------------------------------------------- Old: ---- hexd-1.0.0.tar.gz New: ---- hexd-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hexd.spec ++++++ --- /var/tmp/diff_new_pack.vNoIuE/_old 2022-02-25 21:25:41.427644933 +0100 +++ /var/tmp/diff_new_pack.vNoIuE/_new 2022-02-25 21:25:41.431644933 +0100 @@ -1,8 +1,8 @@ # # spec file for package hexd # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. -# Copyright (c) 2017, Martin Hauke <mar...@gmx.de> +# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2017-2022, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -13,18 +13,18 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: hexd -Version: 1.0.0 +Version: 1.1.0 Release: 0 Summary: Colourful, human-friendly hexdump tool License: MIT Group: Development/Tools/Debuggers -Url: https://github.com/FireyFly/hexd.git -Source: https://github.com/FireyFly/hexd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +URL: https://github.com/FireyFly/hexd.git +Source: https://github.com/FireyFly/hexd/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz %description hexd prints a human-readable hexdump of the specified files, or ++++++ hexd-1.0.0.tar.gz -> hexd-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexd-1.0.0/.gitignore new/hexd-1.1.0/.gitignore --- old/hexd-1.0.0/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.1.0/.gitignore 2022-02-18 12:53:14.000000000 +0100 @@ -0,0 +1 @@ +/hexd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexd-1.0.0/CHANGELOG.md new/hexd-1.1.0/CHANGELOG.md --- old/hexd-1.0.0/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.1.0/CHANGELOG.md 2022-02-18 12:53:14.000000000 +0100 @@ -0,0 +1,11 @@ +# Changelog + +## 1.1.0 + * default to colours/formatting based on whether output is a TTY + * add verbose option to show all bytes (and not omit repeated lines) + * add -h as an option to show usage + * fix misaligned output in case -w width doesn't divide BUFSIZ + * fix downcasting issue from `off_t` to a potentially smaller size + +## 1.0.0 + initial release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexd-1.0.0/Makefile new/hexd-1.1.0/Makefile --- old/hexd-1.0.0/Makefile 2017-11-12 18:51:43.000000000 +0100 +++ new/hexd-1.1.0/Makefile 2022-02-18 12:53:14.000000000 +0100 @@ -1,27 +1,17 @@ CFLAGS += -Wall -std=c11 -ifeq ($(DEBUG),1) - CFLAGS += -g -DDEBUG -endif - -PREFIX=/usr/local -BINDIR=$(PREFIX)/bin -SHAREDIR=$(PREFIX)/share +PREFIX ?= /usr/local +BINDIR ?= $(PREFIX)/bin +MANDIR ?= $(PREFIX)/share/man .PHONY: all -all: hexd hexd.1.gz +all: hexd .PHONY: clean clean: - rm -f hexd hexd.1.gz + rm -f hexd .PHONY: install -install: +install: hexd install -D hexd $(DESTDIR)$(BINDIR)/hexd - install -D hexd.1.gz $(DESTDIR)$(SHAREDIR)/man/man1/hexd.1.gz - -hexd: hexd.c - $(CC) $(CFLAGS) -o $@ $^ - -hexd.1.gz: hexd.1 - gzip -k hexd.1 + install -D hexd.1 $(DESTDIR)$(MANDIR)/man1/hexd.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexd-1.0.0/hexd.1 new/hexd-1.1.0/hexd.1 --- old/hexd-1.0.0/hexd.1 2017-11-12 18:51:43.000000000 +0100 +++ new/hexd-1.1.0/hexd.1 2022-02-18 12:53:14.000000000 +0100 @@ -1,4 +1,4 @@ -.Dd October 11, 2016 +.Dd February 18, 2022 .Dt HEXD 1 .Os .Sh NAME @@ -7,6 +7,8 @@ .Sh SYNOPSIS .Nm .Op Fl p +.Op Fl P +.Op Fl v .Op Fl g Ar groupsize .Op Fl r Ar range .Op Fl w Ar width @@ -30,14 +32,27 @@ and .Em all .Li ( 0xFF ) . +.Pp +By default, colours are used if output is a terminal, and omitted if not. +.Pp +Repeated output lines are collapsed into only one copy followed by a line with +only '*', unless +.Fl v +is used. .Sh OPTIONS If no .Ar file operands are specified, standard input is read instead. Available options are listed below. .Bl -tag -width Ds +.It Fl h +Print usage information. .It Fl p Plain: disable colours/formatting. +.It Fl P +Pretty: enable colours/formatting. +.It Fl v +Verbose: show every hexdump line (don't collapse repetition with '*'). .It Fl g Ar groupsize Number of octets per group, set to .Li 8 @@ -94,7 +109,7 @@ Show the first 16 bytes of each of the *.bin files, with a heading above each file (if more than one). This is useful for example to compare headers of several samples of an unknown format. -.It Em curl -s http://example.com | hexd | less -R +.It Em curl -s http://example.com | hexd -P | less -R .Nm works as a filter, too. For paging long hexdumps, .Xr less 1 Ns 's @@ -107,4 +122,4 @@ .Xr xxd 1 .Sh AUTHORS Written by -.An Jonas ???FireFly??? H??glund. +.An FireFly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hexd-1.0.0/hexd.c new/hexd-1.1.0/hexd.c --- old/hexd-1.0.0/hexd.c 2017-11-12 18:51:43.000000000 +0100 +++ new/hexd-1.1.0/hexd.c 2022-02-18 12:53:14.000000000 +0100 @@ -18,6 +18,7 @@ size_t option_columns = 16; size_t option_groupsize = 8; bool option_use_formatting = true; +bool option_collapse_repetition = true; struct offset_range option_range = { 0, -1 }; const char *formatting_zero = "38;5;238"; @@ -47,7 +48,7 @@ }; void hexdump(FILE *f, const char *filename) { - u8 buf[BUFSIZ]; + u8 line[option_columns]; u8 prev_line[option_columns]; bool first_line = true, printed_asterisk = false; @@ -55,72 +56,65 @@ // Seek to start; fall back to a consuming loop for non-seekable files if (fseeko(f, option_range.start, SEEK_SET) < 0) { off_t remaining = option_range.start; - while (remaining != 0 && !feof(f) && !ferror(f)) { - size_t n = fread(buf, 1, MIN(remaining, BUFSIZ), f); - remaining -= n; - if (n == 0) break; - } + while (remaining != 0 && fgetc(f) != EOF) remaining--; if (ferror(f)) err(1, "(while seeking) %s", filename); } - off_t count = option_range.end - option_range.start; - off_t read = 0; - while (read != count && !feof(f) && !ferror(f)) { - size_t to_read = option_range.end == -1? BUFSIZ : MIN(count - read, BUFSIZ); - size_t n = fread(buf, 1, to_read, f); - - for (size_t i = 0; i < n; i += option_columns) { - u8 *p = &buf[i]; - - // Contract repeated identical lines - if (!first_line && memcmp(p, prev_line, option_columns) == 0) { - if (!printed_asterisk) { - printf("%8s\n", "*"); - printed_asterisk = true; - } - continue; + for (off_t offset = option_range.start; offset < option_range.end || option_range.end == -1; offset += option_columns) { + off_t read = offset - option_range.start; + size_t n = fread(line, 1, option_columns, f); + if (n == 0) break; + + // Contract repeated identical lines + if (!first_line + && option_collapse_repetition + && memcmp(line, prev_line, option_columns) == 0 + && n == option_columns) { + if (!printed_asterisk) { + printf("%8s\n", "*"); + printed_asterisk = true; } - printed_asterisk = false; + continue; + } + printed_asterisk = false; - // Offset - size_t offset = option_range.start + read + i; - printf("%5zx%03zx", offset >> 12, offset & 0xFFF); - - // Print hex area - const char *prev_fmt = NULL; - for (size_t j = 0; j < option_columns; j++) { - if (option_groupsize != 0 && j % option_groupsize == 0) printf(" "); - if (i + j < n) { - const char *fmt = format_of(p[j]); - if (prev_fmt != fmt && option_use_formatting) printf("\x1B[%sm", fmt); - printf(" %02x", p[j]); - prev_fmt = fmt; - } else { - printf(" "); - } + // Offset + intmax_t offset = option_range.start + read; + printf("%5jx%03jx", offset >> 12, offset & 0xFFF); + + // Print hex area + const char *prev_fmt = NULL; + for (size_t j = 0; j < option_columns; j++) { + if (option_groupsize != 0 && j % option_groupsize == 0) printf(" "); + if (j < n) { + const char *fmt = format_of(line[j]); + if (prev_fmt != fmt && option_use_formatting) printf("\x1B[%sm", fmt); + printf(" %02x", line[j]); + prev_fmt = fmt; + } else { + printf(" "); } - putchar(' '); + } + putchar(' '); - // Print char area - for (size_t j = 0; j < option_columns; j++) { - if (option_groupsize != 0 && j % option_groupsize == 0) printf(" "); - if (i + j < n) { - const char *fmt = format_of(p[j]); - if (prev_fmt != fmt && option_use_formatting) printf("\x1B[%sm", fmt); - if (p[j] >= 0x80) printf("%s", CHAR_AREA_HIGH_LUT[p[j] - 0x80]); - else putchar(isprint(p[j])? p[j] : '.'); - prev_fmt = fmt; - } else { - putchar(' '); - } + // Print char area + for (size_t j = 0; j < option_columns; j++) { + if (option_groupsize != 0 && j % option_groupsize == 0) printf(" "); + if (j < n) { + const char *fmt = format_of(line[j]); + if (prev_fmt != fmt && option_use_formatting) printf("\x1B[%sm", fmt); + if (line[j] >= 0x80) printf("%s", CHAR_AREA_HIGH_LUT[line[j] - 0x80]); + else putchar(isprint(line[j])? line[j] : '.'); + prev_fmt = fmt; + } else { + putchar(' '); } - printf("%s\n", option_use_formatting? "\x1B[m" : ""); - - memcpy(prev_line, p, MIN(n - i, option_columns)); - first_line = false; } + printf("%s\n", option_use_formatting? "\x1B[m" : ""); - read += n; + memcpy(prev_line, line, n); + first_line = false; + if (n < option_columns) break; } if (ferror(f)) err(1, "(while reading) %s", filename); @@ -155,16 +149,22 @@ } int main(int argc, char *argv[]) { + // Default to colourful output if output is a TTY + option_use_formatting = isatty(1); + // Parse options int opt; - while (opt = getopt(argc, argv, "g:pr:w:"), opt != -1) { + while (opt = getopt(argc, argv, "g:hpPr:w:v"), opt != -1) { switch (opt) { case 'g': option_groupsize = atol(optarg); break; case 'p': option_use_formatting = false; break; + case 'P': option_use_formatting = true; break; case 'r': option_range = parse_range(optarg); break; + case 'v': option_collapse_repetition = false; break; case 'w': option_columns = atol(optarg); break; + case 'h': // fall through default: - fprintf(stderr, "usage: hexd [-p] [-g groupsize] [-r range] [-w width]\n"); + fprintf(stderr, "usage: hexd [-p] [-P] [-v] [-g groupsize] [-r range] [-w width]\n"); return 1; } } @@ -195,7 +195,7 @@ if (argc == 0) { hexdump(stdin, "(stdin)"); } else { - for (size_t i = 0; i < argc; i++) { + for (int i = 0; i < argc; i++) { FILE *f = fopen(argv[i], "r"); if (f == NULL) { warn("%s", argv[i]);