* event-loop.c: Include unistd.h if it exists.
[deliverable/binutils-gdb.git] / gdb / c-lang.c
index d01490cdce0a89b01bd75e2cf2e36398844105d8..405c489fa4f9a857ccedc2847b4324306c9dc3bb 100644 (file)
@@ -52,17 +52,17 @@ charset_for_string_type (enum c_string_type str_type,
     case C_WIDE_STRING:
       return target_wide_charset (byte_order);
     case C_STRING_16:
-      /* FIXME: UCS-2 is not always correct.  */
+      /* FIXME: UTF-16 is not always correct.  */
       if (byte_order == BFD_ENDIAN_BIG)
-       return "UCS-2BE";
+       return "UTF-16BE";
       else
-       return "UCS-2LE";
+       return "UTF-16LE";
     case C_STRING_32:
-      /* FIXME: UCS-4 is not always correct.  */
+      /* FIXME: UTF-32 is not always correct.  */
       if (byte_order == BFD_ENDIAN_BIG)
-       return "UCS-4BE";
+       return "UTF-32BE";
       else
-       return "UCS-4LE";
+       return "UTF-32LE";
     }
   internal_error (__FILE__, __LINE__, "unhandled c_string_type");
 }
@@ -618,7 +618,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
 
 void
 c_get_string (struct value *value, gdb_byte **buffer, int *length,
-             const char **charset)
+             struct type **char_type, const char **charset)
 {
   int err, width;
   unsigned int fetchlimit;
@@ -626,6 +626,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
   struct type *element_type = TYPE_TARGET_TYPE (type);
   int req_length = *length;
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+  enum c_string_type kind;
 
   if (element_type == NULL)
     goto error;
@@ -652,13 +653,11 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
     /* We work only with arrays and pointers.  */
     goto error;
 
-  element_type = check_typedef (element_type);
-  if (TYPE_CODE (element_type) != TYPE_CODE_INT
-      && TYPE_CODE (element_type) != TYPE_CODE_CHAR)
-    /* If the elements are not integers or characters, we don't consider it
-       a string.  */
+  if (! c_textual_element_type (element_type, 0))
     goto error;
-
+  kind = classify_type (element_type,
+                       gdbarch_byte_order (get_type_arch (element_type)),
+                       charset);
   width = TYPE_LENGTH (element_type);
 
   /* If the string lives in GDB's memory instead of the inferior's, then we
@@ -717,7 +716,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
   if (*length != 0)
      *length = *length / width;
 
-  *charset = target_charset ();
+  *char_type = element_type;
 
   return;
 
@@ -763,7 +762,7 @@ convert_ucn (char *p, char *limit, const char *dest_charset,
       result >>= 8;
     }
 
-  convert_between_encodings ("UCS-4BE", dest_charset, data, 4, 4, output,
+  convert_between_encodings ("UTF-32BE", dest_charset, data, 4, 4, output,
                             translit_none);
 
   return p;
This page took 0.025153 seconds and 4 git commands to generate.