This is the mail archive of the mailing list for the Archer 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]

[archer] RFA: fix duplicate target-wide-encoding

The libstdc++ pretty-printer code has a target-wide-encoding
parameter -- but this is also provided by the charset branch.

This patch removes the python one in favor of the internal one.

Jan, does this look ok for the archer branch?
I assume there is no other branch it ought to go on...


2009-03-11  Tom Tromey  <>

	* python/lib/gdb/libstdcxx/v6/ (WideEncoding): Remove.
	(target_wide_charset): Likewise.
	(StdStringPrinter.to_string): Change encoding lookup.
	(build_libstdcxx_dictionary): Update.

diff --git a/gdb/python/lib/gdb/libstdcxx/v6/ b/gdb/python/lib/gdb/libstdcxx/v6/
index c0dc987..2572731 100644
--- a/gdb/python/lib/gdb/libstdcxx/v6/
+++ b/gdb/python/lib/gdb/libstdcxx/v6/
@@ -436,22 +436,6 @@ class StdDequeIteratorPrinter:
     def to_string(self):
         return self.val['_M_cur'].dereference()
-class WideEncoding (gdb.Parameter):
-    """The target wide character set is the encoding used for wchar_t."""
-    set_doc = "Set the target wide character set."
-    show_doc = "Show the target wide character set."
-    # FIXME: needs a complete method -- but does Parameter support it?
-    def __init__ (self):
-        super (WideEncoding, self).__init__ ("target-wide-charset",
-                                             gdb.COMMAND_SUPPORT,
-                                             gdb.PARAM_STRING)
-        # I think this is ok for most glibc locales.
-        self.value = 'UTF-32'
-target_wide_charset = WideEncoding()
 class StdStringPrinter:
     "Print a std::basic_string of some kind"
@@ -462,10 +446,8 @@ class StdStringPrinter:
     def to_string(self):
         # Look up the target encoding as late as possible.
         encoding = self.encoding
-        if encoding is None:
-            encoding = gdb.parameter('target-charset')
-        elif isinstance(encoding, WideEncoding):
-            encoding = encoding.value
+        if encoding[0] is '@':
+            encoding = gdb.parameter(encoding[1:])
         return self.val['_M_dataplus']['_M_p'].string(encoding)
     def display_hint (self):
@@ -599,8 +581,8 @@ def build_libstdcxx_dictionary ():
     # libstdc++ objects requiring pretty-printing.
     # In order from:
-    pretty_printers_dict[re.compile('^std::basic_string<char,.*>$')] = lambda val: StdStringPrinter(None, val)
-    pretty_printers_dict[re.compile('^std::basic_string<wchar_t,.*>$')] = lambda val: StdStringPrinter(target_wide_charset, val)
+    pretty_printers_dict[re.compile('^std::basic_string<char,.*>$')] = lambda val: StdStringPrinter('@target-charset', val)
+    pretty_printers_dict[re.compile('^std::basic_string<wchar_t,.*>$')] = lambda val: StdStringPrinter('@target-wide-charset', val)
     pretty_printers_dict[re.compile('^std::basic_string<char16_t,.*>$')] = lambda val: StdStringPrinter('UTF-16', val)
     pretty_printers_dict[re.compile('^std::basic_string<char32_t,.*>$')] = lambda val: StdStringPrinter('UTF-32', val)
     pretty_printers_dict[re.compile('^std::bitset<.*>$')] = StdBitsetPrinter

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