[nemiver] Support multibytes string parsing (Closes: #62730)
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver] Support multibytes string parsing (Closes: #62730)
- Date: Sat, 21 Aug 2010 11:09:08 +0000 (UTC)
commit cce416bf15de37e0162ea65a5f623376ef3bdc3d
Author: Dodji Seketeli <dodji gnome org>
Date: Sat Aug 21 12:53:07 2010 +0200
Support multibytes string parsing (Closes: #62730)
* src/dbgengine/nmv-gdbmi-parser.cc
(GDBMIParser::parse_c_string_body): When parsing strings, don't
expect one byte == one character. Rather, eat up bytes that aren't
characters.
* tests/test-gdbmi.cc (test_str3): New test.
(init_unit_test_suite): Add the new test_str3 test to the suite.
src/dbgengine/nmv-gdbmi-parser.cc | 10 +++++++---
tests/test-gdbmi.cc | 19 ++++++++++++++++++-
2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdbmi-parser.cc b/src/dbgengine/nmv-gdbmi-parser.cc
index b65181d..377663f 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -695,7 +695,7 @@ GDBMIParser::parse_c_string_body (UString::size_type a_from,
return false;
}
- UString result;
+ std::string result;
if (ch != '\\') {
result += ch;
++cur;
@@ -740,8 +740,12 @@ GDBMIParser::parse_c_string_body (UString::size_type a_from,
}
CHECK_END2 (cur);
continue;
- }
- break;
+ } else {
+ result += ch;
+ ++cur;
+ if (m_priv->index_passed_end (cur))
+ break;
+ }
}
if (ch != '"') {
diff --git a/tests/test-gdbmi.cc b/tests/test-gdbmi.cc
index bf0e65b..c757f88 100644
--- a/tests/test-gdbmi.cc
+++ b/tests/test-gdbmi.cc
@@ -13,7 +13,7 @@ using namespace nemiver;
static const char* gv_str0 = "\"abracadabra\"";
static const char* gv_str1 = "\"/home/dodji/misc/no\\303\\253l-\\303\\251-\\303\\240/test.c\"";
static const char* gv_str2 = "\"No symbol \\\"events_ecal\\\" in current context.\\n\"";
-
+static const char* gv_str3 = "\"Reading symbols from /home/dodji/devel/tests/éçà /test...\"";
static const char* gv_attrs0 = "msg=\"No symbol \\\"g_return_if_fail\\\" in current context.\"";
static const char* gv_attrs1 = "script=[\"silent\",\"return\"]";
@@ -227,6 +227,22 @@ test_str2 ()
}
void
+test_str3 ()
+{
+ bool is_ok =false;
+
+ UString res;
+ UString::size_type to=0;
+
+ GDBMIParser parser (gv_str3);
+ is_ok = parser.parse_c_string (0, to, res);
+
+ BOOST_REQUIRE (is_ok);
+ MESSAGE ("got string: '" << Glib::locale_from_utf8 (res) << "'");
+ BOOST_REQUIRE_MESSAGE (res.size (), "res size was: " << res.size ());
+}
+
+void
test_attr0 ()
{
bool is_ok =false;
@@ -945,6 +961,7 @@ init_unit_test_suite (int argc, char **argv)
suite->add (BOOST_TEST_CASE (&test_str0));
suite->add (BOOST_TEST_CASE (&test_str1));
suite->add (BOOST_TEST_CASE (&test_str2));
+ suite->add (BOOST_TEST_CASE (&test_str3));
suite->add (BOOST_TEST_CASE (&test_attr0));
suite->add (BOOST_TEST_CASE (&test_stoppped_async_output));
suite->add (BOOST_TEST_CASE (&test_running_async_output));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]