>From c72ac3c55581d81f5c280b6a93b986ca46f6ebe9 Mon Sep 17 00:00:00 2001 From: Hideo Haga Date: Sat, 29 Jun 2019 01:39:38 -0600 Subject: [PATCH] sed: debug-print non-printable octets as hex Previously sed would print values in octal like so: $ printf 'a\u03A3b' | sed --debug 's/./X/g' [...] PATTERN: a\o37777777716\o37777777643b [...] Discussed in https://lists.gnu.org/r/sed-devel/2019-06/msg00001.html * sed/debug.c (debug_print_char): Use %x instead of %o, and trim octet value to 255. * NEWS: Mention improvement. Copyright-paperwork-exempt: Yes --- NEWS | 6 ++++++ sed/debug.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0c1aa73..662d4ed 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ GNU sed NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Improvements + + sed --debug now prints non-printable octets as 2-digit hex values + instead of octal values (and correctly prints values > 127). + [old behavior existed since introduction of --debug in version 4.6] + * Noteworthy changes in release 4.7 (2018-12-20) [stable] diff --git a/sed/debug.c b/sed/debug.c index 93228b8..f8ecbc1 100644 --- a/sed/debug.c +++ b/sed/debug.c @@ -66,7 +66,7 @@ debug_print_char (char c) break; default: - printf ("o%03o", (unsigned int) c); + printf ("x%02x", (unsigned int) c & 0xff); } } -- 2.11.0