diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-24 17:49:18 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-24 17:49:18 -0500 |
commit | 819936f4e536299f1e2eefc650e447ee3eecbe9b (patch) | |
tree | cb3f7d61ff6ed3ad7a772bcc85f5d08dfc17c06b /uxd.c | |
parent | 92e123ac0419a3388cda0001fb01efa9c2ccc1cf (diff) | |
download | uxd-819936f4e536299f1e2eefc650e447ee3eecbe9b.tar.gz |
add -A (ASCII output) option
Diffstat (limited to 'uxd.c')
-rw-r--r-- | uxd.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -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: */ |