This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts.
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: "'Keith Seitz'" <keiths at redhat dot com>, "'gdb-patches'" <gdb-patches at sourceware dot org>
- Date: Fri, 8 Nov 2013 11:11:54 +0100
- Subject: RE: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts.
- Authentication-results: sourceware.org; auth=none
- References: <002901cebaf2$35ec65a0$a1c530e0$ at muller@ics-cnrs.unistra.fr> <002c01cebaf2$89798ea0$9c6cabe0$ at muller@ics-cnrs.unistra.fr> <524A230B dot 5020304 at redhat dot com> <10182 dot 1932978512$1380614580 at news dot gmane dot org> <87txfpmdst dot fsf at fleche dot redhat dot com>
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé : mercredi 6 novembre 2013 22:16
> À : Pierre Muller
> Cc : 'Keith Seitz'; 'gdb-patches'
> Objet : Re: [RFC 1/6 -V2] Fix display of tabulation character for mingw
> hosts.
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
> writes:
>
> Pierre> 2013-10-01 Pierre Muller <muller@sourceware.org>
> 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.
>
> 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 = *need_escapep;
*need_escapep = 0;
- if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
- && w != LCST ('8')
- && w != LCST ('9'))))
- {
- gdb_wchar_t wchar = w;
- if (w == gdb_btowc (quoter) || w == 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 >= 0 && w < 0x7f))
+ && (!need_escape || (!gdb_iswdigit (w)
+ && w != LCST ('8')
+ && w != LCST ('9'))))
+ {
+ gdb_wchar_t wchar = w;
- for (i = 0; i + width <= orig_len; i += width)
- {
- char octal[30];
- ULONGEST value;
+ if (w == gdb_btowc (quoter) || w == LCST ('\\'))
+ obstack_grow_wstr (output, LCST ("\\"));
+ obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
+ }
+ else
+ {
+ int i;
+
+ for (i = 0; i + width <= orig_len; i += width)
+ {
+ char octal[30];
+ ULONGEST value;
- value = extract_unsigned_integer (&orig[i], width,
+ value = 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 <= 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 <= 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];
- 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;
+ }
- *need_escapep = 1;
- }
+ *need_escapep = 1;
+ }
break;
}
}