|
From: <sv...@va...> - 2008-06-30 08:42:51
|
Author: bart
Date: 2008-06-30 09:42:58 +0100 (Mon, 30 Jun 2008)
New Revision: 8311
Log:
Added function VG_(ToXML)().
Modified:
branches/FORMATCHECK/coregrind/m_debuglog.c
Modified: branches/FORMATCHECK/coregrind/m_debuglog.c
===================================================================
--- branches/FORMATCHECK/coregrind/m_debuglog.c 2008-06-30 08:41:59 UTC (rev 8310)
+++ branches/FORMATCHECK/coregrind/m_debuglog.c 2008-06-30 08:42:58 UTC (rev 8311)
@@ -49,6 +49,8 @@
#include "pub_core_basics.h" /* basic types */
#include "pub_core_vkiscnums.h" /* for syscall numbers */
#include "pub_core_debuglog.h" /* our own iface */
+#include "pub_core_libcassert.h" /* vg_assert() */
+#include "pub_tool_libcprint.h" /* VG_(ToXML)() */
#include "valgrind.h" /* for RUNNING_ON_VALGRIND */
/*------------------------------------------------------------*/
@@ -501,7 +503,7 @@
static
UInt myvprintf_str_XML_simplistic ( void(*send)(HChar,void*),
void* send_arg2,
- HChar* str )
+ const HChar* str )
{
UInt ret = 0;
Int i;
@@ -879,8 +881,29 @@
va_end(vargs);
}
+static HChar xml_result_buf[256];
+static int xml_result_buf_pos;
+static void append_to_xml_result_buf(const HChar ch, void* arg2)
+{
+ if (xml_result_buf_pos
+ <= sizeof(xml_result_buf) / sizeof(xml_result_buf[0]) - 2)
+ {
+ xml_result_buf[xml_result_buf_pos++] = ch;
+ }
+}
+/* Convert a string such that it can be inserted into an XML output stream. */
+extern HChar* VG_(ToXML)(const HChar* str)
+{
+ if (str == NULL)
+ str = "(null)";
+ xml_result_buf_pos = 0;
+ myvprintf_str_XML_simplistic(append_to_xml_result_buf, NULL, str);
+ xml_result_buf[xml_result_buf_pos] = 0;
+ return xml_result_buf;
+}
+
/*--------------------------------------------------------------------*/
/*--- end m_debuglog.c ---*/
/*--------------------------------------------------------------------*/
|