aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-24 17:49:18 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-24 17:49:18 -0500
commit819936f4e536299f1e2eefc650e447ee3eecbe9b (patch)
treecb3f7d61ff6ed3ad7a772bcc85f5d08dfc17c06b
parent92e123ac0419a3388cda0001fb01efa9c2ccc1cf (diff)
downloaduxd-819936f4e536299f1e2eefc650e447ee3eecbe9b.tar.gz
add -A (ASCII output) option
-rw-r--r--Makefile2
-rw-r--r--usage.c1
-rw-r--r--uxd.111
-rw-r--r--uxd.c24
-rw-r--r--uxd.rst7
-rw-r--r--ver.rst2
6 files changed, 40 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 3b074e7..fcf4a9d 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ GZIP_MAN=yes
#
### No user-serviceable parts below.
-VERSION=0.3.0
+VERSION=1.0.0
DEFINES=-DVERSION='"$(VERSION)"'
WARNFLAGS=-std=c89 -Wall -pedantic -Wextra
diff --git a/usage.c b/usage.c
index 5831514..754f1fc 100644
--- a/usage.c
+++ b/usage.c
@@ -2,6 +2,7 @@ char *usage_opts[] = {
" --: no more options.",
" -1: don't alternate colors.",
" -a: don't dump ASCII-only lines.",
+ " -A: ASCII output instead of UTF-8.",
" -b: bold color output.",
" -c nnnnn: colors (1 to 5 digits, 0 to 7).",
" -d data: dump this data instead of a file.",
diff --git a/uxd.1 b/uxd.1
index 86d186c..2f90da6 100644
--- a/uxd.1
+++ b/uxd.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "UXD" 1 "2024-12-24" "0.3.0" "Urchlay's Utilities"
+.TH "UXD" 1 "2024-12-24" "1.0.0" "Urchlay's Utilities"
.SH NAME
uxd \- UTF-8 hex dumper
.SH SYNOPSIS
@@ -100,6 +100,15 @@ Don\(aqt dump lines that consist entirely of ASCII characters (codepoints
.
.INDENT 0.0
.TP
+.B \-A
+ASCII output. Unprintable characters and UTF\-8 sequences are
+rendered as periods (like \fBxxd\fP does). Also, spaces are rendered
+as spaces rather than the ␣ character.
+.UNINDENT
+.\" ASCII output instead of UTF-8.
+.
+.INDENT 0.0
+.TP
.B \-b
Bold output. This may be more or less readable, depending on your
terminal and its color settings. Ignored if \fB\-m\fP given.
diff --git a/uxd.c b/uxd.c
index be49939..92dba6f 100644
--- a/uxd.c
+++ b/uxd.c
@@ -158,6 +158,7 @@ int java_mode = 0; /* -j */
int wtf8_mode = 0; /* -w */
int permissive = 0; /* -l */
int skip_ascii = 0; /* -a */
+int dot_mode = 0; /* -A */
int line_all_ascii = 1; /* used by -a */
@@ -292,8 +293,10 @@ void parse_args(int argc, char **argv) {
version();
}
- while((opt = my_getopt(argc, argv, "ajwptTd:1ic:nbl:rmo:S:s:uhv")) != -1) {
+ while((opt = my_getopt(argc, argv, "AajwptTd:1ic:nbl:rmo:S:s:uhv")) != -1) {
switch(opt) {
+ case 'A':
+ dot_mode = 1; break;
case 'a':
skip_ascii = 1; break;
case 'j':
@@ -420,8 +423,13 @@ void parse_options(int argc, char **argv) {
}
char *get_special(unsigned char c) {
- if(c == 0x7f) return "⌦"; /* tab */
- if(c <= ' ') return special_symbols[c];
+ if(dot_mode) {
+ if(c == 0x7f || c < ' ') return ".";
+ if(c == ' ') return " ";
+ } else {
+ if(c == 0x7f) return "⌦"; /* tab */
+ if(c <= ' ') return special_symbols[c];
+ }
return "?"; /* should never happen */
}
@@ -798,7 +806,15 @@ int dump_utf8_char(void) {
/* human-readable (right) column: */
append_hilite(right_buf, hl_type);
- append_right(printable);
+
+ if(dot_mode && (bad || cont_count)) {
+ for(i = 0; i <= cont_count; i++) {
+ append_right(".");
+ }
+ } else {
+ append_right(printable);
+ }
+
append_hilite_off(right_buf);
/* hex columns: */
diff --git a/uxd.rst b/uxd.rst
index 65302c8..c05103e 100644
--- a/uxd.rst
+++ b/uxd.rst
@@ -83,6 +83,13 @@ Also, a decimal point can be used: **1.5K** is 1500 bytes, **1.5k** is
.. don't dump ASCII-only lines.
+-A
+ ASCII output. Unprintable characters and UTF-8 sequences are
+ rendered as periods (like **xxd** does). Also, spaces are rendered
+ as spaces rather than the ␣ character.
+
+.. ASCII output instead of UTF-8.
+
-b
Bold output. This may be more or less readable, depending on your
terminal and its color settings. Ignored if **-m** given.
diff --git a/ver.rst b/ver.rst
index 443bbb2..f1f9abf 100644
--- a/ver.rst
+++ b/ver.rst
@@ -1 +1 @@
-.. |version| replace:: 0.3.0
+.. |version| replace:: 1.0.0