Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix another load of C compiler warnings about xmlChar* unsignedness etc.

  • Loading branch information...
commit 7eca2bb4b704058c0430ded3d1c05ed418ac7223 1 parent b3d02ab
@scoder scoder authored
View
4 src/lxml/apihelpers.pxi
@@ -916,7 +916,7 @@ cdef inline bint _tagMatchesExactly(xmlNode* c_node, qname* c_qname):
else:
return tree.xmlStrcmp(<const_xmlChar*>python.__cstr(c_qname.href), c_node_href) == 0
-cdef size_t _mapTagsToQnameMatchArray(xmlDoc* c_doc, list ns_tags,
+cdef Py_ssize_t _mapTagsToQnameMatchArray(xmlDoc* c_doc, list ns_tags,
qname* c_ns_tags, bint force_into_dict) except -1:
u"""Map a sequence of (name, namespace) pairs to a qname array for efficient
matching with _tagMatchesExactly() above.
@@ -924,7 +924,7 @@ cdef size_t _mapTagsToQnameMatchArray(xmlDoc* c_doc, list ns_tags,
Note that each qname struct in the array owns its href byte string object
if it is not NULL.
"""
- cdef size_t count = 0, i
+ cdef Py_ssize_t count = 0, i
cdef bytes ns, tag
for ns, tag in ns_tags:
if tag is None:
View
6 src/lxml/dtd.pxi
@@ -282,14 +282,14 @@ cdef class DTD(_Validator):
if _isString(file):
file = _encodeFilename(file)
with self._error_log:
- self._c_dtd = xmlparser.xmlParseDTD(NULL, _cstr(file))
+ self._c_dtd = xmlparser.xmlParseDTD(NULL, _xcstr(file))
elif hasattr(file, 'read'):
self._c_dtd = _parseDtdFromFilelike(file)
else:
raise DTDParseError, u"file must be a filename or file-like object"
elif external_id is not None:
with self._error_log:
- self._c_dtd = xmlparser.xmlParseDTD(external_id, NULL)
+ self._c_dtd = xmlparser.xmlParseDTD(<const_xmlChar*>external_id, NULL)
else:
raise DTDParseError, u"either filename or external ID required"
@@ -350,7 +350,7 @@ cdef class DTD(_Validator):
cdef _Element root_node
cdef xmlDoc* c_doc
cdef dtdvalid.xmlValidCtxt* valid_ctxt
- cdef int ret
+ cdef int ret = -1
assert self._c_dtd is not NULL, "DTD not initialised"
doc = _documentOrRaise(etree)
View
6 src/lxml/includes/tree.pxd
@@ -52,7 +52,7 @@ cdef extern from "libxml/encoding.h":
cdef xmlCharEncodingHandler* xmlGetCharEncodingHandler(
xmlCharEncoding enc) nogil
cdef int xmlCharEncCloseFunc(xmlCharEncodingHandler* handler) nogil
- cdef xmlCharEncoding xmlDetectCharEncoding(char* text, int len) nogil
+ cdef xmlCharEncoding xmlDetectCharEncoding(const_xmlChar* text, int len) nogil
cdef const_char* xmlGetCharEncodingName(xmlCharEncoding enc) nogil
cdef xmlCharEncoding xmlParseCharEncoding(char* name) nogil
@@ -61,9 +61,9 @@ cdef extern from "libxml/chvalid.h":
cdef extern from "libxml/hash.h":
ctypedef struct xmlHashTable
- ctypedef void (*xmlHashScanner)(void* payload, void* data, char* name) # may require GIL!
+ ctypedef void (*xmlHashScanner)(void* payload, void* data, const_xmlChar* name) # may require GIL!
void xmlHashScan(xmlHashTable* table, xmlHashScanner f, void* data) nogil
- void* xmlHashLookup(xmlHashTable* table, char* name) nogil
+ void* xmlHashLookup(xmlHashTable* table, const_xmlChar* name) nogil
cdef extern from *: # actually "libxml/dict.h"
# libxml/dict.h appears to be broken to include in C
View
2  src/lxml/includes/xmlparser.pxd
@@ -197,7 +197,7 @@ cdef extern from "libxml/parser.h":
# DTDs:
- cdef xmlDtd* xmlParseDTD(char* ExternalID, char* SystemID) nogil
+ cdef xmlDtd* xmlParseDTD(const_xmlChar* ExternalID, const_xmlChar* SystemID) nogil
cdef xmlDtd* xmlIOParseDTD(xmlSAXHandler* sax,
xmlParserInputBuffer* input,
int enc) nogil
View
51 src/lxml/includes/xslt.pxd
@@ -20,7 +20,7 @@ cdef extern from "libxslt/xsltInternals.h":
xmlDoc* doc
ctypedef struct xsltStylesheet:
- char* encoding
+ xmlChar* encoding
xmlDoc* doc
int errors
@@ -51,18 +51,18 @@ cdef extern from "libxslt/extensions.h":
void* precomp_unused) nogil
cdef int xsltRegisterExtFunction(xsltTransformContext* ctxt,
- char* name,
- char* URI,
+ const_xmlChar* name,
+ const_xmlChar* URI,
xmlXPathFunction function) nogil
- cdef int xsltRegisterExtModuleFunction(char* name, char* URI,
+ cdef int xsltRegisterExtModuleFunction(const_xmlChar* name, const_xmlChar* URI,
xmlXPathFunction function) nogil
- cdef int xsltUnregisterExtModuleFunction(char* name, char* URI)
+ cdef int xsltUnregisterExtModuleFunction(const_xmlChar* name, const_xmlChar* URI)
cdef xmlXPathFunction xsltExtModuleFunctionLookup(
- char* name, char* URI) nogil
+ const_xmlChar* name, const_xmlChar* URI) nogil
cdef int xsltRegisterExtPrefix(xsltStylesheet* style,
- char* prefix, char* URI) nogil
+ const_xmlChar* prefix, const_xmlChar* URI) nogil
cdef int xsltRegisterExtElement(xsltTransformContext* ctxt,
- char* name, char* URI,
+ const_xmlChar* name, const_xmlChar* URI,
xsltTransformFunction function) nogil
cdef extern from "libxslt/documents.h":
@@ -146,19 +146,16 @@ cdef extern from "libxslt/security.h":
cdef extern from "libxslt/variables.h":
cdef int xsltQuoteUserParams(xsltTransformContext* ctxt,
- char** params)
+ const_char** params)
cdef int xsltQuoteOneUserParam(xsltTransformContext* ctxt,
- char* name,
- char* value)
- cdef int xsltEvalOneUserParam(xsltTransformContext* ctxt,
- char* name,
- char* value)
+ const_xmlChar* name,
+ const_xmlChar* value)
cdef extern from "libxslt/extra.h":
- cdef char* XSLT_LIBXSLT_NAMESPACE
- cdef char* XSLT_XALAN_NAMESPACE
- cdef char* XSLT_SAXON_NAMESPACE
- cdef char* XSLT_XT_NAMESPACE
+ const_xmlChar* XSLT_LIBXSLT_NAMESPACE
+ const_xmlChar* XSLT_XALAN_NAMESPACE
+ const_xmlChar* XSLT_SAXON_NAMESPACE
+ const_xmlChar* XSLT_XT_NAMESPACE
cdef xmlXPathFunction xsltFunctionNodeSet
cdef void xsltRegisterAllExtras() nogil
@@ -167,13 +164,13 @@ cdef extern from "libexslt/exslt.h":
cdef void exsltRegisterAll() nogil
# libexslt 1.1.25+
- char* EXSLT_DATE_NAMESPACE
- char* EXSLT_SETS_NAMESPACE
- char* EXSLT_MATH_NAMESPACE
- char* EXSLT_STRINGS_NAMESPACE
-
- cdef int exsltDateXpathCtxtRegister(xmlXPathContext* ctxt, char* prefix)
- cdef int exsltSetsXpathCtxtRegister(xmlXPathContext* ctxt, char* prefix)
- cdef int exsltMathXpathCtxtRegister(xmlXPathContext* ctxt, char* prefix)
- cdef int exsltStrXpathCtxtRegister(xmlXPathContext* ctxt, char* prefix)
+ const_xmlChar* EXSLT_DATE_NAMESPACE
+ const_xmlChar* EXSLT_SETS_NAMESPACE
+ const_xmlChar* EXSLT_MATH_NAMESPACE
+ const_xmlChar* EXSLT_STRINGS_NAMESPACE
+
+ cdef int exsltDateXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
+ cdef int exsltSetsXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
+ cdef int exsltMathXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
+ cdef int exsltStrXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
View
4 src/lxml/lxml.etree.pyx
@@ -2390,7 +2390,7 @@ cdef public class _ElementIterator(_ElementTagMatcher) [
c_node = self._next_element(node._c_node)
while c_node is not NULL and \
self._node_type != 0 and \
- (self._node_type != c_node.type or
+ (<tree.xmlElementType>self._node_type != c_node.type or
not _tagMatches(c_node, <const_xmlChar*>self._href, <const_xmlChar*>self._name)):
c_node = self._next_element(c_node)
if c_node is NULL:
@@ -2512,7 +2512,7 @@ cdef class _MultiTagMatcher:
if not self._cached_tags:
self._cached_doc = None
raise MemoryError()
- self._tag_count = _mapTagsToQnameMatchArray(
+ self._tag_count = <size_t>_mapTagsToQnameMatchArray(
doc._c_doc, self._py_tags, self._cached_tags, force_into_dict)
self._cached_doc = doc
self._cached_size = dict_size
View
2  src/lxml/parser.pxi
@@ -229,7 +229,7 @@ cdef int _setupPythonUnicode() except -1:
cdef const_char* _findEncodingName(const_char* buffer, int size):
u"Work around bug in libxml2: find iconv name of encoding on our own."
cdef tree.xmlCharEncoding enc
- enc = tree.xmlDetectCharEncoding(buffer, size)
+ enc = tree.xmlDetectCharEncoding(<const_xmlChar*>buffer, size)
if enc == tree.XML_CHAR_ENCODING_UTF16LE:
return "UTF-16LE"
elif enc == tree.XML_CHAR_ENCODING_UTF16BE:
View
1  src/lxml/schematron.pxi
@@ -163,6 +163,7 @@ cdef class Schematron(_Validator):
ret = schematron.xmlSchematronValidateDoc(valid_ctxt, c_doc)
_destroyFakeDoc(doc._c_doc, c_doc)
else:
+ ret = -1
with self._error_log:
c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
with nogil:
View
8 src/lxml/xmlid.pxi
@@ -84,7 +84,7 @@ cdef class _IDDict:
cdef xmlAttr* c_attr
c_ids = self._doc._c_doc.ids
id_utf = _utf8(id_name)
- c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _cstr(id_utf))
+ c_id = <tree.xmlID*>tree.xmlHashLookup(c_ids, _xcstr(id_utf))
if c_id is NULL:
raise KeyError, u"key not found."
c_attr = c_id.attr
@@ -99,7 +99,7 @@ cdef class _IDDict:
cdef tree.xmlID* c_id
id_utf = _utf8(id_name)
c_id = <tree.xmlID*>tree.xmlHashLookup(
- self._doc._c_doc.ids, _cstr(id_utf))
+ self._doc._c_doc.ids, _xcstr(id_utf))
return c_id is not NULL
def has_key(self, id_name):
@@ -162,7 +162,7 @@ cdef class _IDDict:
<tree.xmlHashScanner>_collectIdHashItemList, <python.PyObject*>context)
return items
-cdef void _collectIdHashItemList(void* payload, void* context, const_xmlChar* name):
+cdef void _collectIdHashItemList(void* payload, void* context, xmlChar* name):
# collect elements from ID attribute hash table
cdef tree.xmlID* c_id
cdef list lst
@@ -173,7 +173,7 @@ cdef void _collectIdHashItemList(void* payload, void* context, const_xmlChar* na
element = _elementFactory(doc, c_id.attr.parent)
lst.append( (funicode(name), element) )
-cdef void _collectIdHashKeys(void* payload, void* collect_list, const_xmlChar* name):
+cdef void _collectIdHashKeys(void* payload, void* collect_list, xmlChar* name):
cdef tree.xmlID* c_id
c_id = <tree.xmlID*>payload
if c_id is NULL or c_id.attr is NULL or c_id.attr.parent is NULL:
View
16 src/lxml/xpath.pxi
@@ -83,7 +83,7 @@ cdef class _XPathContext(_BaseContext):
# we'd only execute dummy functions anyway
return
tree.xmlHashScan(
- self._xpathCtxt.nsHash, <tree.xmlHashScanner>_registerExsltFunctionsForNamespaces,
+ self._xpathCtxt.nsHash, _registerExsltFunctionsForNamespaces,
self._xpathCtxt)
cdef registerVariables(self, variable_dict):
@@ -105,17 +105,17 @@ cdef class _XPathContext(_BaseContext):
__GLOBAL_PARSER_CONTEXT.initXPathParserDict(xpathCtxt)
cdef void _registerExsltFunctionsForNamespaces(
- void* _c_href, void* _ctxt, char* c_prefix):
- cdef char* c_href = <char*> _c_href
- cdef xpath.xmlXPathContext* ctxt = <xpath.xmlXPathContext*> _ctxt
+ void* _c_href, void* _ctxt, xmlChar* c_prefix):
+ c_href = <const_xmlChar*> _c_href
+ ctxt = <xpath.xmlXPathContext*> _ctxt
- if cstring_h.strcmp(c_href, xslt.EXSLT_DATE_NAMESPACE) == 0:
+ if tree.xmlStrcmp(c_href, xslt.EXSLT_DATE_NAMESPACE) == 0:
xslt.exsltDateXpathCtxtRegister(ctxt, c_prefix)
- elif cstring_h.strcmp(c_href, xslt.EXSLT_SETS_NAMESPACE) == 0:
+ elif tree.xmlStrcmp(c_href, xslt.EXSLT_SETS_NAMESPACE) == 0:
xslt.exsltSetsXpathCtxtRegister(ctxt, c_prefix)
- elif cstring_h.strcmp(c_href, xslt.EXSLT_MATH_NAMESPACE) == 0:
+ elif tree.xmlStrcmp(c_href, xslt.EXSLT_MATH_NAMESPACE) == 0:
xslt.exsltMathXpathCtxtRegister(ctxt, c_prefix)
- elif cstring_h.strcmp(c_href, xslt.EXSLT_STRINGS_NAMESPACE) == 0:
+ elif tree.xmlStrcmp(c_href, xslt.EXSLT_STRINGS_NAMESPACE) == 0:
xslt.exsltStrXpathCtxtRegister(ctxt, c_prefix)
cdef bint _XPATH_VERSION_WARNING_REQUIRED
View
12 src/lxml/xslt.pxi
@@ -1,5 +1,5 @@
-# XSLT
+# XSLT
from lxml.includes cimport xslt
class XSLTError(LxmlError):
@@ -260,7 +260,7 @@ cdef int _register_xslt_function(void* ctxt, name_utf, ns_utf):
return 0
# libxml2 internalises the strings if ctxt has a dict
return xslt.xsltRegisterExtFunction(
- <xslt.xsltTransformContext*>ctxt, _cstr(name_utf), _cstr(ns_utf),
+ <xslt.xsltTransformContext*>ctxt, _xcstr(name_utf), _xcstr(ns_utf),
<xslt.xmlXPathFunction>_xpath_function_call)
cdef dict EMPTY_DICT = {}
@@ -654,7 +654,7 @@ cdef _convert_xslt_parameters(xslt.xsltTransformContext* transform_ctxt,
if isinstance(value, _XSLTQuotedStringParam):
v = (<_XSLTQuotedStringParam>value).strval
xslt.xsltQuoteOneUserParam(
- transform_ctxt, _cstr(k), _cstr(v))
+ transform_ctxt, _xcstr(k), _xcstr(v))
else:
if isinstance(value, XPath):
v = (<XPath>value)._path
@@ -733,11 +733,11 @@ cdef class _XSLTResultTree(_ElementTree):
try:
result = <bytes>s[:l]
finally:
- tree.xmlFree(<char*>s)
+ tree.xmlFree(s)
return result
def __unicode__(self):
- cdef char* encoding
+ cdef xmlChar* encoding
cdef xmlChar* s = NULL
cdef int l = 0
self._saveToStringAndSize(&s, &l)
@@ -750,7 +750,7 @@ cdef class _XSLTResultTree(_ElementTree):
else:
result = s[:l].decode(encoding)
finally:
- tree.xmlFree(<char*>s)
+ tree.xmlFree(s)
return _stripEncodingDeclaration(result)
def __getbuffer__(self, Py_buffer* buffer, int flags):
View
2  src/lxml/xsltext.pxi
@@ -135,7 +135,7 @@ cdef _registerXSLTExtensions(xslt.xsltTransformContext* c_ctxt,
extension_dict):
for ns_utf, name_utf in extension_dict:
xslt.xsltRegisterExtElement(
- c_ctxt, _cstr(name_utf), _cstr(ns_utf),
+ c_ctxt, _xcstr(name_utf), _xcstr(ns_utf),
<xslt.xsltTransformFunction>_callExtensionElement)
cdef void _callExtensionElement(xslt.xsltTransformContext* c_ctxt,

0 comments on commit 7eca2bb

Please sign in to comment.
Something went wrong with that request. Please try again.