diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-23 17:19:05 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-23 17:19:05 -0500 |
commit | f24c37189ab4d4e508604b0f15b4a29e03464d3f (patch) | |
tree | 79651446736e294f7ed316e235d7c95d7ed950d4 /uxd.c | |
parent | e325c9c8410c30cf255dc320c26cfb3e5d93aa85 (diff) | |
download | uxd-f24c37189ab4d4e508604b0f15b4a29e03464d3f.tar.gz |
add -a option
Diffstat (limited to 'uxd.c')
-rw-r--r-- | uxd.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -157,6 +157,9 @@ int restore_term = 0; /* -T only */ int java_mode = 0; /* -j */ int wtf8_mode = 0; /* -w */ int permissive = 0; /* -l */ +int skip_ascii = 0; /* -a */ + +int line_all_ascii = 1; /* used by -a */ /* stats for -i option */ long byte_count = 0; @@ -284,8 +287,10 @@ void parse_args(int argc, char **argv) { version(); } - while((opt = my_getopt(argc, argv, "jwptTd:1ic:nbl:rmo:S:s:uhv")) != -1) { + while((opt = my_getopt(argc, argv, "ajwptTd:1ic:nbl:rmo:S:s:uhv")) != -1) { switch(opt) { + case 'a': + skip_ascii = 1; break; case 'j': java_mode = 1; break; case 'w': @@ -422,19 +427,23 @@ void set_self(const char *argv0) { void print_line(void) { int spacing = MAX_DUMP_COLS - dump_column; + int skip = skip_ascii ? line_all_ascii : 0; - printf("%s", left_buf); + if(!skip) { + printf("%s", left_buf); - /* line up the rightmost field (human-readable), for the partial - line at the end of the output (if there is one). */ - while(spacing--) printf(" "); - if(dump_column < (MAX_DUMP_COLS / 2)) putchar(' '); + /* line up the rightmost field (human-readable), for the partial + line at the end of the output (if there is one). */ + while(spacing--) printf(" "); + if(dump_column < (MAX_DUMP_COLS / 2)) putchar(' '); - printf(" %s\n", right_buf); + printf(" %s\n", right_buf); + } /* clear the buffers, start a new line */ left_buf[0] = right_buf[0] = '\0'; dump_column = 0; + line_all_ascii = 1; } void next_normal_hilite(void) { @@ -726,6 +735,8 @@ int dump_utf8_char(void) { bad = 1; } + if(bad || cont_count) line_all_ascii = 0; + /* read and validate the continuation bytes, if any */ for(i = 0; i < cont_count; i++) { int cb; |