Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Tom Tromey'" <tromey@redhat.com>
Cc: "'Keith Seitz'" <keiths@redhat.com>,
	       "'gdb-patches'" <gdb-patches@sourceware.org>
Subject: RE: [RFC 1/6 -V2] Fix display of tabulation character for mingw hosts.
Date: Fri, 08 Nov 2013 10:26:00 -0000	[thread overview]
Message-ID: <004e01cedc6a$f4635e00$dd2a1a00$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <87txfpmdst.fsf@fleche.redhat.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;
 	}
     }


  reply	other threads:[~2013-11-08 10:12 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-26 19:54 [RFC 0/6] Handle several character priniting problems (mainly related to mingw hosts) Pierre Muller
2013-09-26 19:57 ` [RFC 1/6] Fix display of tabulation character for mingw hosts Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01  8:02     ` [RFC 1/6 -V2] " Pierre Muller
2013-10-22 18:24       ` Keith Seitz
     [not found]     ` <10182.1932978512$1380614580@news.gmane.org>
2013-11-06 21:24       ` Tom Tromey
2013-11-08 10:26         ` Pierre Muller [this message]
2013-09-26 19:57 ` [RFC 2/6] Avoid missing char before incomplete sequence in wchar_iterate Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 12:48     ` Pierre Muller
2013-10-22 18:25       ` Keith Seitz
     [not found]     ` <33559.6669152894$1380631692@news.gmane.org>
2013-11-06 21:38       ` Tom Tromey
2013-11-08 11:21         ` Pierre Muller
     [not found]         ` <"007201cedc72$46a78810$d3f69830$@muller"@ics-cnrs.unistra.fr>
2013-11-08 11:43           ` Eli Zaretskii
2013-09-26 20:01 ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command Pierre Muller
2013-09-26 20:03 ` [RFC 4/6] Always set testsuite mode and interactive mode for mingw hosts Pierre Muller
2013-09-26 20:04 ` [RFC 5/6] Handle "set print sevenbit-strings on" in print_wchar Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 13:23     ` Pierre Muller
2013-10-22 18:25       ` Keith Seitz
2013-11-06 21:43         ` Tom Tromey
2013-09-26 20:05 ` [RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts Pierre Muller
2013-10-01  1:19   ` Keith Seitz
2013-10-01 13:39     ` Pierre Muller
2013-10-22 18:26       ` Keith Seitz
2013-11-06 21:53         ` Tom Tromey
     [not found] ` <33207.6293569573$1380225714@news.gmane.org>
2013-09-27  8:07   ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command asmwarrior
2013-09-27  8:11     ` asmwarrior
2013-09-27 12:12       ` Pierre Muller
2013-09-27 15:07   ` Tom Tromey
2013-09-27 17:42     ` Pierre Muller
     [not found]     ` <5245c3a0.a3e2440a.4b98.ffffd279SMTPIN_ADDED_BROKEN@mx.google.com>
2013-09-27 19:36       ` Pedro Alves
2013-09-27 19:40         ` Pedro Alves
2013-09-27 21:12           ` Pierre Muller
2013-09-29 13:45         ` Yao Qi
2013-09-29 18:51           ` Pedro Alves
2013-09-29 23:00             ` Pierre Muller
2013-09-30  9:38               ` Pedro Alves
2013-09-30 12:33               ` Yao Qi
2013-10-01 19:42               ` Keith Seitz
     [not found]             ` <10148.9390749068$1380495630@news.gmane.org>
2013-09-29 23:54               ` asmwarrior
2013-09-30 19:23               ` Tom Tromey
2013-09-30 19:34                 ` Eli Zaretskii
2013-09-30 19:45                   ` Pedro Alves
2013-09-30 22:41                     ` Pierre Muller
     [not found] ` <11813.6176527061$1380225854@news.gmane.org>
2013-09-27 15:13   ` [RFC 5/6] Handle "set print sevenbit-strings on" in print_wchar Tom Tromey
2013-09-27 15:23     ` Pierre Muller
     [not found] ` <9177.88728042996$1380225912@news.gmane.org>
2013-11-06 21:50   ` [RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts Tom Tromey
     [not found] <"002901cebaf2$35ec65a0$a1c530e0$@muller"@ics-cnrs.unistra.fr>
     [not found] ` <"003201cebaf3$338a8b60$9a9fa220$@muller"@ics-cnrs.unistra.fr>
2013-09-26 20:08   ` [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command Eli Zaretskii
2013-09-26 20:13     ` Pierre Muller
     [not found]     ` <"003e01cebaf4$e97923e0$bc6b6ba0$@muller"@ics-cnrs.unistra.fr>
2013-09-27  5:52       ` Eli Zaretskii
2013-09-27  6:53         ` Pierre Muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='004e01cedc6a$f4635e00$dd2a1a00$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox