aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uxd.18
-rw-r--r--uxd.c25
-rw-r--r--uxd.rst8
3 files changed, 30 insertions, 11 deletions
diff --git a/uxd.1 b/uxd.1
index 6dc19c4..178ed24 100644
--- a/uxd.1
+++ b/uxd.1
@@ -86,6 +86,10 @@ Don\(aqt alternate colors.
.
.INDENT 0.0
.TP
+.B \-a
+Don\(aqt dump lines that consist entirely of ASCII characters (codepoints
+U+00 to U+7f).
+.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.
@@ -492,7 +496,7 @@ Only UTF\-8 and a couple of variants (WTF\-8, MUTF\-8) are supported.
There is no support for UTF\-16, UTF\-32, UTF\-EBCDIC, or any other
non\-UTF\-8 encoding.
.sp
-There\(aqs no support for any number base except hex.
+There\(aqs no support for any output number base except hex.
.sp
The input is read one byte at a time, so a search or regex match
option would be difficult or impossible to implement.
@@ -517,6 +521,6 @@ Watson <\fI\%urchlay@slackware.uk\fP>.
.UNINDENT
.SH SEE ALSO
.sp
-xxd(1), bvi(1), utf\-8(7), unicode(7)
+xxd(1), bvi(1), utf\-8(7), unicode(7), console_codes(4)
.\" Generated by docutils manpage writer.
.
diff --git a/uxd.c b/uxd.c
index a11347f..9926386 100644
--- a/uxd.c
+++ b/uxd.c
@@ -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;
diff --git a/uxd.rst b/uxd.rst
index ae62093..ed52a84 100644
--- a/uxd.rst
+++ b/uxd.rst
@@ -71,6 +71,10 @@ Also, a decimal point can be used: **1.5K** is 1500 bytes, **1.5k** is
.. don't alternate colors.
+-a
+ Don't dump lines that consist entirely of ASCII characters (codepoints
+ U+00 to U+7f).
+
-b
Bold output. This may be more or less readable, depending on your
terminal and its color settings. Ignored if **-m** given.
@@ -426,7 +430,7 @@ Only UTF-8 and a couple of variants (WTF-8, MUTF-8) are supported.
There is no support for UTF-16, UTF-32, UTF-EBCDIC, or any other
non-UTF-8 encoding.
-There's no support for any number base except hex.
+There's no support for any output number base except hex.
The input is read one byte at a time, so a search or regex match
option would be difficult or impossible to implement.
@@ -457,4 +461,4 @@ B. Watson <urchlay@slackware.uk>.
SEE ALSO
========
-xxd(1), bvi(1), utf-8(7), unicode(7)
+xxd(1), bvi(1), utf-8(7), unicode(7), console_codes(4)