aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-14 04:49:30 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-14 04:49:30 -0500
commit7c4f03d63bcc3552c0833fe07569936ce77dd154 (patch)
tree500357c5efc1b48e343ca9b6e5aa95ad3e190b7d
parent072544c2f6072d4fabc8db354cbd128388caa243 (diff)
downloaduxd-7c4f03d63bcc3552c0833fe07569936ce77dd154.tar.gz
implement -u option.
-rw-r--r--uxd.11
-rw-r--r--uxd.c9
-rw-r--r--uxd.rst1
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.