PR python/10664:
	* language.h (struct language_defn) <la_get_string>: Add
	'char_type' argument.
	(LA_GET_STRING): Likewise.
	(default_get_string, c_get_string): Update.
	* language.c (default_get_string): Add 'char_type' argument.
	* c-valprint.c (c_textual_element_type): Rename from
	textual_element_type.  No longer static.  Update callers.
	* c-lang.h (c_textual_element_type): Declare.
	* c-lang.c (c_get_string): Add 'char_type' argument.
gdb/testsuite
	PR python/10664:
	* gdb.base/charset.exp: Test utf-16 strings with Python.
This commit is contained in:
Tom Tromey 2009-09-25 21:39:53 +00:00
parent b8899f2b68
commit 96c07c5b96
9 changed files with 65 additions and 23 deletions

View file

@ -238,6 +238,7 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
const char *errors = NULL;
const char *user_encoding = NULL;
const char *la_encoding = NULL;
struct type *char_type;
static char *keywords[] = { "encoding", "errors", "length" };
if (!PyArg_ParseTupleAndKeywords (args, kw, "|ssi", keywords,
@ -246,12 +247,13 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
TRY_CATCH (except, RETURN_MASK_ALL)
{
LA_GET_STRING (value, &buffer, &length, &la_encoding);
LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding);
}
GDB_PY_HANDLE_EXCEPTION (except);
encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding;
unicode = PyUnicode_Decode (buffer, length, encoding, errors);
unicode = PyUnicode_Decode (buffer, length * TYPE_LENGTH (char_type),
encoding, errors);
xfree (buffer);
return unicode;