Hi ... well I tried to patch adonthell with bugfixes from abf but there are a few problems.
1) The set_data / get_data of surface_sdlgl are pure virtual. 2) Even with that the xml format failed unit tests i added. 3) It's getting late :) I attached a patch for the src/base/diskwriter_xml.cc which _should_ work as intended. Also the patch for test/diskiotest.cc which failed. Ah. Also libabf 0.1.1 released. Phew. I guess you're not using the xml format often, never mind the patchfest, if you don't need it. -phoku
diff --git a/src/base/diskwriter_xml.cc b/src/base/diskwriter_xml.cc index 0fb0ef9..17a778d 100644 --- a/src/base/diskwriter_xml.cc +++ b/src/base/diskwriter_xml.cc @@ -248,6 +248,16 @@ static void param_to_value (const data_sax_context *context) } /** + * Called when an xml entity such as & is encountered. + * @param ctx the parser context + * @param name The entity name + */ +static xmlEntityPtr data_get_entity(void *ctx, const xmlChar *name) +{ + return xmlGetPredefinedEntity(name); +} + +/** * Called when an opening tag has been processed. * @param ctx the parser context * @param name The element name @@ -420,7 +430,7 @@ static void data_read_characters (void *ctx, const xmlChar *content, int len) { // store value first and assign when closing element, as // 'data_read_characters' is not called for empty elements. - context->Value = std::string ((char*) content, len); + context->Value += std::string ((char*) content, len); } } @@ -449,7 +459,7 @@ xmlSAXHandler data_sax_handler = { NULL, /* hasInternalSubset */ NULL, /* hasExternalSubset */ NULL, /* resolveEntity */ - NULL, /* getEntity */ + data_get_entity, NULL, /* entityDecl */ NULL, /* notationDecl */ NULL, /* attributeDecl */
diff --git a/test/diskiotest.cc b/test/diskiotest.cc index 98d578e..e368a64 100644 --- a/test/diskiotest.cc +++ b/test/diskiotest.cc @@ -10,6 +10,7 @@ double d_PI = 3.14159265358979323846; int main (int argc, char* argv[]) { base::diskio test (base::diskio::GZ_FILE); + base::diskio test_xml (base::diskio::XML_FILE); base::flat fl; char *block = new char[256]; @@ -33,7 +34,7 @@ int main (int argc, char* argv[]) { test.put_block ("block", block, 256); // a flat can contain other flats too - fl.put_string ("string", "Another flat"); + fl.put_string ("string", "Another flat so on."); fl.put_flat ("test", test); test.put_flat ("flat", fl); @@ -45,15 +46,34 @@ int main (int argc, char* argv[]) { // write record to disk cout << "Writing data to disk ..." << endl; test.put_record ("diskio.test"); - + // FIXME:This segfaults at the end + // test_xml = test; + test_xml.copy(test); + if (test.checksum () != test_xml.checksum ()) + cout << "Checksum mismatch!" << endl; + + cout << "Writing data to disk (xml) ..." << endl; + test_xml.put_record ("diskiotest.xml"); + if (test.checksum () != test_xml.checksum ()) + cout << "Checksum mismatch!" << endl; // read record from disk cout << "Reading data from disk" << endl; bool b = test.get_record ("diskio.test"); if (b == true) cout << "Reading successful" << endl; + cout << "Reading data from disk (xml)" << endl; + b = test_xml.get_record ("diskiotest.xml"); + if (b == true) cout << "Reading successful" << endl; + // print checksum of data read cout << "Checksum: " << (std::hex) << test.checksum () << (std::dec) << endl; - + + // cheat and just compare checksum for xml. + cout << "XML Checksum : "<< (std::hex) << test_xml.checksum () << (std::dec); + if (test.checksum () != test_xml.checksum ()) + cout << " mismatch!"; + cout << endl; + // unpack all kind of data using get_* // this may happen in any order, although using the original // order is much more efficient.
_______________________________________________ Adonthell-devel mailing list Adonthell-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/adonthell-devel