hexl: handle large files and I/O errors
commit23e64facf9f74133c6bacedeec56ad782ae69b65
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 23 Feb 2017 16:58:39 +0000 (23 08:58 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 23 Feb 2017 17:15:06 +0000 (23 09:15 -0800)
tree19822ecfb5af4b2f867dd02a2a29319ade9fcb13
parent5114b3a2047a9bcdb72fddf35e70201c16eb39a3
hexl: handle large files and I/O errors

* lib-src/hexl.c: Include inttypes.h, for PRIxMAX etc.
Do not include ctype.h, as the code no longer uses isdigit.
(DEFAULT_GROUPING, un_flag, iso_flag, group_by): Now local to ‘main’.
(DEFAULT_BASE, endian): Remove; was not really used.
(usage): Remove; now done by ‘main’, as that’s simpler.
(progname): Now static.
(output_error, hexchar): New functions.
(main): Use them.  Simplify.  Remove "-oct", "-big-endian", and
"-little-endian" options, as they did not work and were not used.
Use SET_BINARY only on stdin, and fopen with "rb" otherwise.
Use SET_BINARY only once on stdout.
Do not assume file offsets fit in ‘long’.
If an I/O error occurs, report it and exit with nonzero status.
lib-src/hexl.c