summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/expected/hexdump/highlighting0
-rw-r--r--tests/expected/hexdump/highlighting-1b_char-141
-rw-r--r--tests/expected/hexdump/highlighting-1b_char-241
-rw-r--r--tests/expected/hexdump/highlighting-1b_char-341
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-141
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-241
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-341
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-441
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-541
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-61
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-741
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-841
-rw-r--r--tests/expected/hexdump/highlighting-1b_octal-941
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-141
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-241
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-31
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-441
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-541
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-61
-rw-r--r--tests/expected/hexdump/highlighting-2b_dec-71
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-121
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-221
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-32
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-42
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-51
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-62
-rw-r--r--tests/expected/hexdump/highlighting-4b_dec-72
-rw-r--r--tests/expected/hexdump/highlighting-canon-141
-rw-r--r--tests/expected/hexdump/highlighting-canon-241
-rwxr-xr-xtests/ts/hexdump/highlighting235
-rw-r--r--text-utils/hexdump-display.c70
-rw-r--r--text-utils/hexdump-parse.c140
-rw-r--r--text-utils/hexdump.138
-rw-r--r--text-utils/hexdump.c23
-rw-r--r--text-utils/hexdump.h11
35 files changed, 1268 insertions, 1 deletions
diff --git a/tests/expected/hexdump/highlighting b/tests/expected/hexdump/highlighting
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/expected/hexdump/highlighting
diff --git a/tests/expected/hexdump/highlighting-1b_char-1 b/tests/expected/hexdump/highlighting-1b_char-1
new file mode 100644
index 000000000..758766460
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_char-1
@@ -0,0 +1,41 @@
+0000000 \0 001 002 003 004 005 006 \a
+0000010 \b \t \n \v \f \r 016 017
+0000020 020 021 022 023 024 025 026 027
+0000030 030 031 032 033 034 035 036 037
+0000040 ! " # $ % & '
+0000050 ( ) * + ,  - . /
+0000060 0 1 2 3 4 5 6 7
+0000070 8 9 : ; < = > ?
+0000080 @ A B C D E F G
+0000090 H  I J K  L M  N O
+00000a0 P Q R S  T  U V W
+00000b0  X Y Z [ \ ] ^ _
+00000c0 ` a b c d e f g
+00000d0 h i j k l m n o
+00000e0 p q r s t u v w
+00000f0 x y z { | } ~ 177
+0000100 302 200 302 201 302 202 302 203 302 204 302
+0000110 205 302 206 302 207 302 210 302 211 302 212
+0000120 302 213 302 214 302 215 302 216 302 217
+0000130 302 220 302 221 302 222 302 223 302 224 302
+0000140 225 302 226 302 227 302 230 302 231 302 232
+0000150 302 233 302 234 302 235 302 236 302 237
+0000160 302 240 302 241 302 242 302 243 302 244 302
+0000170 245 302 246 302 247 302 250 302 251 302 252
+0000180 302 253 302 254 302 255 302 256 302 257
+0000190 302 260 302 261 302 262 302 263 302 264 302
+00001a0 265 302 266 302 267 302 270 302 271 302 272
+00001b0 302 273 302 274 302 275 302 276 302 277
+00001c0 303 200 303 201 303 202 303 203 303 204 303
+00001d0 205 303 206 303 207 303 210 303 211 303 212
+00001e0 303 213 303 214 303 215 303 216 303 217
+00001f0 303 220 303 221 303 222 303 223 303 224 303
+0000200 225 303 226 303 227 303 230 303 231 303 232
+0000210 303 233 303 234 303 235 303 236 303 237
+0000220 303 240 303 241 303 242 303 243 303 244 303
+0000230 245 303 246 303 247 303 250 303 251 303 252
+0000240 303 253 303 254 303 255 303 256 303 257
+0000250 303 260 303 261 303 262 303 263 303 264 303
+0000260 265 303 266 303 267 303 270 303 271 303 272
+0000270 303 273 303 274 303 275 303 276 303 277
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_char-2 b/tests/expected/hexdump/highlighting-1b_char-2
new file mode 100644
index 000000000..762ad3503
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_char-2
@@ -0,0 +1,41 @@
+0000000 \0 001 002 003 004 005 006 \a
+0000010 \b \t \n \v \f \r 016 017
+0000020 020 021 022 023 024 025 026 027
+0000030 030 031 032 033 034 035 036 037
+0000040 ! " # $ % & '
+0000050 ( ) * + , - . /
+0000060 0 1 2 3 4 5 6 7
+0000070 8 9 : ; < = > ?
+0000080 @ A B C D E F G
+0000090 H I J K L M N O
+00000a0 P Q R S T U V W
+00000b0 X Y Z [ \ ] ^ _
+00000c0 ` a b c d e f g
+00000d0 h i j k l m n o
+00000e0 p q r s t u v w
+00000f0 x y z { | } ~ 177
+0000100 302 200 302 201 302 202 302 203 302 204 302
+0000110 205 302 206 302 207 302 210 302 211 302 212
+0000120 302 213 302 214 302 215 302 216 302 217
+0000130 302 220 302 221 302 222 302 223 302 224 302
+0000140 225 302 226 302 227 302 230 302 231 302 232
+0000150 302 233 302 234 302 235 302 236 302 237
+0000160 302 240 302 241 302 242 302 243 302 244 302
+0000170 245 302 246 302 247 302 250 302 251 302 252
+0000180 302 253 302 254 302 255 302 256 302 257
+0000190 302 260 302 261 302 262 302 263 302 264 302
+00001a0 265 302 266 302 267 302 270 302 271 302 272
+00001b0 302 273 302 274 302 275 302 276 302 277
+00001c0 303 200 303 201 303 202 303 203 303 204 303
+00001d0 205 303 206 303 207 303 210 303 211 303 212
+00001e0 303 213 303 214 303 215 303 216 303 217
+00001f0 303 220 303 221 303 222 303 223 303 224 303
+0000200 225 303 226 303 227 303 230 303 231 303 232
+0000210 303 233 303 234 303 235 303 236 303 237
+0000220 303 240 303 241 303 242 303 243 303 244 303
+0000230 245 303 246 303 247 303 250 303 251 303 252
+0000240 303 253 303 254 303 255 303 256 303 257
+0000250 303 260 303 261 303 262 303 263 303 264 303
+0000260 265 303 266 303 267 303 270 303 271 303 272
+0000270 303 273 303 274 303 275 303 276 303 277
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_char-3 b/tests/expected/hexdump/highlighting-1b_char-3
new file mode 100644
index 000000000..1595cefd4
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_char-3
@@ -0,0 +1,41 @@
+0000000 \0 001 002 003 004 005 006 \a
+0000010 \b \t \n \v \f \r 016 017
+0000020 020 021 022 023 024 025 026 027
+0000030 030 031 032 033 034 035 036 037
+0000040 ! " # $ % & '
+0000050 ( ) * + , - . /
+0000060 0 1 2 3 4 5 6 7
+0000070 8 9  : ; < = > ?
+0000080  @ A B C D E F G
+0000090 H I J K L M N O
+00000a0 P Q R S T U V W
+00000b0 X Y Z [ \ ] ^ _
+00000c0 ` a b c d e f g
+00000d0 h i j k l m n o
+00000e0 p q r s t u v w
+00000f0 x y z { | } ~ 177
+0000100 302 200 302 201 302 202 302 203 302 204 302
+0000110 205 302 206 302 207 302 210 302 211 302 212
+0000120 302 213 302 214 302 215 302 216 302 217
+0000130 302 220 302 221 302 222 302 223 302 224 302
+0000140 225 302 226 302 227 302 230 302 231 302 232
+0000150 302 233 302 234 302 235 302 236 302 237
+0000160 302 240 302 241 302 242 302 243 302 244 302
+0000170 245 302 246 302 247 302 250 302 251 302 252
+0000180 302 253 302 254 302 255 302 256 302 257
+0000190 302 260 302 261 302 262 302 263 302 264 302
+00001a0 265 302 266 302 267 302 270 302 271 302 272
+00001b0 302 273 302 274 302 275 302 276 302 277
+00001c0 303 200 303 201 303 202 303 203 303 204 303
+00001d0 205 303 206 303 207 303 210 303 211 303 212
+00001e0 303 213 303 214 303 215 303 216 303 217
+00001f0 303 220 303 221 303 222 303 223 303 224 303
+0000200 225 303 226 303 227 303 230 303 231 303 232
+0000210 303 233 303 234 303 235 303 236 303 237
+0000220 303 240 303 241 303 242 303 243 303 244 303
+0000230 245 303 246 303 247 303 250 303 251 303 252
+0000240 303 253 303 254 303 255 303 256 303 257
+0000250 303 260 303 261 303 262 303 263 303 264 303
+0000260 265 303 266 303 267 303 270 303 271 303 272
+0000270 303 273 303 274 303 275 303 276 303 277
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-1 b/tests/expected/hexdump/highlighting-1b_octal-1
new file mode 100644
index 000000000..1f8ca6859
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-1
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-2 b/tests/expected/hexdump/highlighting-1b_octal-2
new file mode 100644
index 000000000..1f8ca6859
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-2
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-3 b/tests/expected/hexdump/highlighting-1b_octal-3
new file mode 100644
index 000000000..1f8ca6859
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-3
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-4 b/tests/expected/hexdump/highlighting-1b_octal-4
new file mode 100644
index 000000000..1f8ca6859
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-4
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-5 b/tests/expected/hexdump/highlighting-1b_octal-5
new file mode 100644
index 000000000..0eb6def7b
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-5
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-6 b/tests/expected/hexdump/highlighting-1b_octal-6
new file mode 100644
index 000000000..a5cc10bcf
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-6
@@ -0,0 +1 @@
+hexdump: bad byte count for conversion character _L
diff --git a/tests/expected/hexdump/highlighting-1b_octal-7 b/tests/expected/hexdump/highlighting-1b_octal-7
new file mode 100644
index 000000000..1f8ca6859
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-7
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-8 b/tests/expected/hexdump/highlighting-1b_octal-8
new file mode 100644
index 000000000..53a8318ab
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-8
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-1b_octal-9 b/tests/expected/hexdump/highlighting-1b_octal-9
new file mode 100644
index 000000000..7446bd7d5
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-1b_octal-9
@@ -0,0 +1,41 @@
+0000000 000 040 001 040 002 040 003 040 004 040 005 040 006 040 007 040
+0000010 010 040 011 040 012 040 013 040 014 040 015 040 016 040 017 040
+0000020 020 040 021 040 022 040 023 040 024 040 025 040 026 040 027 040
+0000030 030 040 031 040 032 040 033 040 034 040 035 040 036 040 037 040
+0000040 040 040 041 040 042 040 043 040 044 040 045 040 046 040 047 040
+0000050 050 040 051 040 052 040 053 040 054 040 055 040 056 040 057 040
+0000060 060 040 061 040 062 040 063 040 064 040 065 040 066 040 067 040
+0000070 070 040 071 040 072 040 073 040 074 040 075 040 076 040 077 040
+0000080 100 040 101 040 102 040 103 040 104 040 105 040 106 040 107 040
+0000090 110 040 111 040 112 040 113 040 114 040 115 040 116 040 117 040
+00000a0 120 040 121 040 122 040 123 040 124 040 125 040 126 040 127 040
+00000b0 130 040 131 040 132 040 133 040 134 040 135 040 136 040 137 040
+00000c0 140 040 141 040 142 040 143 040 144 040 145 040 146 040 147 040
+00000d0 150 040 151 040 152 040 153 040 154 040 155 040 156 040 157 040
+00000e0 160 040 161 040 162 040 163 040 164 040 165 040 166 040 167 040
+00000f0 170 040 171 040 172 040 173 040 174 040 175 040 176 040 177 040
+0000100 302 200 040 302 201 040 302 202 040 302 203 040 302 204 040 302
+0000110 205 040 302 206 040 302 207 040 302 210 040 302 211 040 302 212
+0000120 040 302 213 040 302 214 040 302 215 040 302 216 040 302 217 040
+0000130 302 220 040 302 221 040 302 222 040 302 223 040 302 224 040 302
+0000140 225 040 302 226 040 302 227 040 302 230 040 302 231 040 302 232
+0000150 040 302 233 040 302 234 040 302 235 040 302 236 040 302 237 040
+0000160 302 240 040 302 241 040 302 242 040 302 243 040 302 244 040 302
+0000170 245 040 302 246 040 302 247 040 302 250 040 302 251 040 302 252
+0000180 040 302 253 040 302 254 040 302 255 040 302 256 040 302 257 040
+0000190 302 260 040 302 261 040 302 262 040 302 263 040 302 264 040 302
+00001a0 265 040 302 266 040 302 267 040 302 270 040 302 271 040 302 272
+00001b0 040 302 273 040 302 274 040 302 275 040 302 276 040 302 277 040
+00001c0 303 200 040 303 201 040 303 202 040 303 203 040 303 204 040 303
+00001d0 205 040 303 206 040 303 207 040 303 210 040 303 211 040 303 212
+00001e0 040 303 213 040 303 214 040 303 215 040 303 216 040 303 217 040
+00001f0 303 220 040 303 221 040 303 222 040 303 223 040 303 224 040 303
+0000200 225 040 303 226 040 303 227 040 303 230 040 303 231 040 303 232
+0000210 040 303 233 040 303 234 040 303 235 040 303 236 040 303 237 040
+0000220 303 240 040 303 241 040 303 242 040 303 243 040 303 244 040 303
+0000230 245 040 303 246 040 303 247 040 303 250 040 303 251 040 303 252
+0000240 040 303 253 040 303 254 040 303 255 040 303 256 040 303 257 040
+0000250 303 260 040 303 261 040 303 262 040 303 263 040 303 264 040 303
+0000260 265 040 303 266 040 303 267 040 303 270 040 303 271 040 303 272
+0000270 040 303 273 040 303 274 040 303 275 040 303 276 040 303 277 040
+0000280
diff --git a/tests/expected/hexdump/highlighting-2b_dec-1 b/tests/expected/hexdump/highlighting-2b_dec-1
new file mode 100644
index 000000000..cfb2c5a8f
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-1
@@ -0,0 +1,41 @@
+0000000 08192 08193 08194 08195 08196 08197 08198 08199
+0000010 08200 08201 08202 08203 08204 08205 08206 08207
+0000020 08208 08209 08210 08211 08212 08213 08214 08215
+0000030 08216 08217 08218 08219 08220 08221 08222 08223
+0000040 08224 08225 08226 08227 08228 08229 08230 08231
+0000050 08232 08233 08234 08235 08236 08237 08238 08239
+0000060 08240 08241  08242 08243 08244 08245 08246 08247
+0000070 08248 08249 08250 08251 08252 08253 08254 08255
+0000080 08256 08257 08258 08259 08260 08261 08262 08263
+0000090 08264 08265 08266 08267 08268 08269 08270 08271
+00000a0 08272 08273 08274 08275 08276 08277 08278 08279
+00000b0 08280 08281 08282 08283 08284 08285 08286 08287
+00000c0 08288 08289 08290 08291 08292 08293 08294 08295
+00000d0 08296 08297 08298 08299 08300 08301 08302 08303
+00000e0 08304 08305 08306 08307 08308 08309 08310 08311
+00000f0 08312 08313 08314 08315 08316 08317 08318 08319
+0000100 32962 49696 08321 33474 49696 08323 33986 49696
+0000110 08325 34498 49696 08327 35010 49696 08329 35522
+0000120 49696 08331 36034 49696 08333 36546 49696 08335
+0000130 37058 49696 08337 37570 49696 08339 38082 49696
+0000140 08341 38594 49696 08343 39106 49696 08345 39618
+0000150 49696 08347 40130 49696 08349 40642 49696 08351
+0000160 41154 49696 08353 41666 49696 08355 42178 49696
+0000170 08357 42690 49696 08359 43202 49696 08361 43714
+0000180 49696 08363 44226 49696 08365 44738 49696 08367
+0000190 45250 49696 08369 45762 49696 08371 46274 49696
+00001a0 08373 46786 49696 08375 47298 49696 08377 47810
+00001b0 49696 08379 48322 49696 08381 48834 49696 08383
+00001c0 32963 49952 08321 33475 49952 08323 33987 49952
+00001d0 08325 34499 49952 08327 35011 49952 08329 35523
+00001e0 49952 08331 36035 49952 08333 36547 49952 08335
+00001f0 37059 49952 08337 37571 49952 08339 38083 49952
+0000200 08341 38595 49952 08343 39107 49952 08345 39619
+0000210 49952 08347 40131 49952 08349 40643 49952 08351
+0000220 41155 49952 08353 41667 49952 08355 42179 49952
+0000230 08357 42691 49952 08359 43203 49952 08361 43715
+0000240 49952 08363 44227 49952 08365 44739 49952 08367
+0000250 45251 49952 08369 45763 49952 08371 46275 49952
+0000260 08373 46787 49952 08375 47299 49952 08377 47811
+0000270 49952 08379 48323 49952 08381 48835 49952 08383
+0000280
diff --git a/tests/expected/hexdump/highlighting-2b_dec-2 b/tests/expected/hexdump/highlighting-2b_dec-2
new file mode 100644
index 000000000..1872323b7
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-2
@@ -0,0 +1,41 @@
+0000000 08192 08193 08194 08195 08196 08197 08198 08199
+0000010 08200 08201 08202 08203 08204 08205 08206 08207
+0000020 08208 08209 08210 08211 08212 08213 08214 08215
+0000030 08216 08217 08218 08219 08220 08221 08222 08223
+0000040 08224 08225 08226 08227 08228 08229 08230 08231
+0000050 08232 08233 08234 08235 08236 08237 08238 08239
+0000060 08240  08241 08242 08243 08244 08245 08246 08247
+0000070 08248 08249 08250 08251 08252 08253 08254 08255
+0000080 08256 08257 08258 08259 08260 08261 08262 08263
+0000090 08264 08265 08266 08267 08268 08269 08270 08271
+00000a0 08272 08273 08274 08275 08276 08277 08278 08279
+00000b0 08280 08281 08282 08283 08284 08285 08286 08287
+00000c0 08288 08289 08290 08291 08292 08293 08294 08295
+00000d0 08296 08297 08298 08299 08300 08301 08302 08303
+00000e0 08304 08305 08306 08307 08308 08309 08310 08311
+00000f0 08312 08313 08314 08315 08316 08317 08318 08319
+0000100 32962 49696 08321 33474 49696 08323 33986 49696
+0000110 08325 34498 49696 08327 35010 49696 08329 35522
+0000120 49696 08331 36034 49696 08333 36546 49696 08335
+0000130 37058 49696 08337 37570 49696 08339 38082 49696
+0000140 08341 38594 49696 08343 39106 49696 08345 39618
+0000150 49696 08347 40130 49696 08349 40642 49696 08351
+0000160 41154 49696 08353 41666 49696 08355 42178 49696
+0000170 08357 42690 49696 08359 43202 49696 08361 43714
+0000180 49696 08363 44226 49696 08365 44738 49696 08367
+0000190 45250 49696 08369 45762 49696 08371 46274 49696
+00001a0 08373 46786 49696 08375 47298 49696 08377 47810
+00001b0 49696 08379 48322 49696 08381 48834 49696 08383
+00001c0 32963 49952 08321 33475 49952 08323 33987 49952
+00001d0 08325 34499 49952 08327 35011 49952 08329 35523
+00001e0 49952 08331 36035 49952 08333 36547 49952 08335
+00001f0 37059 49952 08337 37571 49952 08339 38083 49952
+0000200 08341 38595 49952 08343 39107 49952 08345 39619
+0000210 49952 08347 40131 49952 08349 40643 49952 08351
+0000220 41155 49952 08353 41667 49952 08355 42179 49952
+0000230 08357 42691 49952 08359 43203 49952 08361 43715
+0000240 49952 08363 44227 49952 08365 44739 49952 08367
+0000250 45251 49952 08369 45763 49952 08371 46275 49952
+0000260 08373 46787 49952 08375 47299 49952 08377 47811
+0000270 49952 08379 48323 49952 08381 48835 49952 08383
+0000280
diff --git a/tests/expected/hexdump/highlighting-2b_dec-3 b/tests/expected/hexdump/highlighting-2b_dec-3
new file mode 100644
index 000000000..a5cc10bcf
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-3
@@ -0,0 +1 @@
+hexdump: bad byte count for conversion character _L
diff --git a/tests/expected/hexdump/highlighting-2b_dec-4 b/tests/expected/hexdump/highlighting-2b_dec-4
new file mode 100644
index 000000000..d2111c2b0
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-4
@@ -0,0 +1,41 @@
+0000000 08192 08193 08194 08195 08196 08197 08198 08199
+0000010 08200 08201 08202 08203 08204 08205 08206 08207
+0000020 08208 08209 08210 08211 08212 08213 08214 08215
+0000030 08216 08217 08218 08219 08220 08221 08222 08223
+0000040 08224 08225 08226 08227 08228 08229 08230 08231
+0000050 08232 08233 08234 08235 08236 08237 08238 08239
+0000060 08240 08241 08242 08243 08244 08245 08246 08247
+0000070 08248 08249 08250 08251 08252 08253 08254 08255
+0000080 08256  08257 08258 08259 08260 08261 08262 08263
+0000090 08264 08265 08266 08267 08268 08269 08270 08271
+00000a0 08272 08273 08274 08275 08276 08277 08278 08279
+00000b0 08280 08281 08282 08283 08284 08285 08286 08287
+00000c0 08288 08289 08290 08291 08292 08293 08294 08295
+00000d0 08296 08297 08298 08299 08300 08301 08302 08303
+00000e0 08304 08305 08306 08307 08308 08309 08310 08311
+00000f0 08312 08313 08314 08315 08316 08317 08318 08319
+0000100 32962 49696 08321 33474 49696 08323 33986 49696
+0000110 08325 34498 49696 08327 35010 49696 08329 35522
+0000120 49696 08331 36034 49696 08333 36546 49696 08335
+0000130 37058 49696 08337 37570 49696 08339 38082 49696
+0000140 08341 38594 49696 08343 39106 49696 08345 39618
+0000150 49696 08347 40130 49696 08349 40642 49696 08351
+0000160 41154 49696 08353 41666 49696 08355 42178 49696
+0000170 08357 42690 49696 08359 43202 49696 08361 43714
+0000180 49696 08363 44226 49696 08365 44738 49696 08367
+0000190 45250 49696 08369 45762 49696 08371 46274 49696
+00001a0 08373 46786 49696 08375 47298 49696 08377 47810
+00001b0 49696 08379 48322 49696 08381 48834 49696 08383
+00001c0 32963 49952 08321 33475 49952 08323 33987 49952
+00001d0 08325 34499 49952 08327 35011 49952 08329 35523
+00001e0 49952 08331 36035 49952 08333 36547 49952 08335
+00001f0 37059 49952 08337 37571 49952 08339 38083 49952
+0000200 08341 38595 49952 08343 39107 49952 08345 39619
+0000210 49952 08347 40131 49952 08349 40643 49952 08351
+0000220 41155 49952 08353 41667 49952 08355 42179 49952
+0000230 08357 42691 49952 08359 43203 49952 08361 43715
+0000240 49952 08363 44227 49952 08365 44739 49952 08367
+0000250 45251 49952 08369 45763 49952 08371 46275 49952
+0000260 08373 46787 49952 08375 47299 49952 08377 47811
+0000270 49952 08379 48323 49952 08381 48835 49952 08383
+0000280
diff --git a/tests/expected/hexdump/highlighting-2b_dec-5 b/tests/expected/hexdump/highlighting-2b_dec-5
new file mode 100644
index 000000000..d2111c2b0
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-5
@@ -0,0 +1,41 @@
+0000000 08192 08193 08194 08195 08196 08197 08198 08199
+0000010 08200 08201 08202 08203 08204 08205 08206 08207
+0000020 08208 08209 08210 08211 08212 08213 08214 08215
+0000030 08216 08217 08218 08219 08220 08221 08222 08223
+0000040 08224 08225 08226 08227 08228 08229 08230 08231
+0000050 08232 08233 08234 08235 08236 08237 08238 08239
+0000060 08240 08241 08242 08243 08244 08245 08246 08247
+0000070 08248 08249 08250 08251 08252 08253 08254 08255
+0000080 08256  08257 08258 08259 08260 08261 08262 08263
+0000090 08264 08265 08266 08267 08268 08269 08270 08271
+00000a0 08272 08273 08274 08275 08276 08277 08278 08279
+00000b0 08280 08281 08282 08283 08284 08285 08286 08287
+00000c0 08288 08289 08290 08291 08292 08293 08294 08295
+00000d0 08296 08297 08298 08299 08300 08301 08302 08303
+00000e0 08304 08305 08306 08307 08308 08309 08310 08311
+00000f0 08312 08313 08314 08315 08316 08317 08318 08319
+0000100 32962 49696 08321 33474 49696 08323 33986 49696
+0000110 08325 34498 49696 08327 35010 49696 08329 35522
+0000120 49696 08331 36034 49696 08333 36546 49696 08335
+0000130 37058 49696 08337 37570 49696 08339 38082 49696
+0000140 08341 38594 49696 08343 39106 49696 08345 39618
+0000150 49696 08347 40130 49696 08349 40642 49696 08351
+0000160 41154 49696 08353 41666 49696 08355 42178 49696
+0000170 08357 42690 49696 08359 43202 49696 08361 43714
+0000180 49696 08363 44226 49696 08365 44738 49696 08367
+0000190 45250 49696 08369 45762 49696 08371 46274 49696
+00001a0 08373 46786 49696 08375 47298 49696 08377 47810
+00001b0 49696 08379 48322 49696 08381 48834 49696 08383
+00001c0 32963 49952 08321 33475 49952 08323 33987 49952
+00001d0 08325 34499 49952 08327 35011 49952 08329 35523
+00001e0 49952 08331 36035 49952 08333 36547 49952 08335
+00001f0 37059 49952 08337 37571 49952 08339 38083 49952
+0000200 08341 38595 49952 08343 39107 49952 08345 39619
+0000210 49952 08347 40131 49952 08349 40643 49952 08351
+0000220 41155 49952 08353 41667 49952 08355 42179 49952
+0000230 08357 42691 49952 08359 43203 49952 08361 43715
+0000240 49952 08363 44227 49952 08365 44739 49952 08367
+0000250 45251 49952 08369 45763 49952 08371 46275 49952
+0000260 08373 46787 49952 08375 47299 49952 08377 47811
+0000270 49952 08379 48323 49952 08381 48835 49952 08383
+0000280
diff --git a/tests/expected/hexdump/highlighting-2b_dec-6 b/tests/expected/hexdump/highlighting-2b_dec-6
new file mode 100644
index 000000000..a5cc10bcf
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-6
@@ -0,0 +1 @@
+hexdump: bad byte count for conversion character _L
diff --git a/tests/expected/hexdump/highlighting-2b_dec-7 b/tests/expected/hexdump/highlighting-2b_dec-7
new file mode 100644
index 000000000..a5cc10bcf
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-2b_dec-7
@@ -0,0 +1 @@
+hexdump: bad byte count for conversion character _L
diff --git a/tests/expected/hexdump/highlighting-4b_dec-1 b/tests/expected/hexdump/highlighting-4b_dec-1
new file mode 100644
index 000000000..157a7da4a
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-1
@@ -0,0 +1,21 @@
+0000000 536944640 537075714 537206788 537337862 537468936 537600010 537731084 537862158
+0000020 537993232 538124306 538255380 538386454 538517528 538648602 538779676 538910750
+0000040 539041824 539172898 539303972 539435046 539566120 539697194 539828268 539959342
+0000060  540090416 540221490 540352564 540483638 540614712 540745786 540876860 541007934
+0000080 541139008 541270082 541401156 541532230 541663304 541794378 541925452 542056526
+00000a0 542187600 542318674 542449748 542580822 542711896 542842970 542974044 543105118
+00000c0 543236192 543367266 543498340 543629414 543760488 543891562 544022636 544153710
+00000e0 544284784 544415858 544546932 544678006 544809080 544940154 545071228 545202302
+0000100 3256910018 2193760385 545505824 3256911042 2260869253 545767968 3256912066 2327978121
+0000120 546030112 3256913090 2395086989 546292256 3256914114 2462195857 546554400 3256915138
+0000140 2529304725 546816544 3256916162 2596413593 547078688 3256917186 2663522461 547340832
+0000160 3256918210 2730631329 547602976 3256919234 2797740197 547865120 3256920258 2864849065
+0000180 548127264 3256921282 2931957933 548389408 3256922306 2999066801 548651552 3256923330
+00001a0 3066175669 548913696 3256924354 3133284537 549175840 3256925378 3200393405 549437984
+00001c0 3273687235 2193825921 545506080 3273688259 2260934789 545768224 3273689283 2328043657
+00001e0 546030368 3273690307 2395152525 546292512 3273691331 2462261393 546554656 3273692355
+0000200 2529370261 546816800 3273693379 2596479129 547078944 3273694403 2663587997 547341088
+0000220 3273695427 2730696865 547603232 3273696451 2797805733 547865376 3273697475 2864914601
+0000240 548127520 3273698499 2932023469 548389664 3273699523 2999132337 548651808 3273700547
+0000260 3066241205 548913952 3273701571 3133350073 549176096 3273702595 3200458941 549438240
+0000280
diff --git a/tests/expected/hexdump/highlighting-4b_dec-2 b/tests/expected/hexdump/highlighting-4b_dec-2
new file mode 100644
index 000000000..157a7da4a
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-2
@@ -0,0 +1,21 @@
+0000000 536944640 537075714 537206788 537337862 537468936 537600010 537731084 537862158
+0000020 537993232 538124306 538255380 538386454 538517528 538648602 538779676 538910750
+0000040 539041824 539172898 539303972 539435046 539566120 539697194 539828268 539959342
+0000060  540090416 540221490 540352564 540483638 540614712 540745786 540876860 541007934
+0000080 541139008 541270082 541401156 541532230 541663304 541794378 541925452 542056526
+00000a0 542187600 542318674 542449748 542580822 542711896 542842970 542974044 543105118
+00000c0 543236192 543367266 543498340 543629414 543760488 543891562 544022636 544153710
+00000e0 544284784 544415858 544546932 544678006 544809080 544940154 545071228 545202302
+0000100 3256910018 2193760385 545505824 3256911042 2260869253 545767968 3256912066 2327978121
+0000120 546030112 3256913090 2395086989 546292256 3256914114 2462195857 546554400 3256915138
+0000140 2529304725 546816544 3256916162 2596413593 547078688 3256917186 2663522461 547340832
+0000160 3256918210 2730631329 547602976 3256919234 2797740197 547865120 3256920258 2864849065
+0000180 548127264 3256921282 2931957933 548389408 3256922306 2999066801 548651552 3256923330
+00001a0 3066175669 548913696 3256924354 3133284537 549175840 3256925378 3200393405 549437984
+00001c0 3273687235 2193825921 545506080 3273688259 2260934789 545768224 3273689283 2328043657
+00001e0 546030368 3273690307 2395152525 546292512 3273691331 2462261393 546554656 3273692355
+0000200 2529370261 546816800 3273693379 2596479129 547078944 3273694403 2663587997 547341088
+0000220 3273695427 2730696865 547603232 3273696451 2797805733 547865376 3273697475 2864914601
+0000240 548127520 3273698499 2932023469 548389664 3273699523 2999132337 548651808 3273700547
+0000260 3066241205 548913952 3273701571 3133350073 549176096 3273702595 3200458941 549438240
+0000280
diff --git a/tests/expected/hexdump/highlighting-4b_dec-3 b/tests/expected/hexdump/highlighting-4b_dec-3
new file mode 100644
index 000000000..8d18fc8b8
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-3
@@ -0,0 +1,2 @@
+0000000  1077952576 00010
+0000005
diff --git a/tests/expected/hexdump/highlighting-4b_dec-4 b/tests/expected/hexdump/highlighting-4b_dec-4
new file mode 100644
index 000000000..8d18fc8b8
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-4
@@ -0,0 +1,2 @@
+0000000  1077952576 00010
+0000005
diff --git a/tests/expected/hexdump/highlighting-4b_dec-5 b/tests/expected/hexdump/highlighting-4b_dec-5
new file mode 100644
index 000000000..a5cc10bcf
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-5
@@ -0,0 +1 @@
+hexdump: bad byte count for conversion character _L
diff --git a/tests/expected/hexdump/highlighting-4b_dec-6 b/tests/expected/hexdump/highlighting-4b_dec-6
new file mode 100644
index 000000000..8d18fc8b8
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-6
@@ -0,0 +1,2 @@
+0000000  1077952576 00010
+0000005
diff --git a/tests/expected/hexdump/highlighting-4b_dec-7 b/tests/expected/hexdump/highlighting-4b_dec-7
new file mode 100644
index 000000000..e0e43899f
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-4b_dec-7
@@ -0,0 +1,2 @@
+0000000 1077952576 00010
+0000005
diff --git a/tests/expected/hexdump/highlighting-canon-1 b/tests/expected/hexdump/highlighting-canon-1
new file mode 100644
index 000000000..9ecc35328
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-canon-1
@@ -0,0 +1,41 @@
+00000000 00 20 01 20 02 20 03 20 04 20 05 20 06 20 07 20 |. . . . . . . . |
+00000010 08 20 09 20 0a 20 0b 20 0c 20 0d 20 0e 20 0f 20 |. . . . . . . . |
+00000020 10 20 11 20 12 20 13 20 14 20 15 20 16 20 17 20 |. . . . . . . . |
+00000030 18 20 19 20 1a 20 1b 20 1c 20 1d 20 1e 20 1f 20 |. . . . . . . . |
+00000040 20 20 21 20 22 20 23 20 24 20 25 20 26 20 27 20 |  ! " # $ % & ' |
+00000050 28 20 29 20 2a 20 2b 20 2c 20 2d 20 2e 20 2f 20 |( ) * + , - . / |
+00000060 30 20 31 20 32 20 33 20 34 20 35 20 36 20 37 20 |0 1 2 3 4 5 6 7 |
+00000070 38 20 39 20 3a 20 3b 20 3c 20 3d 20 3e 20 3f 20 |8 9 : ; < = > ? |
+00000080 40 20 41 20 42 20 43 20 44 20 45 20 46 20 47 20 |@ A B C D E F G |
+00000090 48 20 49 20 4a 20 4b 20 4c 20 4d 20 4e 20 4f 20 |H I J K L M N O |
+000000a0 50 20 51 20 52 20 53 20 54 20 55 20 56 20 57 20 |P Q R S T U V W |
+000000b0 58 20 59 20 5a 20 5b 20 5c 20 5d 20 5e 20 5f 20 |X Y Z [ \ ] ^ _ |
+000000c0 60 20 61 20 62 20 63 20 64 20 65 20 66 20 67 20 |` a b c d e f g |
+000000d0 68 20 69 20 6a 20 6b 20 6c 20 6d 20 6e 20 6f 20 |h i j k l m n o |
+000000e0 70 20 71 20 72 20 73 20 74 20 75 20 76 20 77 20 |p q r s t u v w |
+000000f0 78 20 79 20 7a 20 7b 20 7c 20 7d 20 7e 20 7f 20 |x y z { | } ~ . |
+00000100 c2 80 20 c2 81 20 c2 82 20 c2 83 20 c2 84 20 c2 |.. .. .. .. .. .|
+00000110 85 20 c2 86 20 c2 87 20 c2 88 20 c2 89 20 c2 8a |. .. .. .. .. ..|
+00000120 20 c2 8b 20 c2 8c 20 c2 8d 20 c2 8e 20 c2 8f 20 | .. .. .. .. .. |
+00000130 c2 90 20 c2 91 20 c2 92 20 c2 93 20 c2 94 20 c2 |.. .. .. .. .. .|
+00000140 95 20 c2 96 20 c2 97 20 c2 98 20 c2 99 20 c2 9a |. .. .. .. .. ..|
+00000150 20 c2 9b 20 c2 9c 20 c2 9d 20 c2 9e 20 c2 9f 20 | .. .. .. .. .. |
+00000160 c2 a0 20 c2 a1 20 c2 a2 20 c2 a3 20 c2 a4 20 c2 |.. .. .. .. .. .|
+00000170 a5 20 c2 a6 20 c2 a7 20 c2 a8 20 c2 a9 20 c2 aa |. .. .. .. .. ..|
+00000180 20 c2 ab 20 c2 ac 20 c2 ad 20 c2 ae 20 c2 af 20 | .. .. .. .. .. |
+00000190 c2 b0 20 c2 b1 20 c2 b2 20 c2 b3 20 c2 b4 20 c2 |.. .. .. .. .. .|
+000001a0 b5 20 c2 b6 20 c2 b7 20 c2 b8 20 c2 b9 20 c2 ba |. .. .. .. .. ..|
+000001b0 20 c2 bb 20 c2 bc 20 c2 bd 20 c2 be 20 c2 bf 20 | .. .. .. .. .. |
+000001c0 c3 80 20 c3 81 20 c3 82 20 c3 83 20 c3 84 20 c3 |.. .. .. .. .. .|
+000001d0 85 20 c3 86 20 c3 87 20 c3 88 20 c3 89 20 c3 8a |. .. .. .. .. ..|
+000001e0 20 c3 8b 20 c3 8c 20 c3 8d 20 c3 8e 20 c3 8f 20 | .. .. .. .. .. |
+000001f0 c3 90 20 c3 91 20 c3 92 20 c3 93 20 c3 94 20 c3 |.. .. .. .. .. .|
+00000200 95 20 c3 96 20 c3 97 20 c3 98 20 c3 99 20 c3 9a |. .. .. .. .. ..|
+00000210 20 c3 9b 20 c3 9c 20 c3 9d 20 c3 9e 20 c3 9f 20 | .. .. .. .. .. |
+00000220 c3 a0 20 c3 a1 20 c3 a2 20 c3 a3 20 c3 a4 20 c3 |.. .. .. .. .. .|
+00000230 a5 20 c3 a6 20 c3 a7 20 c3 a8 20 c3 a9 20 c3 aa |. .. .. .. .. ..|
+00000240 20 c3 ab 20 c3 ac 20 c3 ad 20 c3 ae 20 c3 af 20 | .. .. .. .. .. |
+00000250 c3 b0 20 c3 b1 20 c3 b2 20 c3 b3 20 c3 b4 20 c3 |.. .. .. .. .. .|
+00000260 b5 20 c3 b6 20 c3 b7 20 c3 b8 20 c3 b9 20 c3 ba |. .. .. .. .. ..|
+00000270 20 c3 bb 20 c3 bc 20 c3 bd 20 c3 be 20 c3 bf 20 | .. .. .. .. .. |
+00000280
diff --git a/tests/expected/hexdump/highlighting-canon-2 b/tests/expected/hexdump/highlighting-canon-2
new file mode 100644
index 000000000..243670668
--- /dev/null
+++ b/tests/expected/hexdump/highlighting-canon-2
@@ -0,0 +1,41 @@
+00000000 00 20 01 20 02 20 03 20 04 20 05 20 06 20 07 20 |. . . . . . . . |
+00000010 08 20 09 20 0a 20 0b 20 0c 20 0d 20 0e 20 0f 20 |. . . . . . . . |
+00000020 10 20 11 20 12 20 13 20 14 20 15 20 16 20 17 20 |. . . . . . . . |
+00000030 18 20 19 20 1a 20 1b 20 1c 20 1d 20 1e 20 1f 20 |. . . . . . . . |
+00000040 20 20 21 20 22 20 23 20 24 20 25 20 26 20 27 20 | ! " # $ % & ' |
+00000050 28 20 29 20 2a 20 2b 20 2c 20 2d 20 2e 20 2f 20 |( ) * + , - . / |
+00000060 30 20 31 20 32 20 33 20 34 20 35 20 36 20 37 20 |0 1 2 3 4 5 6 7 |
+00000070 38 20 39 20 3a 20 3b 20 3c 20 3d 20 3e 20 3f 20 |8 9 : ; < = > ? |
+00000080 40 20 41 20 42 20 43 20 44 20 45 20 46 20 47 20 |@ A B C D E F G |
+00000090 48 20 49 20 4a 20 4b 20 4c 20 4d 20 4e 20 4f 20 |H I J K L M N O |
+000000a0 50 20 51 20 52 20 53 20 54 20 55 20 56 20 57 20 |P Q R S T U V W |
+000000b0 58 20 59 20 5a 20 5b 20 5c 20 5d 20 5e 20 5f 20 |X Y Z [ \ ] ^ _ |
+000000c0 60 20 61 20 62 20 63 20 64 20 65 20 66 20 67 20 |` a b c d e f g |
+000000d0 68 20 69 20 6a 20 6b 20 6c 20 6d 20 6e 20 6f 20 |h i j k l m n o |
+000000e0 70 20 71 20 72 20 73 20 74 20 75 20 76 20 77 20 |p q r s t u v w |
+000000f0 78 20 79 20 7a 20 7b 20 7c 20 7d 20 7e 20 7f 20 |x y z { | } ~ . |
+00000100 c2 80 20 c2 81 20 c2 82 20 c2 83 20 c2 84 20 c2 |.. .. .. .. .. .|
+00000110 85 20 c2 86 20 c2 87 20 c2 88 20 c2 89 20 c2 8a |. .. .. .. .. ..|
+00000120 20 c2 8b 20 c2 8c 20 c2 8d 20 c2 8e 20 c2 8f 20 | .. .. .. .. .. |
+00000130 c2 90 20 c2 91 20 c2 92 20 c2 93 20 c2 94 20 c2 |.. .. .. .. .. .|
+00000140 95 20 c2 96 20 c2 97 20 c2 98 20 c2 99 20 c2 9a |. .. .. .. .. ..|
+00000150 20 c2 9b 20 c2 9c 20 c2 9d 20 c2 9e 20 c2 9f 20 | .. .. .. .. .. |
+00000160 c2 a0 20 c2 a1 20 c2 a2 20 c2 a3 20 c2 a4 20 c2 |.. .. .. .. .. .|
+00000170 a5 20 c2 a6 20 c2 a7 20 c2 a8 20 c2 a9 20 c2 aa |. .. .. .. .. ..|
+00000180 20 c2 ab 20 c2 ac 20 c2 ad 20 c2 ae 20 c2 af 20 | .. .. .. .. .. |
+00000190 c2 b0 20 c2 b1 20 c2 b2 20 c2 b3 20 c2 b4 20 c2 |.. .. .. .. .. .|
+000001a0 b5 20 c2 b6 20 c2 b7 20 c2 b8 20 c2 b9 20 c2 ba |. .. .. .. .. ..|
+000001b0 20 c2 bb 20 c2 bc 20 c2 bd 20 c2 be 20 c2 bf 20 | .. .. .. .. .. |
+000001c0 c3 80 20 c3 81 20 c3 82 20 c3 83 20 c3 84 20 c3 |.. .. .. .. .. .|
+000001d0 85 20 c3 86 20 c3 87 20 c3 88 20 c3 89 20 c3 8a |. .. .. .. .. ..|
+000001e0 20 c3 8b 20 c3 8c 20 c3 8d 20 c3 8e 20 c3 8f 20 | .. .. .. .. .. |
+000001f0 c3 90 20 c3 91 20 c3 92 20 c3 93 20 c3 94 20 c3 |.. .. .. .. .. .|
+00000200 95 20 c3 96 20 c3 97 20 c3 98 20 c3 99 20 c3 9a |. .. .. .. .. ..|
+00000210 20 c3 9b 20 c3 9c 20 c3 9d 20 c3 9e 20 c3 9f 20 | .. .. .. .. .. |
+00000220 c3 a0 20 c3 a1 20 c3 a2 20 c3 a3 20 c3 a4 20 c3 |.. .. .. .. .. .|
+00000230 a5 20 c3 a6 20 c3 a7 20 c3 a8 20 c3 a9 20 c3 aa |. .. .. .. .. ..|
+00000240 20 c3 ab 20 c3 ac 20 c3 ad 20 c3 ae 20 c3 af 20 | .. .. .. .. .. |
+00000250 c3 b0 20 c3 b1 20 c3 b2 20 c3 b3 20 c3 b4 20 c3 |.. .. .. .. .. .|
+00000260 b5 20 c3 b6 20 c3 b7 20 c3 b8 20 c3 b9 20 c3 ba |. .. .. .. .. ..|
+00000270 20 c3 bb 20 c3 bc 20 c3 bd 20 c3 be 20 c3 bf 20 | .. .. .. .. .. |
+00000280
diff --git a/tests/ts/hexdump/highlighting b/tests/ts/hexdump/highlighting
new file mode 100755
index 000000000..8a0aa1d9c
--- /dev/null
+++ b/tests/ts/hexdump/highlighting
@@ -0,0 +1,235 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="highlighting"
+FILES="$TS_TOPDIR/ts/hexdump/files"
+OPTS="--color=always"
+ADDRFMT='-e "%07.7_Ax\n"'
+#sample input consists of hexdump-ed results of the following py3script:
+#for i in range(256):
+# print(chr(i), end= ' ')
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+[ -x $TS_CMD_HEXDUMP ] || ts_skip "hexdump not compiled"
+
+#
+# basic formats /w some highlighting tweaks
+#
+
+# highlight 'A' and 'a'
+ts_init_subtest "1b_octal-1"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:A,red:a] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight bytes with the value of 0x41 (A) and 0x61 (a)
+ts_init_subtest "1b_octal-2"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:0x41,red:0x61] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight the bytes at offsets 130 and 194 (decimal)
+ts_init_subtest "1b_octal-3"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red@130,red@194] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight the byte at offset 194 if it's value is 0x61 (a)
+# and the byte at offset 130 if it's value is A (0x41)
+ts_init_subtest "1b_octal-4"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:A@130,red:0x61@194] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight the byte at offset 194 if it's value is 0x61 (a)
+# and the byte at offset 130 if it's value is C (0x41) (false)
+ts_init_subtest "1b_octal-5"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:C@130,red:0x61@194] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight a range longer than the byte count of %o - error
+ts_init_subtest "1b_octal-6"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red@193-194] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight bytes with the value of 0101 (A) and 0141 (a)
+ts_init_subtest "1b_octal-7"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:0101,red:0141] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight bytes with the value of 0101 (A), 0x61 (a), or if the character is a caret
+ts_init_subtest "1b_octal-8"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:0101,blue:0x61,green:^] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# highlight bytes with the value of 0101 (A), 0x61 (a), or if the character at 196 is not 'c'
+ts_init_subtest "1b_octal-9"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%03o_L[red:0101,blue:0x61,!green:c@196] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+#color the addresses red and the characters in UTIL-LINUX green
+ts_init_subtest "1b_char-1"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax_L[red] " 16/1 "%3_c_L[green:-,green:I,green:L,green:N,green:T,green:U,green:X] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+#color the address 0xe0 red
+ts_init_subtest "1b_char-2"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax_L[red:0xe0] " 16/1 "%3_c " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+#highlight ':' and '@'
+ts_init_subtest "1b_char-3"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 16/1 "%3_c_L[red::@116,red:@@128] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color last address gray, the null byte blue, the spaces brown(-ish) and the text cyan
+ts_init_subtest "canon-1"
+$TS_CMD_HEXDUMP $OPTS \
+ -e '"%08.8_Ax_L[gray]\n"' \
+ -e '"%08.8_ax " 8/1 "%02x_L[blue:0x0,brown:0x20] " " " 8/1 "%02x_L[brown:0x20] " ' \
+ -e '" |" 16/1 "%_p_L[cyan]" "|\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color last address gray - if it's 0x280 or blue if it's 0x380
+# color A/a hex dumps blue and A/a in text green
+ts_init_subtest "canon-2"
+$TS_CMD_HEXDUMP $OPTS \
+ -e '"%08.8_Ax_L[blue:0x380,red:0x280]\n"' \
+ -e '"%08.8_ax " 8/1 "%02x_L[blue:A,blue:a] " " " 8/1 "%02x_L[blue:A,blue:a] " ' \
+ -e '" |" 16/1 "%_p_L[green:A,green:a]" "|\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if one of the bytes it prints is at offset 100 (0x64)
+ts_init_subtest "2b_dec-1"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red@100] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if of the bytes it prints are at offsets 98 and 99
+ts_init_subtest "2b_dec-2"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red@98-99] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if some or all of the bytes it prints are at offsets 98 and 99
+# (false - range longer than format byte count)
+ts_init_subtest "2b_dec-3"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red@97-99] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if it prints "A " at 130-131
+ts_init_subtest "2b_dec-4"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red:A @130-131] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if it doesn't print "B " at 130-131
+ts_init_subtest "2b_dec-5"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[!red:B @130-131] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# specify a string shorter than the range - error
+ts_init_subtest "2b_dec-6"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red:A@130-131] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# specify a negative-length range
+ts_init_subtest "2b_dec-7"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/2 " %05u_L[red:A@131-130] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if some or all of the bytes it prints are at offsets 97 and 99 (true)
+ts_init_subtest "4b_dec-1"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red@97-99] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# color the current print unit if some or all of the bytes it prints are at offsets 96-99
+ts_init_subtest "4b_dec-2"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red@96-99] " "\n"' \
+ $FILES/ascii.in &> $TS_OUTPUT
+ts_finalize_subtest
+
+# look for @@@@
+ts_init_subtest "4b_dec-3"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@] " "\n"' \
+ &> $TS_OUTPUT <<< "@@@@"
+ts_finalize_subtest
+
+# look for @@@@ at 0-3
+ts_init_subtest "4b_dec-4"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@@0-3] " "\n"' \
+ &> $TS_OUTPUT <<< "@@@@"
+ts_finalize_subtest
+
+# look for @@@ at 0-3 (wrong byte count error)
+ts_init_subtest "4b_dec-5"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@0-3] " "\n"' \
+ &> $TS_OUTPUT <<< "@@@@"
+ts_finalize_subtest
+
+# look for @@@ at 1-3 - in the format boundaries - correct
+ts_init_subtest "4b_dec-6"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@1-3] " "\n"' \
+ &> $TS_OUTPUT <<< "@@@@"
+ts_finalize_subtest
+
+# look for @@@ at 2-4 - correct range length, however steps over 2 print units - no colors
+ts_init_subtest "4b_dec-7"
+$TS_CMD_HEXDUMP $OPTS $ADDRFMT \
+ -e '"%07.7_ax " 8/4 " %05u_L[red:@@@@2-4] " "\n"' \
+ &> $TS_OUTPUT <<< "@@@@"
+ts_finalize_subtest
diff --git a/text-utils/hexdump-display.c b/text-utils/hexdump-display.c
index b195a01ae..ce714f68c 100644
--- a/text-utils/hexdump-display.c
+++ b/text-utils/hexdump-display.c
@@ -44,6 +44,7 @@
#include "xalloc.h"
#include "c.h"
#include "nls.h"
+#include "colors.h"
static void doskip(const char *, int, struct hexdump *);
static u_char *get(struct hexdump *);
@@ -53,9 +54,67 @@ enum _vflag vflag = FIRST;
static off_t address; /* address/offset in stream */
static off_t eaddress; /* end address */
+static const char *color_cond(struct hexdump_pr *pr, unsigned char *bp, int bcnt)
+{
+ register struct list_head *p;
+ register struct hexdump_clr *clr;
+ off_t offt;
+ int match;
+
+ list_for_each(p, pr->colorlist) {
+ clr = list_entry(p, struct hexdump_clr, colorlist);
+ offt = clr->offt;
+ match = 0;
+
+ /* no offset or offset outside this print unit */
+ if (offt < 0)
+ offt = address;
+ if (offt < address || offt + clr->range > address + bcnt)
+ continue;
+
+ /* match a string */
+ if (clr->str) {
+ if (pr->flags == F_ADDRESS) {
+ /* TODO */
+ }
+ else if (!strncmp(clr->str, (char *)bp + offt
+ - address, clr->range))
+ match = 1;
+ /* match a value */
+ } else if (clr->val != -1) {
+ int val = 0;
+ /* addresses are not part of the input, so we can't
+ * compare with the contents of bp */
+ if (pr->flags == F_ADDRESS) {
+ if (clr->val == address)
+ match = 1;
+ } else {
+ memcpy(&val, bp + offt - address, clr->range);
+ if (val == clr->val)
+ match = 1;
+ }
+ /* no conditions, only a color was specified */
+ } else
+ return clr->fmt;
+
+ /* return the format string or check for another */
+ if (match ^ clr->invert)
+ return clr->fmt;
+ continue;
+ }
+
+ /* no match */
+ return NULL;
+}
+
static inline void
print(struct hexdump_pr *pr, unsigned char *bp) {
+ const char *color = NULL;
+
+ if (pr->colorlist && (color = color_cond(pr, bp, pr->bcnt)))
+ color_enable(color);
+
switch(pr->flags) {
case F_ADDRESS:
printf(pr->fmt, address);
@@ -148,6 +207,8 @@ print(struct hexdump_pr *pr, unsigned char *bp) {
break;
}
}
+ if (color) /* did we colorize something? */
+ color_disable();
}
static void bpad(struct hexdump_pr *pr)
@@ -239,6 +300,13 @@ void display(struct hexdump *hex)
}
list_for_each (p, &endfu->prlist) {
pr = list_entry(p, struct hexdump_pr, prlist);
+
+ const char *color = NULL;
+ if (colors_wanted() && pr->colorlist
+ && (color = color_cond(pr, bp, pr->bcnt))) {
+ color_enable(color);
+ }
+
switch(pr->flags) {
case F_ADDRESS:
printf(pr->fmt, eaddress);
@@ -247,6 +315,8 @@ void display(struct hexdump *hex)
printf("%s", pr->fmt);
break;
}
+ if (color) /* did we highlight something? */
+ color_disable();
}
}
}
diff --git a/text-utils/hexdump-parse.c b/text-utils/hexdump-parse.c
index 17dd77343..660dcce31 100644
--- a/text-utils/hexdump-parse.c
+++ b/text-utils/hexdump-parse.c
@@ -45,8 +45,10 @@
#include "nls.h"
#include "xalloc.h"
#include "strutils.h"
+#include "colors.h"
static void escape(char *p1);
+static struct list_head *color_fmt(char *cfmt, int bcnt);
static void __attribute__ ((__noreturn__)) badcnt(const char *s)
{
@@ -391,6 +393,28 @@ isint: cs[2] = '\0';
badconv(p1);
}
+ /* Color unit(s) specified */
+ if (*p2 == '_' && p2[1] == 'L') {
+ if (colors_wanted()) {
+ char *a;
+
+ /* "cut out" the color_unit(s) */
+ a = strchr(p2, '[');
+ p2 = strrchr(p2, ']');
+ if (a++ && p2)
+ pr->colorlist = color_fmt(xstrndup(a, p2++ - a), pr->bcnt);
+ else
+ badconv(p2);
+ }
+ /* we don't want colors, quietly skip over them */
+ else {
+ p2 = strrchr(p2, ']');
+ /* be a bit louder if we don't know how to skip over them */
+ if (!p2)
+ badconv("_L");
+ ++p2;
+ }
+ }
/*
* Copy to hexdump_pr format string, set conversion character
* pointer, update original.
@@ -447,6 +471,122 @@ isint: cs[2] = '\0';
}
}
+/* [!]color[:string|:hex_number|:oct_number][@offt|@offt_start-offt_end],... */
+static struct list_head *color_fmt(char *cfmt, int bcnt)
+{
+ struct hexdump_clr *hc, *hcnext;
+ struct list_head *ret_head;
+ char *clr, *fmt;
+
+ ret_head = xmalloc(sizeof(struct list_head));
+ hcnext = hc = xcalloc(1, sizeof(struct hexdump_clr));
+
+ INIT_LIST_HEAD(&hc->colorlist);
+ INIT_LIST_HEAD(ret_head);
+ list_add_tail(&hc->colorlist, ret_head);
+
+ fmt = cfmt;
+ while (cfmt && *cfmt) {
+ char *end;
+ /* invert this condition */
+ if (*cfmt == '!') {
+ hcnext->invert = 1;
+ ++cfmt;
+ }
+
+ clr = xstrndup(cfmt, strcspn(cfmt, ":@,"));
+ cfmt += strlen(clr);
+ hcnext->fmt = colorscheme_from_string(clr);
+ free(clr);
+
+ if (!hcnext->fmt)
+ return NULL;
+
+ /* only colorize this specific value */
+ if (*cfmt == ':') {
+ ++cfmt;
+ /* a hex or oct value */
+ if (*cfmt == '0') {
+ /* hex */
+ errno = 0;
+ end = NULL;
+ if (cfmt[1] == 'x' || cfmt[1] == 'X')
+ hcnext->val = strtoul(cfmt + 2, &end, 16);
+ else
+ hcnext->val = strtoul(cfmt, &end, 8);
+ if (errno || end == cfmt)
+ badfmt(fmt);
+ cfmt = end;
+ /* a string */
+ } else {
+ off_t fmt_end;
+ char endchar;
+ char *endstr;
+
+ hcnext->val = -1;
+ /* temporarily null-delimit the format, so we can reverse-search
+ * for the start of an offset specifier */
+ fmt_end = strcspn(cfmt, ",");
+ endchar = cfmt[fmt_end];
+ cfmt[fmt_end] = '\0';
+ endstr = strrchr(cfmt, '@');
+
+ if (endstr) {
+ if (endstr[1] != '\0')
+ --endstr;
+ hcnext->str = xstrndup(cfmt, endstr - cfmt + 1);
+ } else
+ hcnext->str = xstrndup(cfmt, fmt_end);
+
+ /* restore the character */
+ cfmt[fmt_end] = endchar;
+ cfmt += strlen(hcnext->str);
+ }
+
+ /* no specific value */
+ } else
+ hcnext->val = -1;
+
+ /* only colorize at this offset */
+ hcnext->range = bcnt;
+ if (cfmt && *cfmt == '@') {
+ errno = 0;
+ hcnext->offt = strtoul(++cfmt, &cfmt, 10);
+ if (errno)
+ badfmt(fmt);
+
+ /* offset range */
+ if (*cfmt == '-') {
+ ++cfmt;
+ errno = 0;
+
+ hcnext->range =
+ strtoul(cfmt, &cfmt, 10) - hcnext->offt + 1;
+ if (errno)
+ badfmt(fmt);
+ /* offset range must be between 0 and format byte count */
+ if (!(hcnext->range >= 0 && hcnext->range <= bcnt))
+ badcnt("_L");
+ }
+ /* no specific offset */
+ } else
+ hcnext->offt = (off_t)-1;
+
+ /* check if the string we're looking for is the same length as the range */
+ if (hcnext->str && (int)strlen(hcnext->str) != hcnext->range)
+ badcnt("_L");
+
+ /* link in another condition */
+ if (cfmt && *cfmt == ',') {
+ ++cfmt;
+
+ hcnext = xcalloc(1, sizeof(struct hexdump_clr));
+ INIT_LIST_HEAD(&hcnext->colorlist);
+ list_add_tail(&hcnext->colorlist, ret_head);
+ }
+ }
+ return ret_head;
+}
static void escape(char *p1)
{
diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index e8afdbac8..8b4bf275d 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -235,6 +235,37 @@ displayed using the following, lower-case, names. Characters greater than
018 can 019 em 01A sub 01B esc 01C fs 01D gs
01E rs 01F us 0FF del
.nf
+.SS Colors
+When put at the end of a format specifier, hexdump highlights the respective
+string with the color specified. Conditions, if present, are evaluated
+prior to highlighting.
+.TP
+.B \&_L[color_unit_1,color_unit_2,...,color_unit_n]
+.TP
+The full syntax of a color unit is as follows:
+.TP
+.B [!]COLOR[:HEX_VAL|:OCT_VAL|:STRING][@DEC_OFFT|@DEC_OFFT_START-DEC_OFFT_END]
+.TP
+.B !
+Negate the condition. Please note that it only makes sense to negate
+a unit if both a value/string and an offset are specified. In that case
+the respective output string will be highlighted if and only if the value/string
+does not match the one at the offset.
+.PP
+.BR COLOR
+One of the 8 basic shell colors.
+.PP
+.BR HEX_VAL , OCT_VAL
+A value to be matched specified in hexadecimal or octal base.
+.PP
+.BR STRING
+A string to be matched. Please note that the usual C escape sequences
+are not interpreted by hexdump inside the color_units.
+.PP
+.BR DEC_OFFT , DEC_OFFT_START , DEC_OFFT_END
+An offset or an offset range at which
+to check for a match. Please note that DEC_OFFT is equal to DEC_OFFT-DEC_OFFT.
+Also, the range may not be larger than the respective format byte count.
.SS Counters
The default and supported byte counts for the conversion characters
are as follows:
@@ -313,6 +344,13 @@ Implement the \-x option:
"%07.7_Ax\en"
"%07.7_ax " 8/2 "%04x " "\en"
.nf
+.PP
+MBR Boot Signature example:
+Highlight the addresses cyan and the bytes at offsets 510 and 511 green if their value is 0xAA55, red otherwise.
+.nf
+ "%07.7_Ax_L[cyan]\en"
+ "%07.7_ax_L[cyan] " 8/2 " %04x_L[green:0xAA55@510-511,!red:0xAA55@510-511] " "\en"
+.nf
.SH STANDARDS
The
.B hexdump
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index ac7778229..19e67f46d 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -49,6 +49,7 @@
#include "list.h"
#include "nls.h"
#include "c.h"
+#include "colors.h"
#include "strutils.h"
#include "xalloc.h"
#include "closestream.h"
@@ -59,8 +60,10 @@ int
parse_args(int argc, char **argv, struct hexdump *hex)
{
int ch;
+ int colormode = UL_COLORMODE_NEVER;
char *hex_offt = "\"%07.7_Ax\n\"";
+
static const struct option longopts[] = {
{"one-byte-octal", no_argument, NULL, 'b'},
{"one-byte-char", required_argument, NULL, 'c'},
@@ -70,6 +73,7 @@ parse_args(int argc, char **argv, struct hexdump *hex)
{"two-bytes-hex", no_argument, NULL, 'x'},
{"format", required_argument, NULL, 'e'},
{"format-file", required_argument, NULL, 'f'},
+ {"color", optional_argument, NULL, 'L'},
{"length", required_argument, NULL, 'n'},
{"skip", required_argument, NULL, 's'},
{"no-squeezing", no_argument, NULL, 'v'},
@@ -103,6 +107,12 @@ parse_args(int argc, char **argv, struct hexdump *hex)
case 'f':
addfile(optarg, hex);
break;
+ case 'L':
+ colormode = UL_COLORMODE_AUTO;
+ if (optarg)
+ colormode = colormode_or_err(optarg,
+ _("unsupported color mode"));
+ break;
case 'n':
hex->length = strtosize_or_err(optarg, _("failed to parse length"));
break;
@@ -135,6 +145,7 @@ parse_args(int argc, char **argv, struct hexdump *hex)
add_fmt(hex_offt, hex);
add_fmt("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\"", hex);
}
+ colors_init (colormode);
return optind;
}
@@ -149,6 +160,7 @@ void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -d, --two-bytes-decimal two-byte decimal display\n"), out);
fputs(_(" -o, --two-bytes-octal two-byte octal display\n"), out);
fputs(_(" -x, --two-bytes-hex two-byte hexadecimal display\n"), out);
+ fputs(_(" -L, --color[=<mode>] interpret color formatting specifiers\n"), out);
fputs(_(" -e, --format <format> format string to be used for displaying data\n"), out);
fputs(_(" -f, --format-file <file> file that contains format strings\n"), out);
fputs(_(" -n, --length <length> interpret only length bytes of input\n"), out);
@@ -207,16 +219,25 @@ int main(int argc, char **argv)
void hex_free(struct hexdump *hex)
{
- struct list_head *p, *pn, *q, *qn, *r, *rn;
+ struct list_head *p, *pn, *q, *qn, *r, *rn, *s, *sn;
struct hexdump_fs *fs;
struct hexdump_fu *fu;
struct hexdump_pr *pr;
+ struct hexdump_clr *clr;
+
list_for_each_safe(p, pn, &hex->fshead) {
fs = list_entry(p, struct hexdump_fs, fslist);
list_for_each_safe(q, qn, &fs->fulist) {
fu = list_entry(q, struct hexdump_fu, fulist);
list_for_each_safe(r, rn, &fu->prlist) {
pr = list_entry(r, struct hexdump_pr, prlist);
+ if (pr->colorlist) {
+ list_for_each_safe(s, sn, pr->colorlist) {
+ clr = list_entry (s, struct hexdump_clr, colorlist);
+ free(clr->str);
+ free(clr);
+ }
+ }
free(pr->fmt);
free(pr);
}
diff --git a/text-utils/hexdump.h b/text-utils/hexdump.h
index 56f5dc55a..741a57ad2 100644
--- a/text-utils/hexdump.h
+++ b/text-utils/hexdump.h
@@ -35,6 +35,16 @@
#include "c.h"
#include "list.h"
+struct hexdump_clr {
+ struct list_head colorlist; /* next color unit */
+ const char *fmt; /* the color, UL_COLOR_* */
+ off_t offt; /* offset where unit is valid... */
+ int range; /* ... and it's range */
+ int val; /* value ... */
+ char *str; /* ... or string to match */
+ int invert; /* invert condition? */
+};
+
struct hexdump_pr {
struct list_head prlist; /* next print unit */
#define F_ADDRESS 0x001 /* print offset */
@@ -51,6 +61,7 @@ struct hexdump_pr {
unsigned int flags; /* flag values */
int bcnt; /* byte count */
char *cchar; /* conversion character */
+ struct list_head *colorlist; /* color settings */
char *fmt; /* printf format */
char *nospace; /* no whitespace version */
};