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.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'uxd.c') 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++; -- cgit v1.2.3