From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22163 invoked by alias); 8 Nov 2013 10:12:14 -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 22152 invoked by uid 89); 8 Nov 2013 10:12:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.5 required=5.0 tests=AWL,BAYES_50,MSGID_MULTIPLE_AT,RDNS_NONE,SPAM_SUBJECT,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from Unknown (HELO mailhost.u-strasbg.fr) (130.79.222.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2013 10:12:12 +0000 Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id 406801406B4; Fri, 8 Nov 2013 11:12:02 +0100 (CET) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id 32A6314056E; Fri, 8 Nov 2013 11:12:02 +0100 (CET) Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mr2.u-strasbg.fr (Postfix) with ESMTP id E916D1406E8; Fri, 8 Nov 2013 11:11:58 +0100 (CET) Received: from ms17.u-strasbg.fr (ms17.u-strasbg.fr [130.79.204.117]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id rA8ABvBk016534 ; Fri, 8 Nov 2013 11:11:58 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (Authenticated sender: mullerp) by ms17.u-strasbg.fr (Postfix) with ESMTPSA id 8C5181FD95; Fri, 8 Nov 2013 11:11:55 +0100 (CET) From: "Pierre Muller" To: "'Tom Tromey'" Cc: "'Keith Seitz'" , "'gdb-patches'" References: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> <002c01cebaf2$89798ea0$9c6cabe0$@muller@ics-cnrs.unistra.fr> <524A230B.5020304@redhat.com> <10182.1932978512$1380614580@news.gmane.org> <87txfpmdst.fsf@fleche.redhat.com> In-Reply-To: <87txfpmdst.fsf@fleche.redhat.com> Subject: RE: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts. Date: Fri, 08 Nov 2013 10:26:00 -0000 Message-ID: <004e01cedc6a$f4635e00$dd2a1a00$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-11/txt/msg00225.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Tom Tromey > Envoy=E9=A0: mercredi 6 novembre 2013 22:16 > =C0=A0: Pierre Muller > Cc=A0: 'Keith Seitz'; 'gdb-patches' > Objet=A0: Re: [RFC 1/6 -V2] Fix display of tabulation character for mingw > hosts. >=20 > >>>>> "Pierre" =3D=3D Pierre Muller > writes: >=20 > Pierre> 2013-10-01 Pierre Muller > Pierre> Fix display of tabulation character for MinGW hosts. > Pierre> * gdb_wchar.h (gdb_iswprint): Declare as external function > Pierre> if __MINGW32__ macro is set. > Pierre> (HAVE_MINGW_GDB_ISWPRINT): New macro, declared only for > Pierre> MinGW hosts using wide characters. > Pierre> * mingw-hdep.c (gdb_iswprint): New function. > Pierre> Implemented only if HAVE_MINGW_GDB_ISWPRINT macro is > defined. >=20 > If this is just for working around one mingw bug in one spot in gdb, I > think on the whole it would be simpler to just check for \t directly in > print_wchar. I think with a short comment it will be simpler in the > end > than a new macro and a new host-specific function. I tried to move the change inside print_wchar function, but I couldn't get it into something smaller than that (the patch below also contains the other changes of the same series). Should I resubmit this formally, despite the fact that it is not as simple as one might have expected? Pierre diff --git a/gdb/valprint.c b/gdb/valprint.c index 0ecea0c..7e864f6 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1929,73 +1929,79 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int need_escape =3D *need_escapep; =20 *need_escapep =3D 0; - if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w) - && w !=3D LCST ('8') - && w !=3D LCST ('9')))) - { - gdb_wchar_t wchar =3D w; =20 - if (w =3D=3D gdb_btowc (quoter) || w =3D=3D LCST ('\\')) - obstack_grow_wstr (output, LCST ("\\")); - obstack_grow (output, &wchar, sizeof (gdb_wchar_t)); - } - else + /* iswprint implementation returns 1 on mingw hosts. + In order to avoid different printout on this host, + we explicitly use wchar_printable function. */ + switch (w) { - switch (w) + case LCST ('\a'): + obstack_grow_wstr (output, LCST ("\\a")); + break; + case LCST ('\b'): + obstack_grow_wstr (output, LCST ("\\b")); + break; + case LCST ('\f'): + obstack_grow_wstr (output, LCST ("\\f")); + break; + case LCST ('\n'): + obstack_grow_wstr (output, LCST ("\\n")); + break; + case LCST ('\r'): + obstack_grow_wstr (output, LCST ("\\r")); + break; + case LCST ('\t'): + obstack_grow_wstr (output, LCST ("\\t")); + break; + case LCST ('\v'): + obstack_grow_wstr (output, LCST ("\\v")); + break; + default: { - case LCST ('\a'): - obstack_grow_wstr (output, LCST ("\\a")); - break; - case LCST ('\b'): - obstack_grow_wstr (output, LCST ("\\b")); - break; - case LCST ('\f'): - obstack_grow_wstr (output, LCST ("\\f")); - break; - case LCST ('\n'): - obstack_grow_wstr (output, LCST ("\\n")); - break; - case LCST ('\r'): - obstack_grow_wstr (output, LCST ("\\r")); - break; - case LCST ('\t'): - obstack_grow_wstr (output, LCST ("\\t")); - break; - case LCST ('\v'): - obstack_grow_wstr (output, LCST ("\\v")); - break; - default: - { - int i; + if (wchar_printable (w) + && (!sevenbit_strings || (w >=3D 0 && w < 0x7f)) + && (!need_escape || (!gdb_iswdigit (w) + && w !=3D LCST ('8') + && w !=3D LCST ('9')))) + { + gdb_wchar_t wchar =3D w; =20 - for (i =3D 0; i + width <=3D orig_len; i +=3D width) - { - char octal[30]; - ULONGEST value; + if (w =3D=3D gdb_btowc (quoter) || w =3D=3D LCST ('\\')) + obstack_grow_wstr (output, LCST ("\\")); + obstack_grow (output, &wchar, sizeof (gdb_wchar_t)); + } + else + { + int i; + + for (i =3D 0; i + width <=3D orig_len; i +=3D width) + { + char octal[30]; + ULONGEST value; =20 - value =3D extract_unsigned_integer (&orig[i], width, + value =3D extract_unsigned_integer (&orig[i], width, byte_order); - /* If the value fits in 3 octal digits, print it that - way. Otherwise, print it as a hex escape. */ - if (value <=3D 0777) - xsnprintf (octal, sizeof (octal), "\\%.3o", - (int) (value & 0777)); - else - xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value); - append_string_as_wide (octal, output); - } - /* If we somehow have extra bytes, print them now. */ - while (i < orig_len) - { - char octal[5]; + /* If the value fits in 3 octal digits, print it that + way. Otherwise, print it as a hex escape. */ + if (value <=3D 0777) + xsnprintf (octal, sizeof (octal), "\\%.3o", + (int) (value & 0777)); + else + xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value); + append_string_as_wide (octal, output); + } + /* If we somehow have extra bytes, print them now. */ + while (i < orig_len) + { + char octal[5]; =20 - xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff); - append_string_as_wide (octal, output); - ++i; - } + xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff); + append_string_as_wide (octal, output); + ++i; + } =20 - *need_escapep =3D 1; - } + *need_escapep =3D 1; + } break; } }