From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16551 invoked by alias); 26 Sep 2013 19:57:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16538 invoked by uid 89); 26 Sep 2013 19:57:51 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.215) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Sep 2013 19:57:51 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.3 required=5.0 tests=AWL,BAYES_50,MSGID_MULTIPLE_AT,SPAM_SUBJECT autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id 6EF48A09F6 for ; Thu, 26 Sep 2013 21:57:48 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id 5F80DA0921 for ; Thu, 26 Sep 2013 21:57:48 +0200 (CEST) Received: from md15.u-strasbg.fr (md15.u-strasbg.fr [130.79.200.204]) by mr5.u-strasbg.fr (Postfix) with ESMTP id 4EFC1A08C8 for ; Thu, 26 Sep 2013 21:57:47 +0200 (CEST) Received: from ms13.u-strasbg.fr (ms13.u-strasbg.fr [130.79.204.113]) by md15.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r8QJvlY6015492 for ; Thu, 26 Sep 2013 21:57:47 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (Authenticated sender: mullerp) by ms13.u-strasbg.fr (Postfix) with ESMTPSA id D86261FD84 for ; Thu, 26 Sep 2013 21:57:46 +0200 (CEST) From: "Pierre Muller" To: "'gdb-patches'" References: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> Subject: [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate. Date: Thu, 26 Sep 2013 19:57:00 -0000 Message-ID: <002f01cebaf2$aac80410$00580c30$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00938.txt.bz2 If charset is set to UTF-8 p "ABCD\340" will output "ABC" 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 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 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