This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[commit] Avoid using XML_StopParser if not available


XML_StopParser is basically an optimization.  We have to check for
errors ourselves, because expat does not guarantee that it will
immediately stop calling handlers; for instance, I believe it will call
the end element handlers for anything already opened.  So, we can
call it if it's available but consider a missing copy harmless.

I've checked this in.  Richard, could you let me know if it is not
enough for your version of expat?  I can't readily downgrade to be
sure.

-- 
Daniel Jacobowitz
CodeSourcery

2007-01-09  Daniel Jacobowitz  <dan@codesourcery.com>

	* configure.ac: Check for XML_StopParser.
	* xml-support.c (gdb_xml_body_text): Check for an error.
	(gdb_xml_start_element_wrapper): Conditionalize call to XML_StopParser.
	(gdb_xml_end_element_wrapper): Likewise.
	* config.in, configure: Regenerated.

---
 gdb/config.in     |    3 +
 gdb/configure     |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/configure.ac  |    5 ++
 gdb/xml-support.c |    7 +++
 4 files changed, 121 insertions(+)

Index: src/gdb/configure.ac
===================================================================
--- src.orig/gdb/configure.ac	2007-01-09 09:33:27.000000000 -0500
+++ src/gdb/configure.ac	2007-01-09 09:36:32.000000000 -0500
@@ -325,6 +325,11 @@ AC_LIB_HAVE_LINKFLAGS([expat], [], [#inc
 		      [XML_Parser p = XML_ParserCreate (0);])
 if test "$HAVE_LIBEXPAT" != yes; then
   AC_MSG_WARN([expat is missing or unusable; some features may be disabled.])
+else
+  save_LIBS=$LIBS
+  LIBS="$LIBS $LIBEXPAT"
+  AC_CHECK_FUNCS(XML_StopParser)
+  LIBS=$save_LIBS
 fi
 
 # ------------------------- #
Index: src/gdb/xml-support.c
===================================================================
--- src.orig/gdb/xml-support.c	2007-01-09 09:29:59.000000000 -0500
+++ src/gdb/xml-support.c	2007-01-09 09:33:15.000000000 -0500
@@ -81,6 +81,9 @@ gdb_xml_body_text (void *data, const XML
   struct gdb_xml_parser *parser = data;
   struct scope_level *scope = VEC_last (scope_level_s, parser->scopes);
 
+  if (parser->error.reason < 0)
+    return;
+
   if (scope->body == NULL)
     {
       scope->body = XZALLOC (struct obstack);
@@ -286,7 +289,9 @@ gdb_xml_start_element_wrapper (void *dat
   if (ex.reason < 0)
     {
       parser->error = ex;
+#ifdef HAVE_XML_STOPPARSER
       XML_StopParser (parser->expat_parser, XML_FALSE);
+#endif
     }
 }
 
@@ -362,7 +367,9 @@ gdb_xml_end_element_wrapper (void *data,
   if (ex.reason < 0)
     {
       parser->error = ex;
+#ifdef HAVE_XML_STOPPARSER
       XML_StopParser (parser->expat_parser, XML_FALSE);
+#endif
     }
 }
 


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