aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1998-10-05 19:42:04 +0000
committerStu Grossman <grossman@cygnus>1998-10-05 19:42:04 +0000
commit242c0d81808102504721ac1289dccec5dce660f9 (patch)
treea0d74af308640017ea9e48e4a98be116f50bac55 /gdb/c-lang.c
parentecd41d25b901d3fdee37e8215c288892b4c8c3d5 (diff)
downloadgdb-242c0d81808102504721ac1289dccec5dce660f9.zip
gdb-242c0d81808102504721ac1289dccec5dce660f9.tar.gz
gdb-242c0d81808102504721ac1289dccec5dce660f9.tar.bz2
* c-lang.c (emit_char c_printchar c_printstr), c-lang.h (c_printstr)
ch-lang.c (chill_printstr chill_printchar) c-valprint.c (c_val_print) ch-valprint.c (chill_val_print) expprint.c (print_subexp) f-lang.c (f_printstr f_printchar emit_char) f-valprint.c (f_val_print) jv-lang.c (java_printchar java_emit_char) jv-valprint.c (java_value_print java_val_print) language.c (unk_lang_printchar unk_lang_printstr unk_lang_emit_char) language.h (struct language_defn LA_PRINT_STRING LA_EMIT_CHAR) m2-lang.c (m2_printstr m2_printchar emit_char) printcmd.c (print_formatted) scm-lang.c (scm_printstr) valprint.c (val_print_string) value.h (val_print_string): Add emit_char routines to language_desc struct to allow finer control over language specific character output issues. Add character width arg to printstr routines to allow handling of wchar_t/Unicode strings. Fix c_printstr to handle wide characters. Supply width argument to LA_PRINT_STRING and val_print_string. * jv-lang.c (java_object_type dynamics_objfile java_link_class_type get_dynamics_objfile get_java_object_type) jv-lang.h (get_java_object_type): Make lots of things static. * expprint.c (dump_prefix_expression dump_subexp): Move opcode name printing to common routine (op_name). * (dump_subexp): Add support for OP_SCOPE.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a104e61..251b0b2 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -25,19 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "language.h"
#include "c-lang.h"
-static void emit_char PARAMS ((int, GDB_FILE *, int));
+static void c_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
characters and strings is language specific. */
static void
-emit_char (c, stream, quoter)
+c_emit_char (c, stream, quoter)
register int c;
GDB_FILE *stream;
int quoter;
{
-
c &= 0xFF; /* Avoid sign bit follies */
if (PRINT_LITERAL_FORM (c))
@@ -85,21 +84,23 @@ c_printchar (c, stream)
int c;
GDB_FILE *stream;
{
- fputs_filtered ("'", stream);
- emit_char (c, stream, '\'');
- fputs_filtered ("'", stream);
+ fputc_filtered ('\'', stream);
+ LA_EMIT_CHAR (c, stream, '\'');
+ fputc_filtered ('\'', stream);
}
/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
+ LENGTH is -1 if the string is nul terminated. Each character is WIDTH bytes
+ long. Printing stops early if the number hits print_max; repeat counts are
+ printed as appropriate. Print ellipses at the end if we had to stop before
+ printing LENGTH characters, or if FORCE_ELLIPSES. */
void
-c_printstr (stream, string, length, force_ellipses)
+c_printstr (stream, string, length, width, force_ellipses)
GDB_FILE *stream;
char *string;
unsigned int length;
+ int width;
int force_ellipses;
{
register unsigned int i;
@@ -113,7 +114,9 @@ c_printstr (stream, string, length, force_ellipses)
/* If the string was not truncated due to `set print elements', and
the last byte of it is a null, we don't print that, in traditional C
style. */
- if ((!force_ellipses) && length > 0 && string[length-1] == '\0')
+ if (!force_ellipses
+ && length > 0
+ && extract_unsigned_integer (string + (length - 1) * width, width) == '\0')
length--;
if (length == 0)
@@ -129,6 +132,7 @@ c_printstr (stream, string, length, force_ellipses)
unsigned int rep1;
/* Number of repetitions we have detected so far. */
unsigned int reps;
+ unsigned long current_char;
QUIT;
@@ -138,9 +142,13 @@ c_printstr (stream, string, length, force_ellipses)
need_comma = 0;
}
+ current_char = extract_unsigned_integer (string + i * width, width);
+
rep1 = i + 1;
reps = 1;
- while (rep1 < length && string[rep1] == string[i])
+ while (rep1 < length
+ && extract_unsigned_integer (string + rep1 * width, width)
+ == current_char)
{
++rep1;
++reps;
@@ -156,7 +164,7 @@ c_printstr (stream, string, length, force_ellipses)
fputs_filtered ("\", ", stream);
in_quotes = 0;
}
- c_printchar (string[i], stream);
+ LA_PRINT_CHAR (current_char, stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
things_printed += repeat_count_threshold;
@@ -172,7 +180,7 @@ c_printstr (stream, string, length, force_ellipses)
fputs_filtered ("\"", stream);
in_quotes = 1;
}
- emit_char (string[i], stream, '"');
+ LA_EMIT_CHAR (current_char, stream, '"');
++things_printed;
}
}
@@ -404,6 +412,7 @@ const struct language_defn c_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
@@ -430,6 +439,7 @@ const struct language_defn cplus_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
@@ -456,6 +466,7 @@ const struct language_defn asm_language_defn = {
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
+ c_emit_char, /* Print a single char */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */