34484a
From 05b9033b464ce8dd2c9b33238f9aa14755d7a91a Mon Sep 17 00:00:00 2001
34484a
From: Karl Williamson <khw@cpan.org>
34484a
Date: Sat, 17 Jun 2017 17:56:10 -0600
34484a
Subject: [PATCH] utf8n_to_uvchr(): Don't display too many bytes in msg
34484a
MIME-Version: 1.0
34484a
Content-Type: text/plain; charset=UTF-8
34484a
Content-Transfer-Encoding: 8bit
34484a
34484a
When raising a message about malformed UTF-8, we shouldn't display bytes
34484a
from the next character, unless those bytes were expected to have been
34484a
part of the current one.  Tests for this will be added in future commits
34484a
in ext/XS-APItest/t/utf8_warn_base.pl
34484a
34484a
Signed-off-by: Petr Písař <ppisar@redhat.com>
34484a
---
34484a
 utf8.c | 4 ++--
34484a
 1 file changed, 2 insertions(+), 2 deletions(-)
34484a
34484a
diff --git a/utf8.c b/utf8.c
34484a
index ee5405f..e55a6f1 100644
34484a
--- a/utf8.c
34484a
+++ b/utf8.c
34484a
@@ -1428,7 +1428,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
34484a
                         if (pack_warn) {
34484a
                             message = Perl_form(aTHX_ "%s: %s (overflows)",
34484a
                                             malformed_text,
34484a
-                                            _byte_dump_string(s0, send - s0, 0));
34484a
+                                            _byte_dump_string(s0, curlen, 0));
34484a
                         }
34484a
                     }
34484a
                 }
34484a
@@ -1554,7 +1554,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
34484a
                                 "%s: %s (overlong; instead use %s to represent"
34484a
                                 " U+%0*" UVXf ")",
34484a
                                 malformed_text,
34484a
-                                _byte_dump_string(s0, send - s0, 0),
34484a
+                                _byte_dump_string(s0, curlen, 0),
34484a
                                 _byte_dump_string(tmpbuf, e - tmpbuf, 0),
34484a
                                 ((uv < 256) ? 2 : 4), /* Field width of 2 for
34484a
                                                          small code points */
34484a
-- 
34484a
2.9.4
34484a