From 7c4f03d63bcc3552c0833fe07569936ce77dd154 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 14 Dec 2024 04:49:30 -0500 Subject: implement -u option. --- uxd.1 | 1 - uxd.c | 9 +++++---- uxd.rst | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/uxd.1 b/uxd.1 index cbfad7e..69a41cb 100644 --- a/uxd.1 +++ b/uxd.1 @@ -75,7 +75,6 @@ NOT IMPLEMENTED YET. .TP .B \-u Use uppercase hex digits A\-F. Default is lowercase. -NOT IMPLEMENTED YET. .TP .B \-h\fP,\fB \-\-help Print built\-in usage message and exit. diff --git a/uxd.c b/uxd.c index 3f9d363..612243a 100644 --- a/uxd.c +++ b/uxd.c @@ -84,7 +84,8 @@ int hilite_multi = 0; /* -r */ int mono = 0; /* -m */ int display_offset = 0; /* -o */ int seekpos = 0; /* -s */ -int uppercase = 0; /* -u */ +const char *hex_byte_fmt = "%02x"; /* -u */ +const char *hex_word_fmt = "%04x: "; /* " */ void usage(void) { printf("uxd (Utf-8 heX Dump) v" VERSION " by B. Watson. WTFPL.\n"); @@ -134,7 +135,7 @@ void parse_options(int argc, char **argv) { seekpos = strtol(optarg, NULL, 0); break; case 'u': - uppercase = 1; break; + hex_byte_fmt = "%02X"; hex_word_fmt = "%04X: "; break; case 'h': usage(); break; case 'v': @@ -227,10 +228,10 @@ void append_left(unsigned char byte, int dash, int fgcolor, int bgcolor) { char tmpbuf[100]; if(!dump_column) - sprintf(left_buf, "%04x: ", filepos + display_offset); + sprintf(left_buf, hex_word_fmt, filepos + display_offset); append_color(left_buf, fgcolor, bgcolor); - sprintf(tmpbuf, "%02x", byte); + sprintf(tmpbuf, hex_byte_fmt, byte); strcat(left_buf, tmpbuf); dump_column++; diff --git a/uxd.rst b/uxd.rst index e466adb..26cab62 100644 --- a/uxd.rst +++ b/uxd.rst @@ -64,7 +64,6 @@ OPTIONS -u Use uppercase hex digits A-F. Default is lowercase. - NOT IMPLEMENTED YET. -h, --help Print built-in usage message and exit. -- cgit v1.2.3