This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate.
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'gdb-patches'" <gdb-patches at sourceware dot org>
- Date: Thu, 26 Sep 2013 21:57:44 +0200
- Subject: [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate.
- Authentication-results: sourceware.org; auth=none
- References: <002901cebaf2$35ec65a0$a1c530e0$ at muller@ics-cnrs.unistra.fr>
If charset is set to UTF-8
p "ABCD\340"
will output
"ABC" <incomplete sequence \340>
Note the missing character 'D'.
This patch solves the issue by checking also for EINVAL
if character have been converted.
Pierre Muller
GDB pascal language maintainer
2013-09-26 Pierre Muller <muller@sourceware.org>
charset.c (wchar_iterate): Also handle converted characters
when EINVAL is returned by iconv call.
>From 8a93eac07fa4a5c3b9b77832cd6ebb50e2a07d68 Mon Sep 17 00:00:00 2001
From: Pierre Muller <muller@ics.u-strasbg.fr>
Date: Thu, 26 Sep 2013 17:34:01 +0200
---
gdb/charset.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/gdb/charset.c b/gdb/charset.c
index 5835fd4..f0e258c 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -659,7 +659,7 @@ wchar_iterate (struct wchar_iterator *iter,
converted a character; if so, return it. */
if (out_avail < out_request * sizeof (gdb_wchar_t))
break;
-
+
/* Otherwise skip the first invalid character, and let
the caller know about it. */
*out_result = wchar_iterate_invalid;
@@ -687,7 +687,10 @@ wchar_iterate (struct wchar_iterator *iter,
case EINVAL:
/* Incomplete input sequence. Let the caller know, and
- arrange for future calls to see EOF. */
+ arrange for future calls to see EOF.
+ Here also we might have converted something. */
+ if (out_avail < out_request * sizeof (gdb_wchar_t))
+ break;
*out_result = wchar_iterate_incomplete;
*ptr = iter->input;
*len = iter->bytes;
--
1.7.9