avoid passing a char[] as snprintf first argument. implemented
* encoding.c parserInternals.c: avoid passing a char[] as snprintf
first argument.
* threads.c include/libxml/threads.h: implemented xmlIsThreadsEnabled()
based on Andrew W. Nosenko idea.
* doc/* elfgcchack.h: regenerated the API
Daniel
diff --git a/ChangeLog b/ChangeLog
index 52bc538..935330b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Sep 2 14:26:43 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+ * encoding.c parserInternals.c: avoid passing a char[] as snprintf
+ first argument.
+ * threads.c include/libxml/threads.h: implemented xmlIsThreadsEnabled()
+ based on Andrew W. Nosenko idea.
+ * doc/* elfgcchack.h: regenerated the API
+
Thu Sep 1 14:44:42 CEST 2005 Daniel Veillard <daniel@veillard.com>
* configure.in: the use of AM_PATH_PYTHON is not portable enough
diff --git a/doc/APIchunk10.html b/doc/APIchunk10.html
index 161b4ef..c5083f0 100644
--- a/doc/APIchunk10.html
+++ b/doc/APIchunk10.html
@@ -52,6 +52,7 @@
<a href="html/libxml-xpath.html#xmlXPathOrderDocElems">xmlXPathOrderDocElems</a><br />
</dd><dt>about</dt><dd><a href="html/libxml-parser.html#_xmlParserCtxt">_xmlParserCtxt</a><br />
<a href="html/libxml-debugXML.html#xmlDebugDumpString">xmlDebugDumpString</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-debugXML.html#xmlShellDir">xmlShellDir</a><br />
<a href="html/libxml-xmlwriter.html#xmlTextWriterWriteRawLen">xmlTextWriterWriteRawLen</a><br />
</dd><dt>above</dt><dd><a href="html/libxml-parserInternals.html#xmlParseMarkupDecl">xmlParseMarkupDecl</a><br />
diff --git a/doc/APIchunk12.html b/doc/APIchunk12.html
index e818ee7..e3451a0 100644
--- a/doc/APIchunk12.html
+++ b/doc/APIchunk12.html
@@ -419,6 +419,7 @@
<a href="html/libxml-xmlregexp.html#xmlExpDump">xmlExpDump</a><br />
<a href="html/libxml-xmlregexp.html#xmlExpMaxToken">xmlExpMaxToken</a><br />
<a href="html/libxml-xmlerror.html#xmlGetLastError">xmlGetLastError</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-pattern.html#xmlPatterncompile">xmlPatterncompile</a><br />
<a href="html/libxml-xmlregexp.html#xmlRegexpCompile">xmlRegexpCompile</a><br />
<a href="html/libxml-xmlregexp.html#xmlRegexpExec">xmlRegexpExec</a><br />
diff --git a/doc/APIchunk14.html b/doc/APIchunk14.html
index 78fd4a8..fc36d54 100644
--- a/doc/APIchunk14.html
+++ b/doc/APIchunk14.html
@@ -113,7 +113,8 @@
</dd><dt>emitted</dt><dd><a href="html/libxml-xmlerror.html#xmlSetGenericErrorFunc">xmlSetGenericErrorFunc</a><br />
</dd><dt>empty-element</dt><dd><a href="html/libxml-parserInternals.html#xmlParseStartTag">xmlParseStartTag</a><br />
</dd><dt>enable</dt><dd><a href="html/libxml-catalog.html#xmlCatalogSetDebug">xmlCatalogSetDebug</a><br />
-</dd><dt>enabled</dt><dd><a href="html/libxml-tree.html#xmlSaveFile">xmlSaveFile</a><br />
+</dd><dt>enabled</dt><dd><a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
+<a href="html/libxml-tree.html#xmlSaveFile">xmlSaveFile</a><br />
<a href="html/libxml-tree.html#xmlSaveFormatFile">xmlSaveFormatFile</a><br />
</dd><dt>enabling</dt><dd><a href="html/libxml-parser.html#xmlLineNumbersDefault">xmlLineNumbersDefault</a><br />
<a href="html/libxml-parser.html#xmlPedanticParserDefault">xmlPedanticParserDefault</a><br />
diff --git a/doc/APIchunk17.html b/doc/APIchunk17.html
index b797ffd..403c5b0 100644
--- a/doc/APIchunk17.html
+++ b/doc/APIchunk17.html
@@ -279,6 +279,7 @@
<a href="html/libxml-debugXML.html#xmlDebugDumpNode">xmlDebugDumpNode</a><br />
<a href="html/libxml-debugXML.html#xmlDebugDumpNodeList">xmlDebugDumpNodeList</a><br />
<a href="html/libxml-debugXML.html#xmlDebugDumpOneNode">xmlDebugDumpOneNode</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-nanoftp.html#xmlNanoFTPUpdateURL">xmlNanoFTPUpdateURL</a><br />
<a href="html/libxml-nanohttp.html#xmlNanoHTTPFetch">xmlNanoHTTPFetch</a><br />
<a href="html/libxml-nanohttp.html#xmlNanoHTTPMethod">xmlNanoHTTPMethod</a><br />
diff --git a/doc/APIchunk18.html b/doc/APIchunk18.html
index f02b4d0..21013fd 100644
--- a/doc/APIchunk18.html
+++ b/doc/APIchunk18.html
@@ -223,6 +223,7 @@
<a href="html/libxml-threads.html#xmlCleanupThreads">xmlCleanupThreads</a><br />
<a href="html/libxml-threads.html#xmlInitThreads">xmlInitThreads</a><br />
<a href="html/libxml-globals.html#xmlInitializeGlobalState">xmlInitializeGlobalState</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-threads.html#xmlLockLibrary">xmlLockLibrary</a><br />
<a href="html/libxml-xmlmodule.html#xmlModuleFree">xmlModuleFree</a><br />
<a href="html/libxml-xmlmodule.html#xmlModuleOpen">xmlModuleOpen</a><br />
diff --git a/doc/APIchunk19.html b/doc/APIchunk19.html
index ade6618..5e4b9d0 100644
--- a/doc/APIchunk19.html
+++ b/doc/APIchunk19.html
@@ -307,6 +307,7 @@
</dd><dt>multiple</dt><dd><a href="html/libxml-parserInternals.html#xmlCurrentChar">xmlCurrentChar</a><br />
<a href="html/libxml-parserInternals.html#xmlStringCurrentChar">xmlStringCurrentChar</a><br />
</dd><dt>multiply</dt><dd><a href="html/libxml-xpathInternals.html#xmlXPathMultValues">xmlXPathMultValues</a><br />
+</dd><dt>multithread</dt><dd><a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
</dd><dt>multithreaded</dt><dd><a href="html/libxml-parserInternals.html#htmlInitAutoClose">htmlInitAutoClose</a><br />
<a href="html/libxml-parser.html#xmlInitParser">xmlInitParser</a><br />
</dd><dt>mutex</dt><dd><a href="html/libxml-dict.html#xmlDictCleanup">xmlDictCleanup</a><br />
diff --git a/doc/APIchunk6.html b/doc/APIchunk6.html
index 1433661..69026ab 100644
--- a/doc/APIchunk6.html
+++ b/doc/APIchunk6.html
@@ -240,6 +240,7 @@
</dd><dt>Reverse</dt><dd><a href="html/libxml-list.html#xmlListReverse">xmlListReverse</a><br />
</dd><dt>Root</dt><dd><a href="html/libxml-parserInternals.html#xmlParseDocTypeDecl">xmlParseDocTypeDecl</a><br />
<a href="html/libxml-valid.html#xmlValidateRoot">xmlValidateRoot</a><br />
+</dd><dt>Run-time</dt><dd><a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
</dd><dt>Runic</dt><dd><a href="html/libxml-xmlunicode.html#xmlUCSIsRunic">xmlUCSIsRunic</a><br />
</dd></dl><h2 align="center"><a href="APIchunk0.html">A-B</a>
<a href="APIchunk1.html">C-C</a>
diff --git a/doc/APIfiles.html b/doc/APIfiles.html
index 7cdd7f2..6f74021 100644
--- a/doc/APIfiles.html
+++ b/doc/APIfiles.html
@@ -1202,6 +1202,7 @@
<a href="html/libxml-threads.html#xmlGetThreadId">xmlGetThreadId</a><br />
<a href="html/libxml-threads.html#xmlInitThreads">xmlInitThreads</a><br />
<a href="html/libxml-threads.html#xmlIsMainThread">xmlIsMainThread</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-threads.html#xmlLockLibrary">xmlLockLibrary</a><br />
<a href="html/libxml-threads.html#xmlMutex">xmlMutex</a><br />
<a href="html/libxml-threads.html#xmlMutexLock">xmlMutexLock</a><br />
diff --git a/doc/APIsymbols.html b/doc/APIsymbols.html
index 7abb56c..fd58561 100644
--- a/doc/APIsymbols.html
+++ b/doc/APIsymbols.html
@@ -2084,6 +2084,7 @@
<a href="html/libxml-chvalid.html#xmlIsPubidChar_ch">xmlIsPubidChar_ch</a><br />
<a href="html/libxml-chvalid.html#xmlIsPubidChar_tab">xmlIsPubidChar_tab</a><br />
<a href="html/libxml-valid.html#xmlIsRef">xmlIsRef</a><br />
+<a href="html/libxml-threads.html#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a><br />
<a href="html/libxml-tree.html#xmlIsXHTML">xmlIsXHTML</a><br />
<a href="html/libxml-parser.html#xmlKeepBlanksDefault">xmlKeepBlanksDefault</a><br />
<a href="html/libxml-globals.html#xmlKeepBlanksDefaultValue">xmlKeepBlanksDefaultValue</a><br />
diff --git a/doc/html/libxml-threads.html b/doc/html/libxml-threads.html
index 7df283b..8d79db4 100644
--- a/doc/html/libxml-threads.html
+++ b/doc/html/libxml-threads.html
@@ -23,6 +23,7 @@
<pre class="programlisting">int <a href="#xmlGetThreadId">xmlGetThreadId</a> (void)</pre>
<pre class="programlisting">void <a href="#xmlInitThreads">xmlInitThreads</a> (void)</pre>
<pre class="programlisting">int <a href="#xmlIsMainThread">xmlIsMainThread</a> (void)</pre>
+<pre class="programlisting">int <a href="#xmlIsThreadsEnabled">xmlIsThreadsEnabled</a> (void)</pre>
<pre class="programlisting">void <a href="#xmlLockLibrary">xmlLockLibrary</a> (void)</pre>
<pre class="programlisting">void <a href="#xmlMutexLock">xmlMutexLock</a> (<a href="libxml-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)</pre>
<pre class="programlisting">void <a href="#xmlMutexUnlock">xmlMutexUnlock</a> (<a href="libxml-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)</pre>
@@ -50,7 +51,9 @@
</pre><p>xmlInitThreads() is used to to initialize all the thread related data of the libxml2 library.</p>
<h3><a name="xmlIsMainThread" id="xmlIsMainThread"></a>Function: xmlIsMainThread</h3><pre class="programlisting">int xmlIsMainThread (void)<br />
</pre><p>xmlIsMainThread() check whether the current thread is the main thread.</p>
-<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if the current thread is the main thread, 0 otherwise</td></tr></tbody></table></div><h3><a name="xmlLockLibrary" id="xmlLockLibrary"></a>Function: xmlLockLibrary</h3><pre class="programlisting">void xmlLockLibrary (void)<br />
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if the current thread is the main thread, 0 otherwise</td></tr></tbody></table></div><h3><a name="xmlIsThreadsEnabled" id="xmlIsThreadsEnabled"></a>Function: xmlIsThreadsEnabled</h3><pre class="programlisting">int xmlIsThreadsEnabled (void)<br />
+</pre><p>Run-time information about whether multithread support is compiled in</p>
+<div class="variablelist"><table border="0"><col align="left" /><tbody><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 (true) if library was compiled with multithread support enabled or 0 (false) otherwise.</td></tr></tbody></table></div><h3><a name="xmlLockLibrary" id="xmlLockLibrary"></a>Function: xmlLockLibrary</h3><pre class="programlisting">void xmlLockLibrary (void)<br />
</pre><p>xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 library.</p>
<h3><a name="xmlMutexLock" id="xmlMutexLock"></a>Function: xmlMutexLock</h3><pre class="programlisting">void xmlMutexLock (<a href="libxml-threads.html#xmlMutexPtr">xmlMutexPtr</a> tok)<br />
</pre><p>xmlMutexLock() is used to lock a libxml2 token.</p>
diff --git a/doc/libxml2-api.xml b/doc/libxml2-api.xml
index 74135d5..985677b 100644
--- a/doc/libxml2-api.xml
+++ b/doc/libxml2-api.xml
@@ -1329,6 +1329,7 @@
<exports symbol='xmlInitThreads' type='function'/>
<exports symbol='xmlUnlockLibrary' type='function'/>
<exports symbol='xmlFreeMutex' type='function'/>
+ <exports symbol='xmlIsThreadsEnabled' type='function'/>
</file>
<file name='tree'>
<summary>interfaces for tree manipulation</summary>
@@ -10254,6 +10255,10 @@
<arg name='elem' type='xmlNodePtr' info='the element carrying the attribute'/>
<arg name='attr' type='xmlAttrPtr' info='the attribute'/>
</function>
+ <function name='xmlIsThreadsEnabled' file='threads' module='threads'>
+ <info>Run-time information about whether multithread support is compiled in</info>
+ <return type='int' info='1 (true) if library was compiled with multithread support enabled or 0 (false) otherwise.'/>
+ </function>
<function name='xmlIsXHTML' file='tree' module='xmlsave'>
<info>Try to find if the document correspond to an XHTML DTD</info>
<return type='int' info='1 if true, 0 if not and -1 in case of error'/>
diff --git a/doc/libxml2-refs.xml b/doc/libxml2-refs.xml
index 88ac06c..6ee67e4 100644
--- a/doc/libxml2-refs.xml
+++ b/doc/libxml2-refs.xml
@@ -2078,6 +2078,7 @@
<reference name='xmlIsPubidChar_ch' href='html/libxml-chvalid.html#xmlIsPubidChar_ch'/>
<reference name='xmlIsPubidChar_tab' href='html/libxml-chvalid.html#xmlIsPubidChar_tab'/>
<reference name='xmlIsRef' href='html/libxml-valid.html#xmlIsRef'/>
+ <reference name='xmlIsThreadsEnabled' href='html/libxml-threads.html#xmlIsThreadsEnabled'/>
<reference name='xmlIsXHTML' href='html/libxml-tree.html#xmlIsXHTML'/>
<reference name='xmlKeepBlanksDefault' href='html/libxml-parser.html#xmlKeepBlanksDefault'/>
<reference name='xmlKeepBlanksDefaultValue' href='html/libxml-globals.html#xmlKeepBlanksDefaultValue'/>
@@ -5553,6 +5554,7 @@
<ref name='xmlIsPubidChar_ch'/>
<ref name='xmlIsPubidChar_tab'/>
<ref name='xmlIsRef'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlIsXHTML'/>
<ref name='xmlKeepBlanksDefault'/>
<ref name='xmlKeepBlanksDefaultValue'/>
@@ -11540,6 +11542,7 @@
<ref name='xmlGetThreadId'/>
<ref name='xmlInitThreads'/>
<ref name='xmlIsMainThread'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlLockLibrary'/>
<ref name='xmlMutex'/>
<ref name='xmlMutexLock'/>
@@ -16930,6 +16933,9 @@
<ref name='xmlParseDocTypeDecl'/>
<ref name='xmlValidateRoot'/>
</word>
+ <word name='Run-time'>
+ <ref name='xmlIsThreadsEnabled'/>
+ </word>
<word name='Runic'>
<ref name='xmlUCSIsRunic'/>
</word>
@@ -18081,6 +18087,7 @@
<word name='about'>
<ref name='_xmlParserCtxt'/>
<ref name='xmlDebugDumpString'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlShellDir'/>
<ref name='xmlTextWriterWriteRawLen'/>
</word>
@@ -19752,6 +19759,7 @@
<ref name='xmlExpDump'/>
<ref name='xmlExpMaxToken'/>
<ref name='xmlGetLastError'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlPatterncompile'/>
<ref name='xmlRegexpCompile'/>
<ref name='xmlRegexpExec'/>
@@ -21300,6 +21308,7 @@
<ref name='xmlCatalogSetDebug'/>
</word>
<word name='enabled'>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlSaveFile'/>
<ref name='xmlSaveFormatFile'/>
</word>
@@ -23115,6 +23124,7 @@
<ref name='xmlDebugDumpNode'/>
<ref name='xmlDebugDumpNodeList'/>
<ref name='xmlDebugDumpOneNode'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlNanoFTPUpdateURL'/>
<ref name='xmlNanoHTTPFetch'/>
<ref name='xmlNanoHTTPMethod'/>
@@ -23748,6 +23758,7 @@
<ref name='xmlCleanupThreads'/>
<ref name='xmlInitThreads'/>
<ref name='xmlInitializeGlobalState'/>
+ <ref name='xmlIsThreadsEnabled'/>
<ref name='xmlLockLibrary'/>
<ref name='xmlModuleFree'/>
<ref name='xmlModuleOpen'/>
@@ -24429,6 +24440,9 @@
<word name='multiply'>
<ref name='xmlXPathMultValues'/>
</word>
+ <word name='multithread'>
+ <ref name='xmlIsThreadsEnabled'/>
+ </word>
<word name='multithreaded'>
<ref name='htmlInitAutoClose'/>
<ref name='xmlInitParser'/>
diff --git a/elfgcchack.h b/elfgcchack.h
index ca69dbf..eef3f9a 100644
--- a/elfgcchack.h
+++ b/elfgcchack.h
@@ -4695,6 +4695,16 @@
#endif
#endif
+#ifdef bottom_threads
+#undef xmlIsThreadsEnabled
+extern __typeof (xmlIsThreadsEnabled) xmlIsThreadsEnabled __attribute((alias("xmlIsThreadsEnabled__internal_alias")));
+#else
+#ifndef xmlIsThreadsEnabled
+extern __typeof (xmlIsThreadsEnabled) xmlIsThreadsEnabled__internal_alias __attribute((visibility("hidden")));
+#define xmlIsThreadsEnabled xmlIsThreadsEnabled__internal_alias
+#endif
+#endif
+
#ifdef bottom_xmlsave
#undef xmlIsXHTML
extern __typeof (xmlIsXHTML) xmlIsXHTML __attribute((alias("xmlIsXHTML__internal_alias")));
diff --git a/encoding.c b/encoding.c
index 16f03ac..c6cfe91 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1905,7 +1905,7 @@
case -2: {
char buf[50];
- snprintf(buf, 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
in->content[0], in->content[1],
in->content[2], in->content[3]);
buf[49] = 0;
@@ -2077,7 +2077,7 @@
* and continue the transcoding phase, hoping the error
* did not mangle the encoder state.
*/
- snprintf((char *) charref, sizeof(charref), "&#%d;", cur);
+ snprintf((char *) &charref[0], sizeof(charref), "&#%d;", cur);
xmlBufferShrink(in, len);
xmlBufferAddHead(in, charref, -1);
@@ -2085,7 +2085,7 @@
} else {
char buf[50];
- snprintf(buf, 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
in->content[0], in->content[1],
in->content[2], in->content[3]);
buf[49] = 0;
diff --git a/include/libxml/threads.h b/include/libxml/threads.h
index fb6b704..f954d16 100644
--- a/include/libxml/threads.h
+++ b/include/libxml/threads.h
@@ -36,7 +36,6 @@
#ifdef __cplusplus
extern "C" {
#endif
-
XMLPUBFUN xmlMutexPtr XMLCALL
xmlNewMutex (void);
XMLPUBFUN void XMLCALL
@@ -58,6 +57,8 @@
/*
* Library wide APIs.
*/
+XMLPUBFUN int XMLCALL
+ xmlIsThreadsEnabled(void);
XMLPUBFUN void XMLCALL
xmlInitThreads (void);
XMLPUBFUN void XMLCALL
diff --git a/parserInternals.c b/parserInternals.c
index 6ec8d4b..f3fcd6f 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -728,7 +728,7 @@
{
char buffer[150];
- snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+ snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
ctxt->input->cur[0], ctxt->input->cur[1],
ctxt->input->cur[2], ctxt->input->cur[3]);
__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
diff --git a/threads.c b/threads.c
index 90a461a..f1a5314 100644
--- a/threads.c
+++ b/threads.c
@@ -165,6 +165,24 @@
#endif
/**
+ * xmlIsThreadsEnabled:
+ *
+ * Run-time information about whether multithread support is compiled in
+ *
+ * Returns 1 (true) if library was compiled with multithread support
+ * enabled or 0 (false) otherwise.
+ */
+int
+xmlIsThreadsEnabled(void)
+{
+#ifdef LIBXML_THREAD_ENABLED
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+/**
* xmlNewMutex:
*
* xmlNewMutex() is used to allocate a libxml2 token struct for use in
diff --git a/win32/libxml2.def.src b/win32/libxml2.def.src
index f28a628..bf3cf76 100644
--- a/win32/libxml2.def.src
+++ b/win32/libxml2.def.src
@@ -996,6 +996,7 @@
xmlIsMixedElement
xmlIsPubidChar
xmlIsRef
+xmlIsThreadsEnabled
#ifdef LIBXML_HTML_ENABLED
xmlIsXHTML
#endif