1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-20 18:50:08 +03:00

Add configuration flag for XPointer locations support

Add a new configuration flag that controls whether the outdated support
for XPointer locations (ranges and points) is enabled.

    --with-xptr-locs          # Autotools
    LIBXML2_WITH_XPTR_LOCS    # CMake

The latest spec for what it essentially an XPath extension seems to be
this working draft from 2002:

    https://www.w3.org/TR/xptr-xpointer/

The xpointer() scheme is listed as "being reviewed" in the XPointer
registry since at least 2006. libxml2 seems to be the only modern
software that tries to implement this spec, but the code has many bugs
and quality issues.

The flag defaults to "off" and support for this extensions has to be
requested explicitly. The relevant API functions are deprecated.
This commit is contained in:
Nick Wellnhofer 2022-04-20 23:17:14 +02:00
parent 9a0be0dc4d
commit 670701075b
17 changed files with 212 additions and 256 deletions

View File

@ -19,33 +19,31 @@
script: script:
- | - |
ln -s /tests/xmlconf ln -s /tests/xmlconf
sh autogen.sh $CONFIG sh autogen.sh --with-ftp --with-legacy --with-xptr-locs $CONFIG
make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror" make -j$(nproc) V=1 CFLAGS="$CFLAGS -Werror"
make CFLAGS="$CFLAGS -Werror" check make CFLAGS="$CFLAGS -Werror" check
gcc: gcc:
extends: .test extends: .test
variables: variables:
CONFIG: '--with-ftp --with-legacy'
CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=700" CFLAGS: "-O2 -std=c89 -D_XOPEN_SOURCE=700"
gcc:python3: gcc:python3:
extends: .test extends: .test
variables: variables:
CONFIG: '--with-ftp --with-legacy'
CFLAGS: "-O2" CFLAGS: "-O2"
PYTHON: "/usr/bin/python3" PYTHON: "/usr/bin/python3"
gcc:static: gcc:static:
extends: .test extends: .test
variables: variables:
CONFIG: "--disable-shared --with-ftp --with-legacy --without-python" CONFIG: "--disable-shared --without-python"
CFLAGS: "-O2" CFLAGS: "-O2"
clang:asan: clang:asan:
extends: .test extends: .test
variables: variables:
CONFIG: "--with-ftp --with-legacy --without-python" CONFIG: "--without-python"
CC: clang CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all -Wno-error=cast-align" CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=address,undefined,integer -fno-sanitize-recover=all -Wno-error=cast-align"
# LeakSanitizer requires SYS_CAP_PTRACE # LeakSanitizer requires SYS_CAP_PTRACE
@ -57,7 +55,7 @@ clang:msan:
only: only:
- schedules - schedules
variables: variables:
CONFIG: "--with-ftp --with-legacy --without-python --without-zlib --without-lzma" CONFIG: "--without-python --without-zlib --without-lzma"
CC: clang CC: clang
CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align" CFLAGS: "-O2 -g -fno-omit-frame-pointer -fsanitize=memory -Wno-error=cast-align"

View File

@ -59,6 +59,7 @@ option(LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON)
option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON) option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON)
option(LIBXML2_WITH_XPATH "Add the XPATH support" ON) option(LIBXML2_WITH_XPATH "Add the XPATH support" ON)
option(LIBXML2_WITH_XPTR "Add the XPointer support" ON) option(LIBXML2_WITH_XPTR "Add the XPointer support" ON)
option(LIBXML2_WITH_XPTR_LOCS "Add support for XPointer locations" OFF)
option(LIBXML2_WITH_ZLIB "Use libz" ON) option(LIBXML2_WITH_ZLIB "Use libz" ON)
set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite") set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
@ -96,7 +97,7 @@ if(LIBXML2_WITH_ZLIB)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
endif() endif()
foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB) foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_XPTR_LOCS WITH_ZLIB)
if(LIBXML2_${VARIABLE}) if(LIBXML2_${VARIABLE})
set(${VARIABLE} 1) set(${VARIABLE} 1)
else() else()

View File

@ -160,6 +160,8 @@ AC_ARG_WITH(xpath,
[ --with-xpath add the XPATH support (on)]) [ --with-xpath add the XPATH support (on)])
AC_ARG_WITH(xptr, AC_ARG_WITH(xptr,
[ --with-xptr add the XPointer support (on)]) [ --with-xptr add the XPointer support (on)])
AC_ARG_WITH(xptr-locs,
[ --with-xptr-locs add support for XPointer locations (off)])
AC_ARG_WITH(modules, AC_ARG_WITH(modules,
[ --with-modules add the dynamic modules support (on)]) [ --with-modules add the dynamic modules support (on)])
AC_ARG_WITH(zlib, AC_ARG_WITH(zlib,
@ -199,6 +201,10 @@ if test "$with_reader" = "yes"
then then
with_push=yes with_push=yes
fi fi
if test "$with_xptr_locs" = "yes"
then
with_xptr=yes
fi
if test "$with_xptr" = "yes" if test "$with_xptr" = "yes"
then then
with_xpath=yes with_xpath=yes
@ -1071,6 +1077,7 @@ AC_SUBST(TEST_CATALOG)
if test "$with_xptr" = "no" ; then if test "$with_xptr" = "no" ; then
echo Disabling XPointer support echo Disabling XPointer support
WITH_XPTR=0 WITH_XPTR=0
WITH_XPTR_LOCS=0
XPTR_OBJ= XPTR_OBJ=
else else
WITH_XPTR=1 WITH_XPTR=1
@ -1079,8 +1086,14 @@ else
echo XPointer requires XPath support - enabling it echo XPointer requires XPath support - enabling it
with_xpath=yes with_xpath=yes
fi fi
if test "$with_xptr_locs" = "yes" ; then
WITH_XPTR_LOCS=1
else
WITH_XPTR_LOCS=0
fi
fi fi
AC_SUBST(WITH_XPTR) AC_SUBST(WITH_XPTR)
AC_SUBST(WITH_XPTR_LOCS)
AC_SUBST(XPTR_OBJ) AC_SUBST(XPTR_OBJ)
if test "$with_c14n" = "no" ; then if test "$with_c14n" = "no" ; then

View File

@ -1840,6 +1840,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -1852,6 +1853,7 @@ xmlShellPrintXPathError(int errorType, const char *arg)
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);
@ -2998,6 +3000,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -3010,6 +3013,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);
@ -3115,6 +3119,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -3127,6 +3132,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);
@ -3192,6 +3198,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -3204,6 +3211,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);
@ -3277,6 +3285,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -3289,6 +3298,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);
@ -3355,6 +3365,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a string\n", arg); "%s is a string\n", arg);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a point\n", arg); "%s is a point\n", arg);
@ -3367,6 +3378,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is a range\n", arg); "%s is a range\n", arg);
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"%s is user-defined\n", arg); "%s is user-defined\n", arg);

View File

@ -4461,6 +4461,12 @@
<macro name='XML_XPATH_NOVAR' file='xpath'> <macro name='XML_XPATH_NOVAR' file='xpath'>
<info>forbid variables in expression</info> <info>forbid variables in expression</info>
</macro> </macro>
<macro name='XPATH_LOCATIONSET' file='xpath'>
</macro>
<macro name='XPATH_POINT' file='xpath'>
</macro>
<macro name='XPATH_RANGE' file='xpath'>
</macro>
<macro name='XP_ERROR' file='xpathInternals'> <macro name='XP_ERROR' file='xpathInternals'>
<info>Macro to raise an XPath error and return.</info> <info>Macro to raise an XPath error and return.</info>
<arg name='X' info='the error code'/> <arg name='X' info='the error code'/>
@ -18255,7 +18261,7 @@ Could we use @subtypes for this?'/>
<arg name='no' type='int' info='the error number'/> <arg name='no' type='int' info='the error number'/>
</function> </function>
<function name='xmlXPtrBuildNodeList' file='xpointer' module='xpointer'> <function name='xmlXPtrBuildNodeList' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Build a node list tree copy of the XPointer result. This will drop Attributes and Namespace declarations.</info> <info>Build a node list tree copy of the XPointer result. This will drop Attributes and Namespace declarations.</info>
<return type='xmlNodePtr' info='an xmlNodePtr list or NULL. the caller has to free the node tree.'/> <return type='xmlNodePtr' info='an xmlNodePtr list or NULL. the caller has to free the node tree.'/>
<arg name='obj' type='xmlXPathObjectPtr' info='the XPointer result from the evaluation.'/> <arg name='obj' type='xmlXPathObjectPtr' info='the XPointer result from the evaluation.'/>
@ -18268,53 +18274,53 @@ Could we use @subtypes for this?'/>
<arg name='ctx' type='xmlXPathContextPtr' info='the XPointer context'/> <arg name='ctx' type='xmlXPathContextPtr' info='the XPointer context'/>
</function> </function>
<function name='xmlXPtrEvalRangePredicate' file='xpointer' module='xpointer'> <function name='xmlXPtrEvalRangePredicate' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>[8] Predicate ::= &apos;[&apos; PredicateExpr &apos;]&apos; [9] PredicateExpr ::= Expr Evaluate a predicate as in xmlXPathEvalPredicate() but for a Location Set instead of a node set</info> <info>[8] Predicate ::= &apos;[&apos; PredicateExpr &apos;]&apos; [9] PredicateExpr ::= Expr Evaluate a predicate as in xmlXPathEvalPredicate() but for a Location Set instead of a node set</info>
<return type='void'/> <return type='void'/>
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/> <arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/>
</function> </function>
<function name='xmlXPtrFreeLocationSet' file='xpointer' module='xpointer'> <function name='xmlXPtrFreeLocationSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Free the LocationSet compound (not the actual ranges !).</info> <info>Free the LocationSet compound (not the actual ranges !).</info>
<return type='void'/> <return type='void'/>
<arg name='obj' type='xmlLocationSetPtr' info='the xmlLocationSetPtr to free'/> <arg name='obj' type='xmlLocationSetPtr' info='the xmlLocationSetPtr to free'/>
</function> </function>
<function name='xmlXPtrLocationSetAdd' file='xpointer' module='xpointer'> <function name='xmlXPtrLocationSetAdd' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>add a new xmlXPathObjectPtr to an existing LocationSet If the location already exist in the set @val is freed.</info> <info>add a new xmlXPathObjectPtr to an existing LocationSet If the location already exist in the set @val is freed.</info>
<return type='void'/> <return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/> <arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='xmlXPathObjectPtr' info='a new xmlXPathObjectPtr'/> <arg name='val' type='xmlXPathObjectPtr' info='a new xmlXPathObjectPtr'/>
</function> </function>
<function name='xmlXPtrLocationSetCreate' file='xpointer' module='xpointer'> <function name='xmlXPtrLocationSetCreate' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlLocationSetPtr of type double and of value @val</info> <info>Create a new xmlLocationSetPtr of type double and of value @val</info>
<return type='xmlLocationSetPtr' info='the newly created object.'/> <return type='xmlLocationSetPtr' info='the newly created object.'/>
<arg name='val' type='xmlXPathObjectPtr' info='an initial xmlXPathObjectPtr, or NULL'/> <arg name='val' type='xmlXPathObjectPtr' info='an initial xmlXPathObjectPtr, or NULL'/>
</function> </function>
<function name='xmlXPtrLocationSetDel' file='xpointer' module='xpointer'> <function name='xmlXPtrLocationSetDel' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Removes an xmlXPathObjectPtr from an existing LocationSet</info> <info>Removes an xmlXPathObjectPtr from an existing LocationSet</info>
<return type='void'/> <return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/> <arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='xmlXPathObjectPtr' info='an xmlXPathObjectPtr'/> <arg name='val' type='xmlXPathObjectPtr' info='an xmlXPathObjectPtr'/>
</function> </function>
<function name='xmlXPtrLocationSetMerge' file='xpointer' module='xpointer'> <function name='xmlXPtrLocationSetMerge' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Merges two rangesets, all ranges from @val2 are added to @val1</info> <info>Merges two rangesets, all ranges from @val2 are added to @val1</info>
<return type='xmlLocationSetPtr' info='val1 once extended or NULL in case of error.'/> <return type='xmlLocationSetPtr' info='val1 once extended or NULL in case of error.'/>
<arg name='val1' type='xmlLocationSetPtr' info='the first LocationSet'/> <arg name='val1' type='xmlLocationSetPtr' info='the first LocationSet'/>
<arg name='val2' type='xmlLocationSetPtr' info='the second LocationSet'/> <arg name='val2' type='xmlLocationSetPtr' info='the second LocationSet'/>
</function> </function>
<function name='xmlXPtrLocationSetRemove' file='xpointer' module='xpointer'> <function name='xmlXPtrLocationSetRemove' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Removes an entry from an existing LocationSet list.</info> <info>Removes an entry from an existing LocationSet list.</info>
<return type='void'/> <return type='void'/>
<arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/> <arg name='cur' type='xmlLocationSetPtr' info='the initial range set'/>
<arg name='val' type='int' info='the index to remove'/> <arg name='val' type='int' info='the index to remove'/>
</function> </function>
<function name='xmlXPtrNewCollapsedRange' file='xpointer' module='xpointer'> <function name='xmlXPtrNewCollapsedRange' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using a single nodes</info> <info>Create a new xmlXPathObjectPtr of type range using a single nodes</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting and ending node'/> <arg name='start' type='xmlNodePtr' info='the starting and ending node'/>
@ -18328,20 +18334,20 @@ Could we use @subtypes for this?'/>
<arg name='origin' type='xmlNodePtr' info='the element from which a user or program initiated traversal of the link, or NULL.'/> <arg name='origin' type='xmlNodePtr' info='the element from which a user or program initiated traversal of the link, or NULL.'/>
</function> </function>
<function name='xmlXPtrNewLocationSetNodeSet' file='xpointer' module='xpointer'> <function name='xmlXPtrNewLocationSetNodeSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with all the nodes from @set</info> <info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with all the nodes from @set</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='set' type='xmlNodeSetPtr' info='a node set'/> <arg name='set' type='xmlNodeSetPtr' info='a node set'/>
</function> </function>
<function name='xmlXPtrNewLocationSetNodes' file='xpointer' module='xpointer'> <function name='xmlXPtrNewLocationSetNodes' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with the single range made of the two nodes @start and @end</info> <info>Create a new xmlXPathObjectPtr of type LocationSet and initialize it with the single range made of the two nodes @start and @end</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the start NodePtr value'/> <arg name='start' type='xmlNodePtr' info='the start NodePtr value'/>
<arg name='end' type='xmlNodePtr' info='the end NodePtr value or NULL'/> <arg name='end' type='xmlNodePtr' info='the end NodePtr value or NULL'/>
</function> </function>
<function name='xmlXPtrNewRange' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRange' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range</info> <info>Create a new xmlXPathObjectPtr of type range</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/> <arg name='start' type='xmlNodePtr' info='the starting node'/>
@ -18350,49 +18356,49 @@ Could we use @subtypes for this?'/>
<arg name='endindex' type='int' info='the ending index'/> <arg name='endindex' type='int' info='the ending index'/>
</function> </function>
<function name='xmlXPtrNewRangeNodeObject' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRangeNodeObject' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a not to an object</info> <info>Create a new xmlXPathObjectPtr of type range from a not to an object</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/> <arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending object'/> <arg name='end' type='xmlXPathObjectPtr' info='the ending object'/>
</function> </function>
<function name='xmlXPtrNewRangeNodePoint' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRangeNodePoint' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a node to a point</info> <info>Create a new xmlXPathObjectPtr of type range from a node to a point</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/> <arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending point'/> <arg name='end' type='xmlXPathObjectPtr' info='the ending point'/>
</function> </function>
<function name='xmlXPtrNewRangeNodes' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRangeNodes' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using 2 nodes</info> <info>Create a new xmlXPathObjectPtr of type range using 2 nodes</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlNodePtr' info='the starting node'/> <arg name='start' type='xmlNodePtr' info='the starting node'/>
<arg name='end' type='xmlNodePtr' info='the ending node'/> <arg name='end' type='xmlNodePtr' info='the ending node'/>
</function> </function>
<function name='xmlXPtrNewRangePointNode' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRangePointNode' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range from a point to a node</info> <info>Create a new xmlXPathObjectPtr of type range from a point to a node</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlXPathObjectPtr' info='the starting point'/> <arg name='start' type='xmlXPathObjectPtr' info='the starting point'/>
<arg name='end' type='xmlNodePtr' info='the ending node'/> <arg name='end' type='xmlNodePtr' info='the ending node'/>
</function> </function>
<function name='xmlXPtrNewRangePoints' file='xpointer' module='xpointer'> <function name='xmlXPtrNewRangePoints' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Create a new xmlXPathObjectPtr of type range using 2 Points</info> <info>Create a new xmlXPathObjectPtr of type range using 2 Points</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='start' type='xmlXPathObjectPtr' info='the starting point'/> <arg name='start' type='xmlXPathObjectPtr' info='the starting point'/>
<arg name='end' type='xmlXPathObjectPtr' info='the ending point'/> <arg name='end' type='xmlXPathObjectPtr' info='the ending point'/>
</function> </function>
<function name='xmlXPtrRangeToFunction' file='xpointer' module='xpointer'> <function name='xmlXPtrRangeToFunction' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Implement the range-to() XPointer function Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</info> <info>Implement the range-to() XPointer function Obsolete. range-to is not a real function but a special type of location step which is handled in xpath.c.</info>
<return type='void'/> <return type='void'/>
<arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/> <arg name='ctxt' type='xmlXPathParserContextPtr' info='the XPointer Parser context'/>
<arg name='nargs' type='int' info='the number of args'/> <arg name='nargs' type='int' info='the number of args'/>
</function> </function>
<function name='xmlXPtrWrapLocationSet' file='xpointer' module='xpointer'> <function name='xmlXPtrWrapLocationSet' file='xpointer' module='xpointer'>
<cond>defined(LIBXML_XPTR_ENABLED)</cond> <cond>defined(LIBXML_XPTR_ENABLED) &amp;&amp; defined(LIBXML_XPTR_LOCS_ENABLED)</cond>
<info>Wrap the LocationSet @val in a new xmlXPathObjectPtr</info> <info>Wrap the LocationSet @val in a new xmlXPathObjectPtr</info>
<return type='xmlXPathObjectPtr' info='the newly created object.'/> <return type='xmlXPathObjectPtr' info='the newly created object.'/>
<arg name='val' type='xmlLocationSetPtr' info='the LocationSet value'/> <arg name='val' type='xmlLocationSetPtr' info='the LocationSet value'/>

View File

@ -155,6 +155,13 @@ skipped_functions = [
# Legacy # Legacy
"xmlCleanupPredefinedEntities", "xmlInitializePredefinedEntities", "xmlCleanupPredefinedEntities", "xmlInitializePredefinedEntities",
"xmlSetFeature", "xmlGetFeature", "xmlGetFeaturesList", "xmlSetFeature", "xmlGetFeature", "xmlGetFeaturesList",
# location sets
"xmlXPtrLocationSetAdd",
"xmlXPtrLocationSetCreate",
"xmlXPtrLocationSetDel",
"xmlXPtrLocationSetMerge",
"xmlXPtrLocationSetRemove",
"xmlXPtrWrapLocationSet",
] ]
# #

View File

@ -247,6 +247,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#define LIBXML_XPTR_ENABLED #define LIBXML_XPTR_ENABLED
#endif #endif
/**
* LIBXML_XPTR_LOCS_ENABLED:
*
* Whether support for XPointer locations is configured in
*/
#if @WITH_XPTR_LOCS@
#define LIBXML_XPTR_LOCS_ENABLED
#endif
/** /**
* LIBXML_XINCLUDE_ENABLED: * LIBXML_XINCLUDE_ENABLED:
* *

View File

@ -104,13 +104,23 @@ typedef enum {
XPATH_BOOLEAN = 2, XPATH_BOOLEAN = 2,
XPATH_NUMBER = 3, XPATH_NUMBER = 3,
XPATH_STRING = 4, XPATH_STRING = 4,
#ifdef LIBXML_XPTR_LOCS_ENABLED
XPATH_POINT = 5, XPATH_POINT = 5,
XPATH_RANGE = 6, XPATH_RANGE = 6,
XPATH_LOCATIONSET = 7, XPATH_LOCATIONSET = 7,
#endif
XPATH_USERS = 8, XPATH_USERS = 8,
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
} xmlXPathObjectType; } xmlXPathObjectType;
#ifndef LIBXML_XPTR_LOCS_ENABLED
/** DOC_DISABLE */
#define XPATH_POINT 5
#define XPATH_RANGE 6
#define XPATH_LOCATIONSET 7
/** DOC_ENABLE */
#endif
typedef struct _xmlXPathObject xmlXPathObject; typedef struct _xmlXPathObject xmlXPathObject;
typedef xmlXPathObject *xmlXPathObjectPtr; typedef xmlXPathObject *xmlXPathObjectPtr;
struct _xmlXPathObject { struct _xmlXPathObject {

View File

@ -28,6 +28,7 @@
extern "C" { extern "C" {
#endif #endif
#ifdef LIBXML_XPTR_LOCS_ENABLED
/* /*
* A Location Set * A Location Set
*/ */
@ -43,51 +44,68 @@ struct _xmlLocationSet {
* Handling of location sets. * Handling of location sets.
*/ */
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetCreate (xmlXPathObjectPtr val); xmlXPtrLocationSetCreate (xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
XML_DEPRECATED
XMLPUBFUN xmlLocationSetPtr XMLCALL XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2); xmlLocationSetPtr val2);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRange (xmlNodePtr start, xmlXPtrNewRange (xmlNodePtr start,
int startindex, int startindex,
xmlNodePtr end, xmlNodePtr end,
int endindex); int endindex);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePoints (xmlXPathObjectPtr start, xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end); xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodePoint (xmlNodePtr start, xmlXPtrNewRangeNodePoint (xmlNodePtr start,
xmlXPathObjectPtr end); xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePointNode (xmlXPathObjectPtr start, xmlXPtrNewRangePointNode (xmlXPathObjectPtr start,
xmlNodePtr end); xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodes (xmlNodePtr start, xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end); xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodes (xmlNodePtr start, xmlXPtrNewLocationSetNodes (xmlNodePtr start,
xmlNodePtr end); xmlNodePtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set); xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodeObject (xmlNodePtr start, xmlXPtrNewRangeNodeObject (xmlNodePtr start,
xmlXPathObjectPtr end); xmlXPathObjectPtr end);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewCollapsedRange (xmlNodePtr start); xmlXPtrNewCollapsedRange (xmlNodePtr start);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val); xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrWrapLocationSet (xmlLocationSetPtr val); xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrLocationSetDel (xmlLocationSetPtr cur, xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val); xmlXPathObjectPtr val);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur, xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
int val); int val);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/* /*
* Functions. * Functions.
@ -99,13 +117,18 @@ XMLPUBFUN xmlXPathContextPtr XMLCALL
XMLPUBFUN xmlXPathObjectPtr XMLCALL XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrEval (const xmlChar *str, xmlXPtrEval (const xmlChar *str,
xmlXPathContextPtr ctx); xmlXPathContextPtr ctx);
#ifdef LIBXML_XPTR_LOCS_ENABLED
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt, xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
int nargs); int nargs);
XML_DEPRECATED
XMLPUBFUN xmlNodePtr XMLCALL XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj); xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
XML_DEPRECATED
XMLPUBFUN void XMLCALL XMLPUBFUN void XMLCALL
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt); xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -320,6 +320,12 @@ deprecated_funcs = {
'xmlSchemaCleanupTypes': True, 'xmlSchemaCleanupTypes': True,
'xmlSchemaInitTypes': True, 'xmlSchemaInitTypes': True,
'xmlXPathInit': True, 'xmlXPathInit': True,
'xmlXPtrEvalRangePredicate': True,
'xmlXPtrNewCollapsedRange': True,
'xmlXPtrNewLocationSetNodes': True,
'xmlXPtrNewRange': True,
'xmlXPtrNewRangeNodes': True,
'xmlXPtrRangeToFunction': True,
} }
def skip_function(name): def skip_function(name):

View File

@ -603,6 +603,7 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
case XPATH_STRING: case XPATH_STRING:
ret = PY_IMPORT_STRING((char *) obj->stringval); ret = PY_IMPORT_STRING((char *) obj->stringval);
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
{ {
PyObject *node; PyObject *node;
@ -704,6 +705,7 @@ libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj)
} }
break; break;
} }
#endif /* LIBXML_XPTR_LOCS_ENABLED */
default: default:
#ifdef DEBUG #ifdef DEBUG
printf("Unable to convert XPath object type %d\n", obj->type); printf("Unable to convert XPath object type %d\n", obj->type);

View File

@ -2596,7 +2596,7 @@ xpathDocTest(const char *filename,
return(ret); return(ret);
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
/** /**
* xptrDocTest: * xptrDocTest:
* @filename: the file to parse * @filename: the file to parse
@ -4527,7 +4527,7 @@ testDesc testDescriptions[] = {
{ "XPath document queries regression tests" , { "XPath document queries regression tests" ,
xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, xpathDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
0 }, 0 },
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
{ "XPointer document queries regression tests" , { "XPointer document queries regression tests" ,
xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL, xptrDocTest, "./test/XPath/docs/*", NULL, NULL, NULL,
0 }, 0 },

View File

@ -1833,9 +1833,11 @@ xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
failed = 1; failed = 1;
break; break;
case XPATH_UNDEFINED: case XPATH_UNDEFINED:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif
case XPATH_USERS: case XPATH_USERS:
failed = 1; failed = 1;
break; break;

213
testapi.c
View File

@ -50749,7 +50749,7 @@ static int
test_xmlXPtrBuildNodeList(void) { test_xmlXPtrBuildNodeList(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlNodePtr ret_val; xmlNodePtr ret_val;
xmlXPathObjectPtr obj; /* the XPointer result from the evaluation. */ xmlXPathObjectPtr obj; /* the XPointer result from the evaluation. */
@ -50824,7 +50824,7 @@ static int
test_xmlXPtrEvalRangePredicate(void) { test_xmlXPtrEvalRangePredicate(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */ xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */
int n_ctxt; int n_ctxt;
@ -50851,159 +50851,12 @@ test_xmlXPtrEvalRangePredicate(void) {
return(test_ret); return(test_ret);
} }
#ifdef LIBXML_XPTR_ENABLED
#define gen_nb_xmlLocationSetPtr 1
static xmlLocationSetPtr gen_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
return(NULL);
}
static void des_xmlLocationSetPtr(int no ATTRIBUTE_UNUSED, xmlLocationSetPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
}
#endif
static int
test_xmlXPtrLocationSetAdd(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED)
int mem_base;
xmlLocationSetPtr cur; /* the initial range set */
int n_cur;
xmlXPathObjectPtr val; /* a new xmlXPathObjectPtr */
int n_val;
for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) {
for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) {
mem_base = xmlMemBlocks();
cur = gen_xmlLocationSetPtr(n_cur, 0);
val = gen_xmlXPathObjectPtr(n_val, 1);
xmlXPtrLocationSetAdd(cur, val);
call_tests++;
des_xmlLocationSetPtr(n_cur, cur, 0);
des_xmlXPathObjectPtr(n_val, val, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrLocationSetAdd",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_cur);
printf(" %d", n_val);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrLocationSetCreate(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlXPtrLocationSetDel(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED)
int mem_base;
xmlLocationSetPtr cur; /* the initial range set */
int n_cur;
xmlXPathObjectPtr val; /* an xmlXPathObjectPtr */
int n_val;
for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) {
for (n_val = 0;n_val < gen_nb_xmlXPathObjectPtr;n_val++) {
mem_base = xmlMemBlocks();
cur = gen_xmlLocationSetPtr(n_cur, 0);
val = gen_xmlXPathObjectPtr(n_val, 1);
xmlXPtrLocationSetDel(cur, val);
call_tests++;
des_xmlLocationSetPtr(n_cur, cur, 0);
des_xmlXPathObjectPtr(n_val, val, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrLocationSetDel",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_cur);
printf(" %d", n_val);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int
test_xmlXPtrLocationSetMerge(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlXPtrLocationSetRemove(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED)
int mem_base;
xmlLocationSetPtr cur; /* the initial range set */
int n_cur;
int val; /* the index to remove */
int n_val;
for (n_cur = 0;n_cur < gen_nb_xmlLocationSetPtr;n_cur++) {
for (n_val = 0;n_val < gen_nb_int;n_val++) {
mem_base = xmlMemBlocks();
cur = gen_xmlLocationSetPtr(n_cur, 0);
val = gen_int(n_val, 1);
xmlXPtrLocationSetRemove(cur, val);
call_tests++;
des_xmlLocationSetPtr(n_cur, cur, 0);
des_int(n_val, val, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrLocationSetRemove",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_cur);
printf(" %d", n_val);
printf("\n");
}
}
}
function_tests++;
#endif
return(test_ret);
}
static int static int
test_xmlXPtrNewCollapsedRange(void) { test_xmlXPtrNewCollapsedRange(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting and ending node */ xmlNodePtr start; /* the starting and ending node */
@ -51047,7 +50900,7 @@ static int
test_xmlXPtrNewLocationSetNodeSet(void) { test_xmlXPtrNewLocationSetNodeSet(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodeSetPtr set; /* a node set */ xmlNodeSetPtr set; /* a node set */
@ -51081,7 +50934,7 @@ static int
test_xmlXPtrNewLocationSetNodes(void) { test_xmlXPtrNewLocationSetNodes(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the start NodePtr value */ xmlNodePtr start; /* the start NodePtr value */
@ -51122,7 +50975,7 @@ static int
test_xmlXPtrNewRange(void) { test_xmlXPtrNewRange(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */ xmlNodePtr start; /* the starting node */
@ -51177,7 +51030,7 @@ static int
test_xmlXPtrNewRangeNodeObject(void) { test_xmlXPtrNewRangeNodeObject(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */ xmlNodePtr start; /* the starting node */
@ -51218,7 +51071,7 @@ static int
test_xmlXPtrNewRangeNodePoint(void) { test_xmlXPtrNewRangeNodePoint(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */ xmlNodePtr start; /* the starting node */
@ -51259,7 +51112,7 @@ static int
test_xmlXPtrNewRangeNodes(void) { test_xmlXPtrNewRangeNodes(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlNodePtr start; /* the starting node */ xmlNodePtr start; /* the starting node */
@ -51300,7 +51153,7 @@ static int
test_xmlXPtrNewRangePointNode(void) { test_xmlXPtrNewRangePointNode(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlXPathObjectPtr start; /* the starting point */ xmlXPathObjectPtr start; /* the starting point */
@ -51341,7 +51194,7 @@ static int
test_xmlXPtrNewRangePoints(void) { test_xmlXPtrNewRangePoints(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathObjectPtr ret_val; xmlXPathObjectPtr ret_val;
xmlXPathObjectPtr start; /* the starting point */ xmlXPathObjectPtr start; /* the starting point */
@ -51382,7 +51235,7 @@ static int
test_xmlXPtrRangeToFunction(void) { test_xmlXPtrRangeToFunction(void) {
int test_ret = 0; int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED) && defined(LIBXML_XPTR_LOCS_ENABLED)
int mem_base; int mem_base;
xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */ xmlXPathParserContextPtr ctxt; /* the XPointer Parser context */
int n_ctxt; int n_ctxt;
@ -51416,53 +51269,14 @@ test_xmlXPtrRangeToFunction(void) {
return(test_ret); return(test_ret);
} }
static int
test_xmlXPtrWrapLocationSet(void) {
int test_ret = 0;
#if defined(LIBXML_XPTR_ENABLED)
int mem_base;
xmlXPathObjectPtr ret_val;
xmlLocationSetPtr val; /* the LocationSet value */
int n_val;
for (n_val = 0;n_val < gen_nb_xmlLocationSetPtr;n_val++) {
mem_base = xmlMemBlocks();
val = gen_xmlLocationSetPtr(n_val, 0);
ret_val = xmlXPtrWrapLocationSet(val);
desret_xmlXPathObjectPtr(ret_val);
call_tests++;
des_xmlLocationSetPtr(n_val, val, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlXPtrWrapLocationSet",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_val);
printf("\n");
}
}
function_tests++;
#endif
return(test_ret);
}
static int static int
test_xpointer(void) { test_xpointer(void) {
int test_ret = 0; int test_ret = 0;
if (quiet == 0) printf("Testing xpointer : 17 of 21 functions ...\n"); if (quiet == 0) printf("Testing xpointer : 13 of 21 functions ...\n");
test_ret += test_xmlXPtrBuildNodeList(); test_ret += test_xmlXPtrBuildNodeList();
test_ret += test_xmlXPtrEval(); test_ret += test_xmlXPtrEval();
test_ret += test_xmlXPtrEvalRangePredicate(); test_ret += test_xmlXPtrEvalRangePredicate();
test_ret += test_xmlXPtrLocationSetAdd();
test_ret += test_xmlXPtrLocationSetCreate();
test_ret += test_xmlXPtrLocationSetDel();
test_ret += test_xmlXPtrLocationSetMerge();
test_ret += test_xmlXPtrLocationSetRemove();
test_ret += test_xmlXPtrNewCollapsedRange(); test_ret += test_xmlXPtrNewCollapsedRange();
test_ret += test_xmlXPtrNewContext(); test_ret += test_xmlXPtrNewContext();
test_ret += test_xmlXPtrNewLocationSetNodeSet(); test_ret += test_xmlXPtrNewLocationSetNodeSet();
@ -51474,7 +51288,6 @@ test_xpointer(void) {
test_ret += test_xmlXPtrNewRangePointNode(); test_ret += test_xmlXPtrNewRangePointNode();
test_ret += test_xmlXPtrNewRangePoints(); test_ret += test_xmlXPtrNewRangePoints();
test_ret += test_xmlXPtrRangeToFunction(); test_ret += test_xmlXPtrRangeToFunction();
test_ret += test_xmlXPtrWrapLocationSet();
if (test_ret != 0) if (test_ret != 0)
printf("Module xpointer: %d errors\n", test_ret); printf("Module xpointer: %d errors\n", test_ret);

View File

@ -881,6 +881,7 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
return(result); return(result);
} }
#ifdef LIBXML_XPTR_LOCS_ENABLED
/** /**
* xmlXIncludeGetNthChild: * xmlXIncludeGetNthChild:
* @cur: the node * @cur: the node
@ -1120,6 +1121,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
} }
return(list); return(list);
} }
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/** /**
* xmlXIncludeBuildNodeList: * xmlXIncludeBuildNodeList:
@ -1218,7 +1220,7 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
} }
break; break;
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: { case XPATH_LOCATIONSET: {
xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user; xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
if (set == NULL) if (set == NULL)
@ -1240,10 +1242,10 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
} }
case XPATH_RANGE: case XPATH_RANGE:
return(xmlXIncludeCopyRange(ctxt, target, source, obj)); return(xmlXIncludeCopyRange(ctxt, target, source, obj));
#endif
case XPATH_POINT: case XPATH_POINT:
/* points are ignored in XInclude */ /* points are ignored in XInclude */
break; break;
#endif
default: default:
break; break;
} }
@ -1595,7 +1597,9 @@ loaded:
case XPATH_BOOLEAN: case XPATH_BOOLEAN:
case XPATH_NUMBER: case XPATH_NUMBER:
case XPATH_STRING: case XPATH_STRING:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
#endif
case XPATH_USERS: case XPATH_USERS:
case XPATH_XSLT_TREE: case XPATH_XSLT_TREE:
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
@ -1617,9 +1621,11 @@ loaded:
return(-1); return(-1);
} }
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
break; break;
#endif
} }
set = xptr->nodesetval; set = xptr->nodesetval;
if (set != NULL) { if (set != NULL) {

80
xpath.c
View File

@ -36,7 +36,7 @@
#include <libxml/xpathInternals.h> #include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
#include <libxml/hash.h> #include <libxml/hash.h>
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
#include <libxml/xpointer.h> #include <libxml/xpointer.h>
#endif #endif
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
@ -901,7 +901,7 @@ typedef enum {
XPATH_OP_PREDICATE, XPATH_OP_PREDICATE,
XPATH_OP_FILTER, /* 16 */ XPATH_OP_FILTER, /* 16 */
XPATH_OP_SORT /* 17 */ XPATH_OP_SORT /* 17 */
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
,XPATH_OP_RANGETO ,XPATH_OP_RANGETO
#endif #endif
} xmlXPathOp; } xmlXPathOp;
@ -1352,7 +1352,7 @@ xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
fprintf(output, "%d", i + 1); fprintf(output, "%d", i + 1);
xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1); xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1);
} }
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_LOCS_ENABLED)
static void static void
xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) { xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
int i; int i;
@ -1375,7 +1375,7 @@ xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1); xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1);
} }
} }
#endif /* LIBXML_XPTR_ENABLED */ #endif /* LIBXML_XPTR_LOCS_ENABLED */
/** /**
* xmlXPathDebugDumpObject: * xmlXPathDebugDumpObject:
@ -1444,6 +1444,7 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
xmlDebugDumpString(output, cur->stringval); xmlDebugDumpString(output, cur->stringval);
fprintf(output, "\n"); fprintf(output, "\n");
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
fprintf(output, "Object is a point : index %d in node", cur->index); fprintf(output, "Object is a point : index %d in node", cur->index);
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1); xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1);
@ -1479,12 +1480,11 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
} }
break; break;
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#if defined(LIBXML_XPTR_ENABLED)
fprintf(output, "Object is a Location Set:\n"); fprintf(output, "Object is a Location Set:\n");
xmlXPathDebugDumpLocationSet(output, xmlXPathDebugDumpLocationSet(output,
(xmlLocationSetPtr) cur->user, depth); (xmlLocationSetPtr) cur->user, depth);
#endif
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
fprintf(output, "Object is user defined\n"); fprintf(output, "Object is user defined\n");
break; break;
@ -1652,7 +1652,7 @@ xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
case XPATH_OP_ARG: fprintf(output, "ARG"); break; case XPATH_OP_ARG: fprintf(output, "ARG"); break;
case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break; case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break;
case XPATH_OP_FILTER: fprintf(output, "FILTER"); break; case XPATH_OP_FILTER: fprintf(output, "FILTER"); break;
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break; case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break;
#endif #endif
default: default:
@ -1844,6 +1844,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_STRING: case XPATH_STRING:
cache->dbgReusedString++; cache->dbgReusedString++;
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
cache->dbgReusedPoint++; cache->dbgReusedPoint++;
break; break;
@ -1853,6 +1854,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
cache->dbgReusedLocset++; cache->dbgReusedLocset++;
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
cache->dbgReusedUsers++; cache->dbgReusedUsers++;
break; break;
@ -1911,6 +1913,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
xmlXPathDebugObjMaxString = xmlXPathDebugObjMaxString =
xmlXPathDebugObjCounterString; xmlXPathDebugObjCounterString;
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
if (! isCached) if (! isCached)
xmlXPathDebugObjTotalPoint++; xmlXPathDebugObjTotalPoint++;
@ -1938,6 +1941,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
xmlXPathDebugObjMaxLocset = xmlXPathDebugObjMaxLocset =
xmlXPathDebugObjCounterLocset; xmlXPathDebugObjCounterLocset;
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
if (! isCached) if (! isCached)
xmlXPathDebugObjTotalUsers++; xmlXPathDebugObjTotalUsers++;
@ -1998,6 +2002,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_STRING: case XPATH_STRING:
cache->dbgCachedString++; cache->dbgCachedString++;
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
cache->dbgCachedPoint++; cache->dbgCachedPoint++;
break; break;
@ -2007,6 +2012,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
cache->dbgCachedLocset++; cache->dbgCachedLocset++;
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
cache->dbgCachedUsers++; cache->dbgCachedUsers++;
break; break;
@ -2035,6 +2041,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_STRING: case XPATH_STRING:
xmlXPathDebugObjCounterString--; xmlXPathDebugObjCounterString--;
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
xmlXPathDebugObjCounterPoint--; xmlXPathDebugObjCounterPoint--;
break; break;
@ -2044,6 +2051,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
xmlXPathDebugObjCounterLocset--; xmlXPathDebugObjCounterLocset--;
break; break;
#endif /* LIBXML_XPTR_LOCS_ENABLED */
case XPATH_USERS: case XPATH_USERS:
xmlXPathDebugObjCounterUsers--; xmlXPathDebugObjCounterUsers--;
break; break;
@ -2696,9 +2704,11 @@ xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
res = xmlXPathCastNumberToString(val->floatval); res = xmlXPathCastNumberToString(val->floatval);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO; TODO;
break; break;
} }
@ -5377,8 +5387,10 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
switch (val->type) { switch (val->type) {
case XPATH_BOOLEAN: case XPATH_BOOLEAN:
case XPATH_NUMBER: case XPATH_NUMBER:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
break; break;
case XPATH_STRING: case XPATH_STRING:
ret->stringval = xmlStrdup(val->stringval); ret->stringval = xmlStrdup(val->stringval);
@ -5422,8 +5434,8 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
/* Do not deallocate the copied tree value */ /* Do not deallocate the copied tree value */
ret->boolval = 0; ret->boolval = 0;
break; break;
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#ifdef LIBXML_XPTR_ENABLED
{ {
xmlLocationSetPtr loc = val->user; xmlLocationSetPtr loc = val->user;
ret->user = (void *) xmlXPtrLocationSetMerge(NULL, loc); ret->user = (void *) xmlXPtrLocationSetMerge(NULL, loc);
@ -5466,7 +5478,7 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
if (obj->nodesetval != NULL) if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval); xmlXPathFreeNodeSet(obj->nodesetval);
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (obj->type == XPATH_LOCATIONSET) { } else if (obj->type == XPATH_LOCATIONSET) {
if (obj->user != NULL) if (obj->user != NULL)
xmlXPtrFreeLocationSet(obj->user); xmlXPtrFreeLocationSet(obj->user);
@ -5556,7 +5568,7 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
goto obj_cached; goto obj_cached;
} }
break; break;
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
if (obj->user != NULL) { if (obj->user != NULL) {
xmlXPtrFreeLocationSet(obj->user); xmlXPtrFreeLocationSet(obj->user);
@ -5759,9 +5771,11 @@ xmlXPathCastToString(xmlXPathObjectPtr val) {
break; break;
} }
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
ret = xmlStrdup((const xmlChar *) ""); ret = xmlStrdup((const xmlChar *) "");
break; break;
@ -5804,9 +5818,11 @@ xmlXPathConvertString(xmlXPathObjectPtr val) {
res = xmlXPathCastNumberToString(val->floatval); res = xmlXPathCastNumberToString(val->floatval);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO; TODO;
break; break;
} }
@ -5924,9 +5940,11 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
ret = xmlXPathCastBooleanToNumber(val->boolval); ret = xmlXPathCastBooleanToNumber(val->boolval);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO; TODO;
ret = xmlXPathNAN; ret = xmlXPathNAN;
break; break;
@ -6036,9 +6054,11 @@ xmlXPathCastToBoolean (xmlXPathObjectPtr val) {
ret = val->boolval; ret = val->boolval;
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO; TODO;
ret = 0; ret = 0;
break; break;
@ -6975,9 +6995,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
ret = (arg1->boolval == ret); ret = (arg1->boolval == ret);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
case XPATH_NODESET: case XPATH_NODESET:
@ -7032,9 +7054,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
} }
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
case XPATH_NODESET: case XPATH_NODESET:
@ -7093,9 +7117,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
} }
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
case XPATH_NODESET: case XPATH_NODESET:
@ -7104,9 +7130,11 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
} }
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
case XPATH_NODESET: case XPATH_NODESET:
@ -7189,9 +7217,11 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval, 0); ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval, 0);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
} }
@ -7274,9 +7304,11 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval,1); ret = xmlXPathEqualNodeSetString(arg1, arg2->stringval,1);
break; break;
case XPATH_USERS: case XPATH_USERS:
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_POINT: case XPATH_POINT:
case XPATH_RANGE: case XPATH_RANGE:
case XPATH_LOCATIONSET: case XPATH_LOCATIONSET:
#endif /* LIBXML_XPTR_LOCS_ENABLED */
TODO TODO
break; break;
} }
@ -10587,7 +10619,7 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
"PathExpr: Type search\n"); "PathExpr: Type search\n");
#endif #endif
lc = 1; lc = 1;
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
} else if (ctxt->xptr && } else if (ctxt->xptr &&
xmlStrEqual(name, BAD_CAST "range-to")) { xmlStrEqual(name, BAD_CAST "range-to")) {
lc = 1; lc = 1;
@ -11238,7 +11270,7 @@ xmlXPathIsAxisName(const xmlChar *name) {
*/ */
static void static void
xmlXPathCompStep(xmlXPathParserContextPtr ctxt) { xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
int rangeto = 0; int rangeto = 0;
int op2 = -1; int op2 = -1;
#endif #endif
@ -11263,7 +11295,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
/* /*
* The modification needed for XPointer change to the production * The modification needed for XPointer change to the production
*/ */
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
if (ctxt->xptr) { if (ctxt->xptr) {
name = xmlXPathParseNCName(ctxt); name = xmlXPathParseNCName(ctxt);
if ((name != NULL) && (xmlStrEqual(name, BAD_CAST "range-to"))) { if ((name != NULL) && (xmlStrEqual(name, BAD_CAST "range-to"))) {
@ -11348,7 +11380,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval); xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
#endif #endif
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
eval_predicates: eval_predicates:
#endif #endif
op1 = ctxt->comp->last; op1 = ctxt->comp->last;
@ -11359,7 +11391,7 @@ eval_predicates:
xmlXPathCompPredicate(ctxt, 0); xmlXPathCompPredicate(ctxt, 0);
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
if (rangeto) { if (rangeto) {
PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0); PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, op1, 0, 0);
} else } else
@ -11702,7 +11734,7 @@ xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
xpctxt->proximityPosition = oldpp; xpctxt->proximityPosition = oldpp;
} }
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
/** /**
* xmlXPathLocationSetFilter: * xmlXPathLocationSetFilter:
* @ctxt: the XPath Parser context * @ctxt: the XPath Parser context
@ -11819,7 +11851,7 @@ xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
xpctxt->contextSize = oldcs; xpctxt->contextSize = oldcs;
xpctxt->proximityPosition = oldpp; xpctxt->proximityPosition = oldpp;
} }
#endif /* LIBXML_XPTR_ENABLED */ #endif /* LIBXML_XPTR_LOCS_ENABLED */
/** /**
* xmlXPathCompOpEvalPredicate: * xmlXPathCompOpEvalPredicate:
@ -12875,7 +12907,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
if (ctxt->value == NULL) if (ctxt->value == NULL)
return (total); return (total);
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
/* /*
* Hum are we filtering the result of an XPointer expression * Hum are we filtering the result of an XPointer expression
*/ */
@ -12890,7 +12922,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total); return (total);
} }
#endif /* LIBXML_XPTR_ENABLED */ #endif /* LIBXML_XPTR_LOCS_ENABLED */
CHECK_TYPE0(XPATH_NODESET); CHECK_TYPE0(XPATH_NODESET);
set = ctxt->value->nodesetval; set = ctxt->value->nodesetval;
@ -13298,7 +13330,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
if (ctxt->value == NULL) if (ctxt->value == NULL)
break; break;
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
/* /*
* Hum are we filtering the result of an XPointer expression * Hum are we filtering the result of an XPointer expression
*/ */
@ -13308,7 +13340,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
1, locset->locNr); 1, locset->locNr);
break; break;
} }
#endif /* LIBXML_XPTR_ENABLED */ #endif /* LIBXML_XPTR_LOCS_ENABLED */
CHECK_TYPE0(XPATH_NODESET); CHECK_TYPE0(XPATH_NODESET);
set = ctxt->value->nodesetval; set = ctxt->value->nodesetval;
@ -13329,7 +13361,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlXPathNodeSetSort(ctxt->value->nodesetval); xmlXPathNodeSetSort(ctxt->value->nodesetval);
} }
break; break;
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_OP_RANGETO:{ case XPATH_OP_RANGETO:{
xmlXPathObjectPtr range; xmlXPathObjectPtr range;
xmlXPathObjectPtr res, obj; xmlXPathObjectPtr res, obj;
@ -13487,7 +13519,7 @@ rangeto_error:
ctxt->context->proximityPosition = oldpp; ctxt->context->proximityPosition = oldpp;
break; break;
} }
#endif /* LIBXML_XPTR_ENABLED */ #endif /* LIBXML_XPTR_LOCS_ENABLED */
default: default:
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"XPath: unknown precompiled operation %d\n", op->op); "XPath: unknown precompiled operation %d\n", op->op);
@ -13995,7 +14027,7 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
return(res->nodesetval->nodeNr != 0); return(res->nodesetval->nodeNr != 0);
case XPATH_STRING: case XPATH_STRING:
return((res->stringval != NULL) && (res->stringval[0] != 0)); return((res->stringval != NULL) && (res->stringval[0] != 0));
#ifdef LIBXML_XPTR_ENABLED #ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET:{ case XPATH_LOCATIONSET:{
xmlLocationSetPtr ptr = res->user; xmlLocationSetPtr ptr = res->user;
if (ptr == NULL) if (ptr == NULL)

View File

@ -132,6 +132,7 @@ xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
* A few helper functions for child sequences * * A few helper functions for child sequences *
* * * *
************************************************************************/ ************************************************************************/
#ifdef LIBXML_XPTR_LOCS_ENABLED
/* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */ /* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
/** /**
@ -177,6 +178,7 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
} }
return(i); return(i);
} }
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/** /**
* xmlXPtrGetNthChild: * xmlXPtrGetNthChild:
@ -205,6 +207,7 @@ xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
return(cur); return(cur);
} }
#ifdef LIBXML_XPTR_LOCS_ENABLED
/************************************************************************ /************************************************************************
* * * *
* Handling of XPointer specific types * * Handling of XPointer specific types *
@ -836,6 +839,7 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
ret->user = (void *) val; ret->user = (void *) val;
return(ret); return(ret);
} }
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/************************************************************************ /************************************************************************
* * * *
@ -1125,12 +1129,14 @@ xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
xmlXPathObjectPtr obj = ctxt->value; xmlXPathObjectPtr obj = ctxt->value;
switch (obj->type) { switch (obj->type) {
#ifdef LIBXML_XPTR_LOCS_ENABLED
case XPATH_LOCATIONSET: { case XPATH_LOCATIONSET: {
xmlLocationSetPtr loc = ctxt->value->user; xmlLocationSetPtr loc = ctxt->value->user;
if ((loc != NULL) && (loc->locNr > 0)) if ((loc != NULL) && (loc->locNr > 0))
return; return;
break; break;
} }
#endif
case XPATH_NODESET: { case XPATH_NODESET: {
xmlNodeSetPtr loc = ctxt->value->nodesetval; xmlNodeSetPtr loc = ctxt->value->nodesetval;
if ((loc != NULL) && (loc->nodeNr > 0)) if ((loc != NULL) && (loc->nodeNr > 0))
@ -1269,6 +1275,7 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
* * * *
************************************************************************/ ************************************************************************/
#ifdef LIBXML_XPTR_LOCS_ENABLED
static static
void xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs); void xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
static static
@ -1283,6 +1290,7 @@ static
void xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs); void xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs);
static static
void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs); void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
/** /**
* xmlXPtrNewContext: * xmlXPtrNewContext:
@ -1298,10 +1306,13 @@ void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
xmlXPathContextPtr xmlXPathContextPtr
xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) { xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) {
xmlXPathContextPtr ret; xmlXPathContextPtr ret;
(void) here;
(void) origin;
ret = xmlXPathNewContext(doc); ret = xmlXPathNewContext(doc);
if (ret == NULL) if (ret == NULL)
return(ret); return(ret);
#ifdef LIBXML_XPTR_LOCS_ENABLED
ret->xptr = 1; ret->xptr = 1;
ret->here = here; ret->here = here;
ret->origin = origin; ret->origin = origin;
@ -1320,6 +1331,7 @@ xmlXPtrNewContext(xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin) {
xmlXPtrHereFunction); xmlXPtrHereFunction);
xmlXPathRegisterFunc(ret, (xmlChar *)" origin", xmlXPathRegisterFunc(ret, (xmlChar *)" origin",
xmlXPtrOriginFunction); xmlXPtrOriginFunction);
#endif /* LIBXML_XPTR_LOCS_ENABLED */
return(ret); return(ret);
} }
@ -1353,8 +1365,10 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPtrEvalXPointer(ctxt); xmlXPtrEvalXPointer(ctxt);
if ((ctxt->value != NULL) && if ((ctxt->value != NULL) &&
(ctxt->value->type != XPATH_NODESET) && #ifdef LIBXML_XPTR_LOCS_ENABLED
(ctxt->value->type != XPATH_LOCATIONSET)) { (ctxt->value->type != XPATH_LOCATIONSET) &&
#endif
(ctxt->value->type != XPATH_NODESET)) {
xmlXPtrErr(ctxt, XML_XPTR_EVAL_FAILED, xmlXPtrErr(ctxt, XML_XPTR_EVAL_FAILED,
"xmlXPtrEval: evaluation failed to return a node set\n", "xmlXPtrEval: evaluation failed to return a node set\n",
NULL); NULL);
@ -1395,6 +1409,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
return(res); return(res);
} }
#ifdef LIBXML_XPTR_LOCS_ENABLED
/** /**
* xmlXPtrBuildRangeNodeList: * xmlXPtrBuildRangeNodeList:
* @range: a range object * @range: a range object
@ -2948,6 +2963,7 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
NEXT; NEXT;
SKIP_BLANKS; SKIP_BLANKS;
} }
#endif /* LIBXML_XPTR_LOCS_ENABLED */
#endif #endif