This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Fix typo in type of parameter "w" in print_wchar...


> I think this is wrong.  The type of a single wide character is wint_t
> instead of wchar_t such that it can properly hold WEOF, much in the
> same way as the "normal" character functions use int instead of char.

Thanks for the hint, Mark.  Does the following look correct to you?
I've just tested that it also fixes the issue on AIX, and I got no
regression on amd64-linux.

2009-05-07  Joel Brobecker  <brobecker@adacore.com>

        * c-lang.c (print_wchar): Convert w into a gdb_wchar_t before
        pushing it on the output obstack.

-- 
Joel
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 027e9b2..f95c98f 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -166,9 +166,11 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
 					    && w != LCST ('8')
 					    && w != LCST ('9'))))
     {
+      gdb_wchar_t wchar = (gdb_wchar_t) w;
+
       if (w == gdb_btowc (quoter) || w == LCST ('\\'))
 	obstack_grow_wstr (output, LCST ("\\"));
-      obstack_grow (output, &w, sizeof (gdb_wchar_t));
+      obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
     }
   else
     {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]