This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Patch: printing java `char' values
>>>>> "Michael" == Michael Snyder <msnyder@redhat.com> writes:
Michael> Yes, that's the idea. I wouldn't even bother with the temp
Michael> variable-- I would just call TYPE_CODE (type) twice. It's a
Michael> macro, and not expensive to evaluate. Then you don't need
Michael> the brackets.
Ok. I've made this change and another one suggested by Andrew Cagney
privately.
Is this one ok to commit?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* jv-valprint.c (java_val_print): Handle `char' as a special case
of TYPE_CODE_INT.
Index: jv-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-valprint.c,v
retrieving revision 1.9
diff -u -r1.9 jv-valprint.c
--- jv-valprint.c 21 Oct 2001 01:57:42 -0000 1.9
+++ jv-valprint.c 9 May 2002 04:05:49 -0000
@@ -497,18 +498,17 @@
return i;
case TYPE_CODE_CHAR:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
- else
- LA_PRINT_CHAR ((int) unpack_long (type, valaddr), stream);
- break;
-
case TYPE_CODE_INT:
- /* Can't just call c_val_print because that print bytes as C chars. */
+ /* Can't just call c_val_print because that prints bytes as C
+ chars. */
format = format ? format : output_format;
if (format)
print_scalar_formatted (valaddr, type, format, 0, stream);
+ else if (TYPE_CODE (type) == TYPE_CODE_CHAR
+ || (TYPE_CODE (type) == TYPE_CODE_INT
+ && TYPE_LENGTH (type) == 2
+ && strcmp (TYPE_NAME (type), "char") == 0))
+ LA_PRINT_CHAR ((int) unpack_long (type, valaddr), stream);
else
val_print_type_code_int (type, valaddr, stream);
break;