Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package hex for openSUSE:Factory checked in at 2024-03-01 23:34:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hex (Old) and /work/SRC/openSUSE:Factory/.hex.new.1770 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hex" Fri Mar 1 23:34:25 2024 rev:20 rq:1153157 version:1.11 Changes: -------- --- /work/SRC/openSUSE:Factory/hex/hex.changes 2024-02-23 16:41:01.625979630 +0100 +++ /work/SRC/openSUSE:Factory/.hex.new.1770/hex.changes 2024-03-01 23:34:31.611118539 +0100 @@ -1,0 +2,25 @@ +Thu Feb 29 10:07:19 UTC 2024 - pgaj...@suse.com + +- version update to 1.11 [bsc#1220491] + 1.11: 2024-02-07:: + Ship 6 bytes of address ratrher than 4, files run bigger these days. + Update to modern C style standard. + 1.10: 2019-06-12:: + Name changed to hexd to avoid collision with BSD hexdump. + License changed to BSD-2-clause. + 1.9: 2015-04-02:: + Administrivial release; Gitorious is dying, project metadata must change. + 1.8: 2012-12-03:: + Use C99 bools. Code passes cppcheck audit. Added a regression test. + 1.7: 2010-10-20:: + Code fully ANSIfied. License changed to BSD. RPM spec removed. + 1.6: 2003-12-29:: + Source RPMs no longer depend on --define myversion + 1.5: 2003-12-26:: + Name changed to 'hexd'. +- deleted patches + - hex-1.4.diff (renamed) +- added patches + + hex.diff + +------------------------------------------------------------------- Old: ---- hex-1.4.diff hex-1.4.tar.gz New: ---- hex.diff hexd-1.11.tar.gz BETA DEBUG BEGIN: Old:- deleted patches - hex-1.4.diff (renamed) - added patches BETA DEBUG END: BETA DEBUG BEGIN: New:- added patches + hex.diff BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hex.spec ++++++ --- /var/tmp/diff_new_pack.JiVuND/_old 2024-03-01 23:34:34.123209387 +0100 +++ /var/tmp/diff_new_pack.JiVuND/_new 2024-03-01 23:34:34.139209966 +0100 @@ -1,7 +1,7 @@ # # spec file for package hex # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,20 +12,20 @@ # 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: hex -# I am not inclined towards the update to 1.8, see bsc#806703 -Version: 1.4 +Version: 1.11 Release: 0 Summary: Yet Another Hex Dumper License: BSD-3-Clause Group: Development/Tools/Other -Url: http://www.catb.org/~esr/hexdump/ -Source: http://www.catb.org/~esr/hexdump/%{name}-%{version}.tar.gz -Patch0: %{name}-%{version}.diff +URL: http://www.catb.org/~esr/hexd/index.html +Source: http://www.catb.org/~esr/hexd/hexd-1.11.tar.gz +Patch0: %{name}.diff +BuildRequires: rubygem(asciidoctor) Provides: util-linux:%{_bindir}/hex BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -34,7 +34,7 @@ internationalization support. %prep -%autosetup -p0 +%autosetup -p1 -n hexd-%{version} %build make %{?_smp_mflags} clean @@ -46,7 +46,7 @@ %files %defattr(-,root,root) -%doc READ.ME +%doc README NEWS.adoc %doc %{_mandir}/man?/* %{_bindir}/hex ++++++ hex-1.4.diff -> hex.diff ++++++ --- /work/SRC/openSUSE:Factory/hex/hex-1.4.diff 2011-09-23 02:02:46.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.hex.new.1770/hex.diff 2024-03-01 23:34:31.715122301 +0100 @@ -1,33 +1,35 @@ ---- Makefile -+++ Makefile -@@ -4,7 +4,7 @@ - VERS=1.4 - - hex: hex.c -- $(CC) -DRELEASE=\"$(VERS)\" -O hex.c -o hex -+ $(CC) -DRELEASE=\"$(VERS)\" $(CFLAGS) hex.c -o hex - - SOURCES = READ.ME Makefile hex.c hex.xml hex.spec - -@@ -18,8 +18,8 @@ - xmlto man hex.xml - - install: hex.1 uninstall -- cp hex /usr/bin -- cp hex.1 /usr/share/man/man1/hex.1 -+ install -m 0755 hex $(DESTDIR)/usr/bin/ -+ install -m 0644 hex.1 $(DESTDIR)$(MANDIR)/man1/ +Index: hexd-1.11/Makefile +=================================================================== +--- hexd-1.11.orig/Makefile ++++ hexd-1.11/Makefile +@@ -5,7 +5,7 @@ + VERS=$(shell sed -n <NEWS.adoc '/^[0-9]/s/:.*//p' | head -1) + + hexd: hexd.c +- $(CC) -DRELEASE=\"$(VERS)\" -O hexd.c -o hexd ++ $(CC) -DRELEASE=\"$(VERS)\" -O $(CFLAGS) hexd.c -o hexd + + SOURCES = README COPYING NEWS.adoc control Makefile hexd.c hexd.adoc + +@@ -27,8 +27,8 @@ hexd-$(VERS).tar.gz: $(SOURCES) hexd.1 + asciidoctor -D. -a nofooter -a webfonts! $< + + install: hexd.1 uninstall +- cp hexd /usr/bin +- cp hexd.1 /usr/share/man/man1/hexd.1 ++ install -m 0755 hexd $(DESTDIR)/usr/bin/hex ++ install -m 0644 hexd.1 $(DESTDIR)$(MANDIR)/man1/hex.1 uninstall: - rm -f /usr/bin/hex /usr/share/man/man1/hex. ---- hex.1 -+++ hex.1 -@@ -55,7 +55,7 @@ - dump file section - - .TP ----V -+-V - print version number and exit - - .PP + rm -f /usr/bin/hexd /usr/share/man/man1/hexd. +Index: hexd-1.11/hexd.1 +=================================================================== +--- hexd-1.11.orig/hexd.1 ++++ hexd-1.11/hexd.1 +@@ -105,4 +105,4 @@ Eric S. Raymond \c + See my home page at + .URL "http://www.catb.org/~esr" "" "" + for updates and +-related resources. +\ No newline at end of file ++related resources. ++++++ hex-1.4.tar.gz -> hexd-1.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/COPYING new/hexd-1.11/COPYING --- old/hex-1.4/COPYING 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/COPYING 2016-01-09 08:15:28.000000000 +0100 @@ -0,0 +1,27 @@ + BSD LICENSE + +Copyright (c) 2015, Eric S. Raymond +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/Makefile new/hexd-1.11/Makefile --- old/hex-1.4/Makefile 2003-03-04 13:02:14.000000000 +0100 +++ new/hexd-1.11/Makefile 2024-02-01 23:50:00.000000000 +0100 @@ -1,40 +1,55 @@ -# Makefile for Eric Raymond's silly hex dumper +# Makefile for Eric Raymond's CP/M-like hex dumper +# SPDX-FileCopyrightText: (C) Eric S. Raymond <e...@thyrsus.com> +# SPDX-License-Identifier: BSD-2-Clause + +VERS=$(shell sed -n <NEWS.adoc '/^[0-9]/s/:.*//p' | head -1) + +hexd: hexd.c + $(CC) -DRELEASE=\"$(VERS)\" -O hexd.c -o hexd + +SOURCES = README COPYING NEWS.adoc control Makefile hexd.c hexd.adoc + +hexd-$(VERS).tar.gz: $(SOURCES) hexd.1 + @ls $(SOURCES) hexd.1 | sed s:^:hexd-$(VERS)/: >MANIFEST + @(cd ..; ln -s hexd hexd-$(VERS)) + (cd ..; tar -czf hexd/hexd-$(VERS).tar.gz `cat hexd/MANIFEST`) + @(cd ..; rm hexd-$(VERS)) + +# Note: to suppress the footers with timestamps being generated in HTML, +# we use "-a nofooter". +# To debug asciidoc problems, you may need to run "xmllint --nonet --noout --valid" +# on the intermediate XML that throws an error. +.SUFFIXES: .html .adoc .1 + +.adoc.1: + asciidoctor -D. -a nofooter -b manpage $< +.adoc.html: + asciidoctor -D. -a nofooter -a webfonts! $< + +install: hexd.1 uninstall + cp hexd /usr/bin + cp hexd.1 /usr/share/man/man1/hexd.1 -# Note: When the version changes, you also have to change the RPM spec file -VERS=1.4 - -hex: hex.c - $(CC) -DRELEASE=\"$(VERS)\" -O hex.c -o hex - -SOURCES = READ.ME Makefile hex.c hex.xml hex.spec +uninstall: + rm -f /usr/bin/hexd /usr/share/man/man1/hexd. -hex-$(VERS).tar.gz: $(SOURCES) hex.1 - @ls $(SOURCES) hex.1 | sed s:^:hex-$(VERS)/: >MANIFEST - @(cd ..; ln -s hex hex-$(VERS)) - (cd ..; tar -czvf hex/hex-$(VERS).tar.gz `cat hex/MANIFEST`) - @(cd ..; rm hex-$(VERS)) +clean: + rm -f hexd hexd-$(VERS).tar.gz *.rpm *.1 *.html MANIFEST SHIPPER.* -hex.1: hex.xml - xmlto man hex.xml +reflow: + @clang-format --style="{IndentWidth: 8, UseTab: ForIndentation}" -i $$(find . -name "*.[ch]") -install: hex.1 uninstall - cp hex /usr/bin - cp hex.1 /usr/share/man/man1/hex.1 +cppcheck: + cppcheck --template gcc --enable=all hexd.c -uninstall: - rm -f /usr/bin/hex /usr/share/man/man1/hex. +check: hexd + @./hexd hexd.png | diff -u hexd.chk - + @echo "No diff output is good news." -clean: - rm -f hex hex-$(VERS).tar.gz *.rpm +dist: hexd-$(VERS).tar.gz -dist: hex-$(VERS).tar.gz +release: hexd-$(VERS).tar.gz hexd.html + shipper version=$(VERS) | sh -e -x -RPMROOT=/usr/src/redhat -RPM = rpmbuild -RPMFLAGS = -ba -rpm: dist - cp hex-$(VERS).tar.gz $(RPMROOT)/SOURCES; - cp hex.spec $(RPMROOT)/SPECS - cd $(RPMROOT)/SPECS; $(RPM) $(RPMFLAGS) hex.spec - cp $(RPMROOT)/RPMS/`arch|sed 's/i[4-9]86/i386/'`/hex-$(VERS)*.rpm . - cp $(RPMROOT)/SRPMS/hex-$(VERS)*.src.rpm . +refresh: hexd.html + shipper -N -w version=$(VERS) | sh -e -x diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/NEWS.adoc new/hexd-1.11/NEWS.adoc --- old/hex-1.4/NEWS.adoc 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/NEWS.adoc 2024-02-08 02:45:17.000000000 +0100 @@ -0,0 +1,38 @@ += hexd news = + +1.11: 2024-02-07:: + Ship 6 bytes of address ratrher than 4, files run bigger these days. + Update to modern C style standard. + +1.10: 2019-06-12:: + Name changed to hexd to avoid collision with BSD hexdump. + License changed to BSD-2-clause. + +1.9: 2015-04-02:: + Administrivial release; Gitorious is dying, project metadata must change. + +1.8: 2012-12-03:: + Use C99 bools. Code passes cppcheck audit. Added a regression test. + +1.7: 2010-10-20:: + Code fully ANSIfied. License changed to BSD. RPM spec removed. + +1.6: 2003-12-29:: + Source RPMs no longer depend on --define myversion + +1.5: 2003-12-26:: + Name changed to 'hexd'. + +1.4: 2003-03-04:: + Packaging fixes. + +1.3: 2002-07-30:: + Documentation converted to XML-DocBook. A Windows NT port fix. + +1.2: 1999-09-13:: + Added RPM spec. + +1.1: 1998-06-29:: + Minor string header port fix. Archiving production. + +Based on a 1.0 written in 1983. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/READ.ME new/hexd-1.11/READ.ME --- old/hex-1.4/READ.ME 2003-03-04 13:00:26.000000000 +0100 +++ new/hexd-1.11/READ.ME 1970-01-01 01:00:00.000000000 +0100 @@ -1,26 +0,0 @@ - HEX - (by Eric S. Raymond <e...@thyrsus.com>) - -This hex dumper was born because - - a) od octal format is appallingly ugly - b) od -x ain't much better - c) I needed to dump EBCDIC files from SNA sessions - d) I needed to dump single blocks of files offset into the file. - -If any of these describes your universe, you'll like it too. The format -resembles a CP/M or MS/DOS DEBUG dump screen. There is nothing UNIX-specific -in the source, it should work OK under any C with a stdio.h library. And, -in fact, I'm told it has been used under Windows NT. - -I wrote the original of this in 1983. I'm not certain, but I think it -may have been my very first C program, and I believe it was the first -code I wrote under Unix (4.1BSD on a Vax). It's certainly the oldest -piece of C code I wrote that I still have source for. It has held -up remarkably well. - -You can find updates and other resources at: - - http://www.catb.org/~esr - -Send comments and bug reports to: e...@thyrsus.com diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/README new/hexd-1.11/README --- old/hex-1.4/README 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/README 2024-02-05 20:57:58.000000000 +0100 @@ -0,0 +1,42 @@ += hexd = + +Yes, it's yet another hex dumper. This one produces a nice CP/M-like +format by default and can do EBCDIC. It's internationalized, too. +Has many useful formatting functions. + +The output format is similar to what "od -A x -t x1z -v" would +generate, but with a gutter between bytes 8 and 9 and without the +delimiting >< around the ASCII display. + +Several release of this traveled under the name "hexdump". I changed +the name to avoid confusion with BSD hexdump, which I somehow only +became aware of sometime after the year 2000. I'd retire this code +entirely, except that BSD hexdump doesn't do EBCDIC and its -s option +is not quite as flexible. + +This hex dumper was born because + + a) od octal format is appallingly ugly + b) od -x ain't much better + c) I needed to dump EBCDIC files from SNA sessions + d) I needed to dump single blocks of data offset into the file. + +If any of these describes your universe, you'll like it too. The format +resembles a CP/M or MS/DOS DEBUG dump screen. There is nothing UNIX-specific +in the source, it should work OK under any C with a stdio.h library. And, +in fact, I'm told it has been used under Windows NT. + +To test the program, "make check". This checks to make sure dumping of +the PNG logo included with the distribution is stable. + +I wrote the original of this in 1983. I'm not certain, but I think it +may have been my very first C program, and I believe it was the first +code I wrote under Unix (4.1BSD on a Vax). It's certainly the oldest +piece of C code I wrote that I still have source for. It has held +up remarkably well. For many years it was just `hex'. + +You can find updates and other resources at: + + http://www.catb.org/~esr + +Send comments and bug reports to: Eric S. Raymond <e...@thyrsus.com> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/control new/hexd-1.11/control --- old/hex-1.4/control 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/control 2019-06-12 15:52:06.000000000 +0200 @@ -0,0 +1,26 @@ +# This is not a real Debian control file +# It's project metadata for the shipper tool + +Package: hexd + +Description: Dump binary files in a CP/M-like hex format. + Resembles BSD hexdump but can dump IBM EBCDIC and has + support for dumping blocks inside a file. + +#XBS-Destinations: freshcode + +Homepage: http://www.catb.org/~esr/hexd + +XBS-HTML-Target: index.html + +XBS-Repository-URL: https://gitlab.com/esr/hexd + +XBS-OpenHub-URL: https://www.openhub.net/p/hexdump-curses + +XBS-Logo: hexd.png + +#XBS-Project-Tags: hex, binary, dump + +XBS-VC-Tag-Template: %(version)s + +XBS-Validate: make check diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hex.1 new/hexd-1.11/hex.1 --- old/hex-1.4/hex.1 2003-03-04 13:05:41.000000000 +0100 +++ new/hexd-1.11/hex.1 1970-01-01 01:00:00.000000000 +0100 @@ -1,82 +0,0 @@ -.\"Generated by db2man.xsl. Don't modify this, modify the source. -.de Sh \" Subsection -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Ip \" List item -.br -.ie \\n(.$>=3 .ne \\$3 -.el .ne 3 -.IP "\\$1" \\$2 -.. -.TH "HEX" 1 "" "" "" -.SH NAME -hex \- dump a file to stdout in CP/M-like hex format -.SH "SYNOPSIS" - -.nf -\fBhex\fR [-V] [-w] [-e] [-c] [-g] [-s] [\fIfilename\fR...] -.fi - -.SH "DESCRIPTION" - -.PP -This program provides a facility for obtaining a dump of a binary file to stdout. The default format is a CP/M style \fBhex\fR dump with byte offset in file, 16 bytes of \fBhex\fR and 16 bytes of alpha representation with '.' for non-printables per line. If no filename is given, hex reads from standard input. - -.PP -The program accepts the following options to control its output: - -.TP --w -set # of bytes dumped per line (default is 16) - -.TP --e -display EBCDIC character assignments rather than ASCII - -.TP --c -display printable characters as text in-line - -.TP --g -don't output mid-page gutter - -.TP --s -dump file section - -.TP ---V -print version number and exit - -.PP -The command line is scanned left-to-right for filenames and options, and each file dumped according to the format defined by preceding options. To turn off an option, precede the letter with a +. Options that take arguments may have them immediately following the option letter or whitespace-separated. - -.PP -If the command-line arguments include two or more filenames (with - being regarded as a `filename' for standard input), \fBhex\fR will emit a one-line header giving the name of the file in front of each input file. - -.PP -The \fB-s\fR option expects a start offset, optionally followed by a comma-separated count. Each of these should be a decimal or \fBhex\fR integer (hex must be prefixed by x or h; leading zeros will be ignored). - -.PP -The \fB-w\fR option expects a width, formatted as a single decimal or \fBhex\fR number in the style of an \fB-s\fR option argument. Odd widths turn on the \fB-g\fR option. - -.SH "NOTE" - -.PP -The definition of EBCDIC used is IBM's ASCII-compatible 96-character SCS set used with Systems Network Architecture (SNA). - -.SH "AUTHOR" - -.PP -Eric S. Raymond <e...@thyrsus.com>. See my home page at \fIhttp://www.catb.org/~esr\fR for updates and related resources. - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hex.c new/hexd-1.11/hex.c --- old/hex-1.4/hex.c 2002-07-31 00:36:17.000000000 +0200 +++ new/hexd-1.11/hex.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,313 +0,0 @@ -/***************************************************************************** - -hex.c -- generate CP/M style hex dumps - -Copyright (c) 1999 by Eric S. Raymond<P> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions:<P> - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software.<P> - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE.<P> - -*****************************************************************************/ - - -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include <locale.h> - -#define DEFWIDTH 16 /* Default # chars to show per line */ -#define MAXWIDTH 32 /* Maximum # of bytes per line */ - -typedef int bool; -#define TRUE 1 -#define FALSE 0 - -static long linesize = DEFWIDTH; /* # of bytes to print per line */ -static bool eflag = FALSE; /* display ebcdic if true */ -static bool cflag = FALSE; /* show printables as ASCII if true */ -static bool gflag = FALSE; /* suppress mid-page gutter if true */ -static long start = 0L; /* file offset to start dumping at */ -static long length = 0L; /* if nz, how many chars to dump */ - -static char ebcdic[] = -{ -/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ -/* 40 */ ' ','.','.','.','.','.','.','.','.','.','[','.','<','(','+','!', -/* 50 */ '&','.','.','.','.','.','.','.','.','.',']','$','*',')',';','^', -/* 60 */ '-','/','.','.','.','.','.','.','.','.','|',',','%','_','>','?', -/* 70 */ '.','.','.','.','.','.','.','.','.','`',':','#','@','\'','=','"', -/* 80 */ '.','a','b','c','d','e','f','g','h','i','.','.','.','.','.','.', -/* 90 */ '.','j','k','l','m','n','o','p','q','r','.','.','.','.','.','.', -/* A0 */ '.','~','s','t','u','v','w','x','y','z','.','.','.','.','.','.', -/* B0 */ '.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.', -/* C0 */ '{','A','B','C','D','E','F','G','H','I','.','.','.','.','.','.', -/* D0 */ '}','J','K','L','M','N','O','P','Q','R','.','.','.','.','.','.', -/* E0 */ '\\','.','S','T','U','V','W','X','Y','Z','.','.','.','.','.','.', -/* F0 */ '0','1','2','3','4','5','6','7','8','9','.','.','.','.','.','.', -}; - -static void dumpfile(f) -/* dump a single, specified file -- stdin if filename is NULL */ -FILE *f; -{ - int ch = '\0'; /* current character */ - char ascii[MAXWIDTH+3]; /* printable ascii data */ - int i = 0; /* counter: # bytes processed */ - int ai = 0; /* index into ascii[] */ - int offset = 0; /* byte offset of line in file */ - int hpos; /* horizontal position counter */ - long fstart = start; - long flength = length; - char *specials = "\b\f\n\r\t"; - char *escapes = "bfnrt"; - char *cp; - - do { - ch = getc(f); - - if (ch != EOF) - { - if (start && fstart-- > 0) - continue; - - if (length && flength-- <= 0) - ch = EOF; - } - - if (ch != EOF) - { - if (i++ % linesize == 0) - { - (void) printf("%04x ", offset); - offset += linesize; - hpos = 5; - } - - /* output one space for the mid-page gutter */ - if (!gflag) - if ((i - 1) % (linesize / 2) == 0) - { - (void) putchar(' '); - hpos++; - ascii[ai++] = ' '; - } - - /* dump the indicated representation of a character */ - if (eflag) /* we're dumping EBCDIC (blecch!) */ - { - ascii[ai] = (ch >= 0x40) ? ebcdic[ch - 0x40] : '.'; - - if (cflag && (ascii[ai] != '.' || ch == ebcdic['.'])) - (void) printf("%c ", ascii[ai]); - else if (cflag && ch && (cp = strchr(specials, ch))) - (void) printf("\\%c ", escapes[cp - specials]); - else - (void) printf("%02x ", ch); - } - else /* we're dumping ASCII */ - { - ascii[ai] = (isprint (ch) || ch == ' ') ? ch : '.'; - - if (cflag && (isprint(ch) || ch == ' ')) - (void) printf("%c ", ch); - else if (cflag && ch && (cp = strchr(specials, ch))) - (void) printf("\\%c ", escapes[cp - specials]); - else - (void) printf("%02x ", ch); - } - - /* update counters and things */ - ai++; - hpos += 3; - } - - /* At end-of-line or EOF, show ASCII or EBCDIC version of data. */ - if (i && (ch == EOF || (i % linesize == 0))) - { - if (!cflag) - { - while (hpos < linesize * 3 + 7) - { - hpos++; - (void) putchar(' '); - } - - ascii[ai] = '\0'; - (void) printf("%s", ascii); - } - - if (ch != EOF || (i % linesize != 0)) - (void) putchar('\n'); - ai = 0; /* reset counters */ - } - } while - (ch != EOF); -} - -static long getoffs(cp) -/* fetch decimal or hex integer to be used as file start or offset */ -char *cp; -{ - bool foundzero = FALSE; - long value = 0; - int base = 0; - char *hexdigits = "0123456789abcdefABCDEF"; - - for (; *cp; cp++) - if (*cp == '0') - foundzero = TRUE; - else if (isdigit(*cp)) - { - base = 10; - break; - } - else if (*cp == 'x' || *cp == 'X' || *cp == 'h' || *cp == 'H') - { - base = 16; - cp++; - break; - } - else - return(-1L); - - if (base == 0) - if (foundzero) - base = 10; - else - return(-1L); - - if (base == 10) - { - for (; *cp; cp++) - if (isdigit(*cp)) - value = value * 10 + (*cp - '0'); - else - return(-1L); - } - else - { - for (; *cp; cp++) - if (strchr(hexdigits, *cp)) - value = value*16 + (strchr(hexdigits, tolower(*cp))-hexdigits); - else - return(-1L); - } - - return(value); -} - -main(argc, argv) -int argc; -char *argv[]; -{ - FILE *infile; /* file pointer input file */ - int dumpcount = 0; /* count of files dumped so far */ - char *cp; - - setlocale (LC_CTYPE, ""); - - for (argv++, argc--; argc > 0; argv++, argc--) - { - char s = **argv; - - if (s == '-' || s == '+') - { - int c = *++*argv; - - switch (c) - { - case 'V': - printf("hex " RELEASE " by Eric S. Raymond.\n"); - exit(0); - - case 'e': eflag = (s == '-'); continue; - case 'c': cflag = (s == '-'); continue; - case 'g': gflag = (s == '-'); continue; - - case 's': - if ((*argv)[1]) - (*argv)++; - else - argc--, argv++; - if (s == '-' && argc >= 0) - { - if (cp = strchr(*argv, ',')) - *cp++ = '\0'; - if ((start = getoffs(*argv)) == -1L) - { - (void) fputs("hex: start offset no good\n", stderr); - exit(0); - } - - if (cp) - if ((length = getoffs(cp)) == -1L) - { - (void) fputs("hex: length no good\n", stderr); - exit(0); - } - } - else - start = length = 0L; - continue; - - case '\0': - infile = stdin; - break; - - case 'w': - if ((*argv)[1]) - (*argv)++; - else - argc--, argv++; - if ((linesize = getoffs(*argv)) == -1L || linesize > MAXWIDTH) - { - (void) fputs("hex: line width no good\n", stderr); - exit(0); - } - if (linesize % 2) - gflag = TRUE; - continue; - - default: - (void) fprintf(stderr, "hex: no such option as %s\n", *argv); - exit(0); - } - } - else if ((infile = fopen(*argv, "rb")) == NULL) - { - (void) fprintf(stderr, "hex: cannot open %s\n", *argv); - exit(1); - } - - if (dumpcount > 0 || argc > 1) - if (infile == stdin) - (void) printf("---- <Standard input> ----\n"); - else - (void) printf("---- %s ----\n", *argv); - dumpfile(infile); - dumpcount++; - if (infile != stdin) - (void) fclose(infile); - } - - if (dumpcount == 0) - dumpfile(stdin); - return(0); -} - -/* hex.c ends here */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hex.spec new/hexd-1.11/hex.spec --- old/hex-1.4/hex.spec 2003-03-04 13:02:26.000000000 +0100 +++ new/hexd-1.11/hex.spec 1970-01-01 01:00:00.000000000 +0100 @@ -1,26 +0,0 @@ -Name: hex -Version: 1.4 -Release: 1 -Summary: yet another hex dumper -URL: http://www.catb.org/~esr/hex/ -Source0: %{name}-%{version}.tar.gz -License: BSD-like -Group: Development/Tools - -%%description -Yes, it's yet another hex dumper. This one produces a nice CP/M-like -format by default and can do EBCDIC. It's internationalized, too. -Has many nifty formatting functions. - -%prep -%setup - -%build -make - -%install -make install - -%files -/usr/share/man/man1/hex.1 -/usr/bin/hex diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hex.xml new/hexd-1.11/hex.xml --- old/hex-1.4/hex.xml 2003-03-04 13:05:39.000000000 +0100 +++ new/hexd-1.11/hex.xml 1970-01-01 01:00:00.000000000 +0100 @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE refentry PUBLIC - "-//OASIS//DTD DocBook XML V4.1.2//EN" - "docbook/docbookx.dtd"> -<refentry id='hex.1'> -<refmeta> -<refentrytitle>hex</refentrytitle> -<manvolnum>1</manvolnum> -<refmiscinfo class='date'>Oct 27, 1987</refmiscinfo> -</refmeta> -<refnamediv id='name'> -<refname>hex</refname> -<refpurpose>dump a file to stdout in CP/M-like hex format</refpurpose> -</refnamediv> -<refsynopsisdiv id='synopsis'> - -<cmdsynopsis> - <!-- hex [-V] [-w] [-e] [-c] [-g] [-s] [filename...] --> - <command>hex</command> <arg choice='opt'>-V </arg> - <arg choice='opt'>-w </arg> - <arg choice='opt'>-e </arg> - <arg choice='opt'>-c </arg> - <arg choice='opt'>-g </arg> - <arg choice='opt'>-s </arg> - <arg choice='opt' rep='repeat'><replaceable>filename</replaceable></arg> -</cmdsynopsis> - -</refsynopsisdiv> - -<refsect1 id='description'><title>DESCRIPTION</title> - -<para>This program provides a facility for obtaining a dump of a -binary file to stdout. The default format is a CP/M style -<command>hex</command> dump with byte offset in file, 16 bytes of -<command>hex</command> and 16 bytes of alpha representation with '.' -for non-printables per line. If no filename is given, hex reads from -standard input.</para> - -<para>The program accepts the following options to control its output:</para> -<variablelist remap='TP'> -<varlistentry> -<term>-w</term> -<listitem> -<para>set # of bytes dumped per line (default is 16)</para> -</listitem> -</varlistentry> -<varlistentry> -<term>-e</term> -<listitem> -<para>display EBCDIC character assignments rather than ASCII</para> -</listitem> -</varlistentry> -<varlistentry> -<term>-c</term> -<listitem> -<para>display printable characters as text in-line</para> -</listitem> -</varlistentry> -<varlistentry> -<term>-g</term> -<listitem><para>don't output mid-page gutter</para></listitem> -</varlistentry> -<varlistentry> -<term>-s</term> -<listitem><para>dump file section</para></listitem> -</varlistentry> -<varlistentry> -<term>--V</term> -<listitem><para>print version number and exit</para></listitem> -</varlistentry> -</variablelist> - -<para>The command line is scanned left-to-right for filenames and -options, and each file dumped according to the format defined by -preceding options. To turn off an option, precede the letter with a -+. Options that take arguments may have them immediately following the -option letter or whitespace-separated.</para> - -<para>If the command-line arguments include two or more filenames -(with - being regarded as a `filename' for standard input), -<command>hex</command> will emit a one-line header giving the name of -the file in front of each input file.</para> - -<para>The <option>-s</option> option expects a start offset, -optionally followed by a comma-separated count. Each of these should -be a decimal or <command>hex</command> integer (hex must be prefixed -by x or h; leading zeros will be ignored).</para> - -<para>The <option>-w</option> option expects a width, formatted as a -single decimal or <command>hex</command> number in the style of an -<option>-s</option> option argument. Odd widths turn on the -<option>-g</option> option.</para> </refsect1> - -<refsect1 id='note'><title>NOTE</title> <para>The definition of EBCDIC -used is IBM's ASCII-compatible 96-character SCS set used with Systems -Network Architecture (SNA).</para> </refsect1> - -<refsect1 id='author'><title>AUTHOR</title> <para>Eric S. Raymond -<e...@thyrsus.com>. See my home page at <ulink -url='http://www.catb.org/~esr'>http://www.catb.org/~esr</ulink> -for updates and related resources.</para> -</refsect1> -</refentry> - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hexd.1 new/hexd-1.11/hexd.1 --- old/hex-1.4/hexd.1 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/hexd.1 2024-02-08 02:45:29.000000000 +0100 @@ -0,0 +1,108 @@ +'\" t +.\" Title: ascii +.\" Author: [see the "AUTHOR(S)" section] +.\" Generator: Asciidoctor 2.0.16 +.\" Date: 2024-02-07 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: English +.\" +.TH "HEXD" "1" "2024-02-07" "\ \&" "\ \&" +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.ss \n[.ss] 0 +.nh +.ad l +.de URL +\fI\\$2\fP <\\$1>\\$3 +.. +.als MTO URL +.if \n[.g] \{\ +. mso www.tmac +. am URL +. ad l +. . +. am MTO +. ad l +. . +. LINKSTYLE blue R < > +.\} +.SH "NAME" +hexd \- dump a file to stdout in CP/M\-like hexadecimal format +.SH "SYNOPSIS" +.sp +hexd [\-V ] [\-w ] [\-e ] [\-c ] [\-g ] [\-s ] [\*(Aqfilename\*(Aq] +</cmdsynopsis> +.SH "DESCRIPTION" +.sp +This program dumps a binary file to stdout in a form friendlier to the +eyeball than either raw binary or the output of the Unix od(1) +command. The default format is a CP/M\-style hexadecimal dump with +byte offset in file, 16 bytes of hex and 16 bytes of textual +representation with \*(Aq.\*(Aq for non\-printables per line. If no filename +is given, this program reads from standard input. +.sp +The program accepts the following options to control its output: +.sp +\-w +.RS 4 +set # of bytes dumped per line (default is 16) +.RE +.sp +\-e +.RS 4 +display EBCDIC character assignments rather than ASCII +.RE +.sp +\-c +.RS 4 +display printable characters as text in\-line +.RE +.sp +\-g +.RS 4 +don\(cqt output mid\-page gutter</listitem> +.RE +.sp +\-s +.RS 4 +dump file section</listitem> +.RE +.sp +\-V +.RS 4 +print version number and exit</listitem> +.RE +.sp +The command line is scanned left\-to\-right for filenames and +options, and each file dumped according to the format defined by +preceding options. To turn off an option, precede the letter with a ++. Options that take arguments may have them immediately following the +option letter or whitespace\-separated. +.sp +If the command\-line arguments include two or more filenames +(with \- being regarded as a filename for standard input), +hexd will emit a one\-line header giving the name of +the file in front of each input file. +.sp +The \-s option expects a start offset, optionally followed by a +comma\-separated count. Each of these should be a decimal or +hexadecimal integer (hexadecimal must be prefixed by x or h; leading +zeros will be ignored). +.sp +The \-w option expects a width, formatted as a single decimal or +haxadecimal number in the style of an \-s option argument. Odd widths +turn on the \-g option. +.sp +The \-e option decodes the imput as EBCDIC characters and dumps their +ASCII equivalents when displaying as text. The definition of EBCDIC +used is IBM\(cqs ASCII\-compatible 96\-character SCS set used with Systems +Network Architecture (SNA). +.SH "AUTHOR" +.sp +Eric S. Raymond \c +.MTO "esr\(atthyrsus.com" "" "." +See my home page at +.URL "http://www.catb.org/~esr" "" "" +for updates and +related resources. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hexd.adoc new/hexd-1.11/hexd.adoc --- old/hex-1.4/hexd.adoc 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/hexd.adoc 2024-02-08 02:43:32.000000000 +0100 @@ -0,0 +1,68 @@ += ascii(1) = +:doctype: manpage + +== NAME == +hexd - dump a file to stdout in CP/M-like hexadecimal format + +== SYNOPSIS == + ++hexd+ [-V ] [-w ] [-e ] [-c ] [-g ] [-s ] ['filename'] +</cmdsynopsis> + +[[description]] +== DESCRIPTION == + +This program dumps a binary file to stdout in a form friendlier to the +eyeball than either raw binary or the output of the Unix od(1) +command. The default format is a CP/M-style hexadecimal dump with +byte offset in file, 16 bytes of +hex+ and 16 bytes of textual +representation with '.' for non-printables per line. If no filename +is given, this program reads from standard input. + +The program accepts the following options to control its output: + +-w:: set # of bytes dumped per line (default is 16) + +-e:: display EBCDIC character assignments rather than ASCII + +-c:: display printable characters as text in-line + +-g:: don't output mid-page gutter</listitem> + +-s:: dump file section</listitem> + +-V:: print version number and exit</listitem> + +The command line is scanned left-to-right for filenames and +options, and each file dumped according to the format defined by +preceding options. To turn off an option, precede the letter with a ++. Options that take arguments may have them immediately following the +option letter or whitespace-separated. + +If the command-line arguments include two or more filenames +(with - being regarded as a filename for standard input), ++hexd+ will emit a one-line header giving the name of +the file in front of each input file. + +The -s option expects a start offset, optionally followed by a +comma-separated count. Each of these should be a decimal or +hexadecimal integer (hexadecimal must be prefixed by x or h; leading +zeros will be ignored). + +The -w option expects a width, formatted as a single decimal or +haxadecimal number in the style of an -s option argument. Odd widths +turn on the -g option. + +The -e option decodes the imput as EBCDIC characters and dumps their +ASCII equivalents when displaying as text. The definition of EBCDIC +used is IBM's ASCII-compatible 96-character SCS set used with Systems +Network Architecture (SNA). + +[[author]] +== AUTHOR == + +Eric S. Raymond <e...@thyrsus.com>. See my home page at +http://www.catb.org/~esr for updates and +related resources. + +// end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hex-1.4/hexd.c new/hexd-1.11/hexd.c --- old/hex-1.4/hexd.c 1970-01-01 01:00:00.000000000 +0100 +++ new/hexd-1.11/hexd.c 2024-02-05 21:00:17.000000000 +0100 @@ -0,0 +1,315 @@ +/***************************************************************************** + +hexd.c -- generate CP/M style hex dumps + +*****************************************************************************/ +// SPDX-License-Identifier: BSD-2-Clause +// SPDX-FileCopyrightText: (C) Eric S. Raymond <e...@thyrsus.com> + +#include <ctype.h> +#include <locale.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define DEFWIDTH 16 /* Default # chars to show per line */ +#define MAXWIDTH 128 /* Maximum # of bytes per line */ +#define HEXPERBYTE 3 /* Two hex characters plus space */ +#define HEXOVERHEAD 7 /* fixed overhead per line of hex */ + +static long linebytes = DEFWIDTH; /* # of bytes to print per line */ +static bool eflag = false; /* display ebcdic if true */ +static bool cflag = false; /* show printables as ASCII if true */ +static bool gflag = false; /* suppress mid-page gutter if true */ +static long start = 0L; /* file offset to start dumping at */ +static long length = 0L; /* if nz, how many chars to dump */ + +static char ebcdic[] = { + // clang-format off + /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + /* 40 */ ' ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '[', '.', '<', '(', '+', '!', + /* 50 */ '&', '.', '.', '.', '.', '.', '.', '.', '.', '.', ']', '$', '*', ')', ';', '^', + /* 60 */ '-', '/', '.', '.', '.', '.', '.', '.', '.', '.', '|', ',', '%', '_', '>', '?', + /* 70 */ '.', '.', '.', '.', '.', '.', '.', '.', '.', '`', ':', '#', '@', '\'', '=', '"', + /* 80 */ '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '.', '.', '.', '.', '.', '.', + /* 90 */ '.', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '.', '.', '.', '.', '.', '.', + /* A0 */ '.', '~', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '.', '.', '.', '.', '.', + /* B0 */ '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', + /* C0 */ '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '.', '.', '.', '.', '.', '.', + /* D0 */ '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '.', '.', '.', '.', '.', '.', + /* E0 */ '\\', '.', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '.', '.', '.', '.', '.', '.', + /* F0 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '.', '.', '.', '.', '.', + // clang-format on +}; + +static void dumpfile(FILE *f) { + /* dump a single, specified file -- stdin if filename is NULL */ + int ch = '\0'; /* current character */ + char ascii[MAXWIDTH + 3]; /* printable ascii data */ + int i = 0; /* counter: # bytes processed */ + int ai = 0; /* index into ascii[] */ + int offset = 0; /* byte offset of line in file */ + int hpos; /* horizontal position counter */ + long fstart = start; + long flength = length; + char *specials = "\b\f\n\r\t"; + char *escapes = "bfnrt"; + char *cp; + + do { + ch = getc(f); + + if (ch != EOF) { + if (start && fstart-- > 0) { + continue; + } + + if (length && flength-- <= 0) { + ch = EOF; + } + } + + if (ch != EOF) { + if (i++ % linebytes == 0) { + (void)printf("%06x ", offset); + offset += linebytes; + hpos = 5; + } + + /* output one space for the mid-page gutter */ + if (!gflag) { + if ((i - 1) % (linebytes / 2) == 0) { + (void)putchar(' '); + hpos++; + ascii[ai++] = ' '; + } + } + + /* dump the indicated representation of a character */ + if (eflag) /* we're dumping EBCDIC (blecch!) */ + { + ascii[ai] = + (ch >= 0x40) ? ebcdic[ch - 0x40] : '.'; + + if (cflag && + (ascii[ai] != '.' || ch == ebcdic['.'])) { + (void)printf("%c ", ascii[ai]); + } else if (cflag && ch && + (cp = strchr(specials, ch))) { + (void)printf("\\%c ", + escapes[cp - specials]); + } else { + (void)printf("%02x ", ch); + } + } else /* we're dumping ASCII */ + { + ascii[ai] = + (isprint(ch) || ch == ' ') ? ch : '.'; + + if (cflag && (isprint(ch) || ch == ' ')) { + (void)printf("%c ", ch); + } else if (cflag && ch && + (cp = strchr(specials, ch))) { + (void)printf("\\%c ", + escapes[cp - specials]); + } else { + (void)printf("%02x ", ch); + } + } + + /* update counters and things */ + ai++; + hpos += HEXPERBYTE; + } + + /* At end-of-line or EOF, show ASCII or EBCDIC version of data. + */ + if (i && (ch == EOF || (i % linebytes == 0))) { + if (!cflag) { + while (hpos < + linebytes * HEXPERBYTE + HEXOVERHEAD) { + hpos++; + (void)putchar(' '); + } + + ascii[ai] = '\0'; + (void)printf("%s", ascii); + } + + if (ch != EOF || (i % linebytes != 0)) { + (void)putchar('\n'); + } + ai = 0; /* reset counters */ + } + } while (ch != EOF); +} + +static long getoffs(char *cp) { + /* fetch decimal or hex integer to be used as file start or offset */ + bool foundzero = false; + long value = 0; + int base = 0; + char *hexdigits = "0123456789abcdefABCDEF"; + + for (; *cp; cp++) { + if (*cp == '0') { + foundzero = true; + } else if (isdigit(*cp)) { + base = 10; + break; + } else if (*cp == 'x' || *cp == 'X' || *cp == 'h' || + *cp == 'H') { + base = 16; + cp++; + break; + } else { + return (-1L); + } + } + + if (base == 0) { + if (foundzero) { + base = 10; + } else { + return (-1L); + } + } + + if (base == 10) { + for (; *cp; cp++) { + if (isdigit(*cp)) { + value = value * 10 + (*cp - '0'); + } else { + return (-1L); + } + } + } else { + for (; *cp; cp++) { + if (strchr(hexdigits, *cp)) { + value = value * 16 + + (strchr(hexdigits, tolower(*cp)) - + hexdigits); + } else { + return (-1L); + } + } + } + + return (value); +} + +int main(int argc, char **argv) { + FILE *infile; /* file pointer input file */ + int dumpcount = 0; /* count of files dumped so far */ + char *cp; + + setlocale(LC_CTYPE, ""); + + for (argv++, argc--; argc > 0; argv++, argc--) { + char s = **argv; + + if (s == '-' || s == '+') { + int c = *++*argv; + + switch (c) { + case 'V': + printf("hex " RELEASE " by Eric S. Raymond.\n"); + exit(0); + + case 'e': + eflag = (s == '-'); + continue; + case 'c': + cflag = (s == '-'); + continue; + case 'g': + gflag = (s == '-'); + continue; + + case 's': + if ((*argv)[1]) { + (*argv)++; + } else { + argc--, argv++; + } + if (s == '-' && argc >= 0) { + if (cp = strchr(*argv, ',')) { + *cp++ = '\0'; + } + if ((start = getoffs(*argv)) == -1L) { + (void)fputs("hexd: start " + "offset no good\n", + stderr); + exit(0); + } + + if (cp) { + if ((length = getoffs(cp)) == + -1L) { + (void)fputs( + "hexd: length no " + "good\n", + stderr); + exit(0); + } + } + } else { + start = length = 0L; + } + continue; + + case '\0': + infile = stdin; + break; + + case 'w': + if ((*argv)[1]) { + (*argv)++; + } else { + argc--, argv++; + } + if ((linebytes = getoffs(*argv)) == -1L || + linebytes > MAXWIDTH) { + (void)fputs( + "hexd: line width no good\n", + stderr); + exit(0); + } + if (linebytes % 2) { + gflag = true; + } + continue; + + default: + (void)fprintf(stderr, + "hexd: no such option as %s\n", + *argv); + exit(0); + } + } else if ((infile = fopen(*argv, "rb")) == NULL) { + (void)fprintf(stderr, "hexd: cannot open %s\n", *argv); + exit(1); + } + + if (dumpcount > 0 || argc > 1) { + if (infile == stdin) { + (void)printf("---- <Standard input> ----\n"); + } else { + (void)printf("---- %s ----\n", *argv); + } + } + dumpfile(infile); + dumpcount++; + if (infile != stdin) { + (void)fclose(infile); + } + } + + if (dumpcount == 0) { + dumpfile(stdin); + } + return (0); +} + +/* hexd.c ends here */