From: Darren S. <li...@yo...> - 2010-03-13 23:10:07
|
# HG changeset patch # User Darren Salt <li...@yo...> # Date 1268521791 0 # Node ID d70688fa8c4adcddc607f66c0d40cd5c04261691 # Parent 8eb6bdb4afa0e82e0ea5c8123ec732fcc79e9c2e Use re-entrant versions of xine-lib's XML parser functions (if available). diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 0.5.906: 2010/??/?? * Reset pointer shape on stream stop/eject. + * Use re-entrant versions of xine-lib's XML parser functions + (if available). 0.5.905: 2010/01/01 * Fix a build problem affecting LIRC in the absence of a pkgconfig diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -411,6 +411,8 @@ AC_MSG_WARN([logo format "$logo_sub" cannot be displayed - demuxer not present]) fi +XINE_LIB_SHIMS + dnl --------------------------------------------- dnl Check for lirc dnl --------------------------------------------- diff --git a/m4/_gxine.m4 b/m4/_gxine.m4 --- a/m4/_gxine.m4 +++ b/m4/_gxine.m4 @@ -132,3 +132,20 @@ AC_MSG_RESULT([no]) fi ]) + +dnl Shims for various functions which are present in newer xine-lib +AC_DEFUN([XINE_LIB_SHIMS], + [AC_MSG_CHECKING([for re-entrant XML parser in xine-lib]) + tmp_CFLAGS="$CFLAGS" + tmp_LIBS="$LIBS" + CFLAGS="$CFLAGS $XINE_CFLAGS" + LIBS="$LIBS $XINE_LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include <xine/xmlparser.h>]], + [[xml_parser_init_r ((void *)0, 0, XML_PARSER_CASE_INSENSITIVE);]])], + [AC_DEFINE([[HAVE_XML_PARSER_REENTRANT]], [[1]], [[Define if xml_parser_init_r etc. are available]]) + AC_MSG_RESULT([[yes]])], + [AC_MSG_RESULT([[no]])]) + CFLAGS="$tmp_CFLAGS" + LIBS="$tmp_LIBS" + ]) \ No newline at end of file diff --git a/src/globals.h b/src/globals.h --- a/src/globals.h +++ b/src/globals.h @@ -116,4 +116,14 @@ extern void gxine_threads_leave (const char *, int); #endif +#ifdef HAVE_XML_PARSER_REENTRANT +# define xml_parser_init_R(X,D,L,M) X = xml_parser_init_r ((D), (L), (M)) +# define xml_parser_build_tree_R(X,T) xml_parser_build_tree_r ((X), (T)) +# define xml_parser_finalize_R(X) xml_parser_finalize_r ((X)) +#else +# define xml_parser_init_R(X,D,L,M) xml_parser_init ((D), (L), (M)) +# define xml_parser_build_tree_R(X,T) xml_parser_build_tree ((T)) +# define xml_parser_finalize_R(X) do {} while (0) #endif + +#endif diff --git a/src/key_events.c b/src/key_events.c --- a/src/key_events.c +++ b/src/key_events.c @@ -690,9 +690,9 @@ if (kbfile) { xml_node_t *root = NULL; - xml_parser_init (kbfile, strlen (kbfile), XML_PARSER_CASE_INSENSITIVE); + xml_parser_init_R (xml_parser_t *xml, kbfile, strlen (kbfile), XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree (&root) >= 0) + if (xml_parser_build_tree_R (xml, &root) >= 0) { if (!strcasecmp (root->name, "gxinekb")) { @@ -740,6 +740,7 @@ load_default_kb(); } + xml_parser_finalize_R (xml); free (kbfile); } else diff --git a/src/mediamarks.c b/src/mediamarks.c --- a/src/mediamarks.c +++ b/src/mediamarks.c @@ -509,16 +509,17 @@ { xml_node_t *node; - xml_parser_init (mmfile, strlen (mmfile), XML_PARSER_CASE_INSENSITIVE); + xml_parser_init_R (xml_parser_t *xml, mmfile, strlen (mmfile), XML_PARSER_CASE_INSENSITIVE); g_signal_handlers_block_by_func (G_OBJECT(mm_store), tree_changed_cb, NULL); - if (xml_parser_build_tree (&node) < 0) + if (xml_parser_build_tree_R (xml, &node) < 0) load_old_file (fname); else { load_new_file (node); xml_parser_free_tree (node); } + xml_parser_finalize_R (xml); update_menu (); g_signal_handlers_unblock_by_func (G_OBJECT(mm_store), tree_changed_cb, NULL); diff --git a/src/playlist.c b/src/playlist.c --- a/src/playlist.c +++ b/src/playlist.c @@ -432,9 +432,9 @@ goto ret0; } - xml_parser_init (plfile, st.st_size, XML_PARSER_CASE_INSENSITIVE); + xml_parser_init_R (xml_parser_t *xml, plfile, st.st_size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree (&root) < 0) + if (xml_parser_build_tree_R (xml, &root) < 0) { display_error (FROM_GXINE, _("Loading of playlist file failed."), _("‘%s’ is not a valid XML/ASX file"), fname); @@ -528,6 +528,7 @@ ret0: free (plfile); xml_parser_free_tree (root); + xml_parser_finalize_R (xml); if (defaultfile) free ((char *)fname); return ret; @@ -823,6 +824,9 @@ xml_node_t *xml_tree; pl_xml_info_t *xml_info = NULL; void *data = NULL; +#ifdef HAVE_XML_PARSER_REENTRANT + xml_parser_t *xml = NULL; +#endif if (ins_pos == -2) { @@ -837,15 +841,17 @@ if (loader->is_xml) { - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree (&xml_tree)) + xml_parser_init_R (xml, contents, size, XML_PARSER_CASE_INSENSITIVE); + if (xml_parser_build_tree_R (xml, &xml_tree)) { + xml_parser_finalize_R (xml); g_free (contents); return -1; } if (loader->xml.root && strcmp (xml_tree->name, loader->xml.root)) { g_printerr (_("playlist: no %s tag\n"), loader->xml.root); + xml_parser_finalize_R (xml); g_free (contents); return -1; } @@ -904,6 +910,7 @@ if (loader->is_xml) { xml_parser_free_tree (xml_tree); + xml_parser_finalize_R (xml); free (xml_info); } else @@ -1177,8 +1184,8 @@ if (! (contents = read_entire_file (mrl, &size))) return ret; - xml_parser_init (contents, size, XML_PARSER_CASE_INSENSITIVE); - res = xml_parser_build_tree (&xml_tree); + xml_parser_init_R (xml_parser_t *xml, contents, size, XML_PARSER_CASE_INSENSITIVE); + res = xml_parser_build_tree_R (xml, &xml_tree); if (res) { @@ -1200,6 +1207,7 @@ ret = playlist_add_mrl (strstr(lines[i], "mms://"), ins_pos); } } + xml_parser_finalize_R (xml); return ret; } @@ -1343,6 +1351,7 @@ g_printerr(_("playlist: no ASX tag\n")); xml_parser_free_tree (xml_tree); + xml_parser_finalize_R (xml); g_free (contents); return ret; diff --git a/src/xml_widgets.c b/src/xml_widgets.c --- a/src/xml_widgets.c +++ b/src/xml_widgets.c @@ -1348,10 +1348,11 @@ return NULL; } - xml_parser_init (xml_data, strlen (xml_data), XML_PARSER_CASE_INSENSITIVE); - if (xml_parser_build_tree (&tree) < 0) + xml_parser_init_R (xml_parser_t *xml, xml_data, strlen (xml_data), XML_PARSER_CASE_INSENSITIVE); + if (xml_parser_build_tree_R (xml, &tree) < 0) { xml_error (_("xml_widgets: error in %s: XML parser failed\n"), file); + xml_parser_finalize_R (xml); free (xml_data); return NULL; } @@ -1405,6 +1406,7 @@ widget = widget_parse (node); xml_parser_free_tree (tree); + xml_parser_finalize_R (xml); #ifndef MAKE_TRANSLATION_SOURCE foreach_glist (mnemonic, mnemonic_list) |