diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-14 04:49:30 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-14 04:49:30 -0500 |
commit | 7c4f03d63bcc3552c0833fe07569936ce77dd154 (patch) | |
tree | 500357c5efc1b48e343ca9b6e5aa95ad3e190b7d /uxd.c | |
parent | 072544c2f6072d4fabc8db354cbd128388caa243 (diff) | |
download | uxd-7c4f03d63bcc3552c0833fe07569936ce77dd154.tar.gz |
implement -u option.
Diffstat (limited to 'uxd.c')
-rw-r--r-- | uxd.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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++; |