mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-07-04 12:02:29 +03:00
Fix Windows compiler warnings
Fixes bug 788317. Thanks to J. Peter Mugaas for the initial patch.
This commit is contained in:
@ -121,12 +121,14 @@ exsltCryptoHex2Bin (const unsigned char *hex, int hexlen,
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wincrypt.h>
|
#include <wincrypt.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "advapi32.lib")
|
#pragma comment(lib, "advapi32.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exsltCryptoCryptoApiReportError (xmlXPathParserContextPtr ctxt,
|
exsltCryptoCryptoApiReportError (xmlXPathParserContextPtr ctxt,
|
||||||
int line) {
|
int line) {
|
||||||
LPVOID lpMsgBuf;
|
char *lpMsgBuf;
|
||||||
DWORD dw = GetLastError ();
|
DWORD dw = GetLastError ();
|
||||||
|
|
||||||
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
@ -143,7 +145,7 @@ exsltCryptoCryptoApiReportError (xmlXPathParserContextPtr ctxt,
|
|||||||
static HCRYPTHASH
|
static HCRYPTHASH
|
||||||
exsltCryptoCryptoApiCreateHash (xmlXPathParserContextPtr ctxt,
|
exsltCryptoCryptoApiCreateHash (xmlXPathParserContextPtr ctxt,
|
||||||
HCRYPTPROV hCryptProv, ALG_ID algorithm,
|
HCRYPTPROV hCryptProv, ALG_ID algorithm,
|
||||||
const char *msg, unsigned int msglen,
|
const unsigned char *msg, unsigned int msglen,
|
||||||
char *dest, unsigned int destlen)
|
char *dest, unsigned int destlen)
|
||||||
{
|
{
|
||||||
HCRYPTHASH hHash = 0;
|
HCRYPTHASH hHash = 0;
|
||||||
@ -154,12 +156,12 @@ exsltCryptoCryptoApiCreateHash (xmlXPathParserContextPtr ctxt,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CryptHashData (hHash, (const BYTE *) msg, msglen, 0)) {
|
if (!CryptHashData (hHash, msg, msglen, 0)) {
|
||||||
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
|
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CryptGetHashParam (hHash, HP_HASHVAL, dest, &dwHashLen, 0)) {
|
if (!CryptGetHashParam (hHash, HP_HASHVAL, (BYTE *) dest, &dwHashLen, 0)) {
|
||||||
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
|
exsltCryptoCryptoApiReportError (ctxt, __LINE__);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -194,8 +196,8 @@ exsltCryptoCryptoApiHash (xmlXPathParserContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hHash = exsltCryptoCryptoApiCreateHash (ctxt, hCryptProv,
|
hHash = exsltCryptoCryptoApiCreateHash (ctxt, hCryptProv,
|
||||||
algorithm, msg, msglen,
|
algorithm, (unsigned char *) msg,
|
||||||
dest, HASH_DIGEST_LENGTH);
|
msglen, dest, HASH_DIGEST_LENGTH);
|
||||||
if (0 != hHash) {
|
if (0 != hHash) {
|
||||||
CryptDestroyHash (hHash);
|
CryptDestroyHash (hHash);
|
||||||
}
|
}
|
||||||
@ -212,7 +214,7 @@ exsltCryptoCryptoApiRc4Encrypt (xmlXPathParserContextPtr ctxt,
|
|||||||
HCRYPTKEY hKey;
|
HCRYPTKEY hKey;
|
||||||
HCRYPTHASH hHash;
|
HCRYPTHASH hHash;
|
||||||
DWORD dwDataLen;
|
DWORD dwDataLen;
|
||||||
unsigned char hash[HASH_DIGEST_LENGTH];
|
char hash[HASH_DIGEST_LENGTH];
|
||||||
|
|
||||||
if (msglen > destlen) {
|
if (msglen > destlen) {
|
||||||
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
|
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
|
||||||
@ -263,7 +265,7 @@ exsltCryptoCryptoApiRc4Decrypt (xmlXPathParserContextPtr ctxt,
|
|||||||
HCRYPTKEY hKey;
|
HCRYPTKEY hKey;
|
||||||
HCRYPTHASH hHash;
|
HCRYPTHASH hHash;
|
||||||
DWORD dwDataLen;
|
DWORD dwDataLen;
|
||||||
unsigned char hash[HASH_DIGEST_LENGTH];
|
char hash[HASH_DIGEST_LENGTH];
|
||||||
|
|
||||||
if (msglen > destlen) {
|
if (msglen > destlen) {
|
||||||
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
|
xsltTransformError (xsltXPathGetTransformContext (ctxt), NULL,
|
||||||
|
@ -808,7 +808,8 @@ exsltDateCurrent (void)
|
|||||||
gmtime_r(&secs, &gmTm);
|
gmtime_r(&secs, &gmTm);
|
||||||
#else
|
#else
|
||||||
tb = gmtime(&secs);
|
tb = gmtime(&secs);
|
||||||
if (tb != NULL)
|
if (tb == NULL)
|
||||||
|
return NULL;
|
||||||
gmTm = *tb;
|
gmTm = *tb;
|
||||||
#endif
|
#endif
|
||||||
ret->tz_flag = 0;
|
ret->tz_flag = 0;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
@ -5872,7 +5873,8 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
|
|||||||
*/
|
*/
|
||||||
root = xmlDocGetRootElement(doc);
|
root = xmlDocGetRootElement(doc);
|
||||||
if (root != NULL) {
|
if (root != NULL) {
|
||||||
if (((long) root->content) >= 0 && (xslDebugStatus == XSLT_DEBUG_NONE))
|
if (((ptrdiff_t) root->content >= 0) &&
|
||||||
|
(xslDebugStatus == XSLT_DEBUG_NONE))
|
||||||
xmlXPathOrderDocElems(doc);
|
xmlXPathOrderDocElems(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ xsltNewLocale(const xmlChar *languageTag) {
|
|||||||
region = xsltDefaultRegion(localeName);
|
region = xsltDefaultRegion(localeName);
|
||||||
if (region == NULL) goto end;
|
if (region == NULL) goto end;
|
||||||
|
|
||||||
strcpy(localeName + llen + 1, region);
|
strcpy((char *) localeName + llen + 1, (char *) region);
|
||||||
locale = xslt_locale_WINAPI(localeName);
|
locale = xslt_locale_WINAPI(localeName);
|
||||||
end:
|
end:
|
||||||
return(locale);
|
return(locale);
|
||||||
@ -382,7 +382,7 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XSLT_LOCALE_WINAPI
|
#ifdef XSLT_LOCALE_WINAPI
|
||||||
xstrlen = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
|
xstrlen = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, NULL, 0);
|
||||||
if (xstrlen == 0) {
|
if (xstrlen == 0) {
|
||||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
|
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar check failed\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -392,7 +392,7 @@ xsltStrxfrm(xsltLocale locale, const xmlChar *string)
|
|||||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
|
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
r = MultiByteToWideChar(CP_UTF8, 0, string, -1, xstr, xstrlen);
|
r = MultiByteToWideChar(CP_UTF8, 0, (char *) string, -1, xstr, xstrlen);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
|
xsltTransformError(NULL, NULL, NULL, "xsltStrxfrm : MultiByteToWideChar failed\n");
|
||||||
xmlFree(xstr);
|
xmlFree(xstr);
|
||||||
@ -479,9 +479,11 @@ xsltIterateSupportedLocales(LPSTR lcid) {
|
|||||||
k = sscanf(lcid, "%lx", (long*)&p->lcid);
|
k = sscanf(lcid, "%lx", (long*)&p->lcid);
|
||||||
if (k < 1) goto end;
|
if (k < 1) goto end;
|
||||||
/*don't count terminating null character*/
|
/*don't count terminating null character*/
|
||||||
k = GetLocaleInfoA(p->lcid, LOCALE_SISO639LANGNAME , iso639lang , sizeof(iso639lang ));
|
k = GetLocaleInfoA(p->lcid, LOCALE_SISO639LANGNAME,
|
||||||
|
(char *) iso639lang, sizeof(iso639lang));
|
||||||
if (--k < 1) goto end;
|
if (--k < 1) goto end;
|
||||||
l = GetLocaleInfoA(p->lcid, LOCALE_SISO3166CTRYNAME, iso3136ctry, sizeof(iso3136ctry));
|
l = GetLocaleInfoA(p->lcid, LOCALE_SISO3166CTRYNAME,
|
||||||
|
(char *) iso3136ctry, sizeof(iso3136ctry));
|
||||||
if (--l < 1) goto end;
|
if (--l < 1) goto end;
|
||||||
|
|
||||||
{ /*fill results*/
|
{ /*fill results*/
|
||||||
|
@ -42,16 +42,9 @@
|
|||||||
#include "imports.h"
|
#include "imports.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
/* gettimeofday on Windows ??? */
|
|
||||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <winsock2.h>
|
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
|
||||||
#define gettimeofday(p1,p2)
|
|
||||||
#define HAVE_GETTIMEOFDAY
|
|
||||||
#define XSLT_WIN32_PERFORMANCE_COUNTER
|
#define XSLT_WIN32_PERFORMANCE_COUNTER
|
||||||
#endif /* _MS_VER */
|
#endif
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
@ -1811,6 +1804,8 @@ static long calibration = -1;
|
|||||||
*
|
*
|
||||||
* Returns the number of milliseconds used by xsltTimestamp()
|
* Returns the number of milliseconds used by xsltTimestamp()
|
||||||
*/
|
*/
|
||||||
|
#if !defined(XSLT_WIN32_PERFORMANCE_COUNTER) && \
|
||||||
|
(defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETTIMEOFDAY))
|
||||||
static long
|
static long
|
||||||
xsltCalibrateTimestamps(void) {
|
xsltCalibrateTimestamps(void) {
|
||||||
register int i;
|
register int i;
|
||||||
@ -1819,6 +1814,7 @@ xsltCalibrateTimestamps(void) {
|
|||||||
xsltTimestamp();
|
xsltTimestamp();
|
||||||
return(xsltTimestamp() / 1000);
|
return(xsltTimestamp() / 1000);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xsltCalibrateAdjust:
|
* xsltCalibrateAdjust:
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "libxslt-py.h"
|
#include "libxslt-py.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(vsnprintf)
|
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(vsnprintf)
|
||||||
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
|
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
|
||||||
@ -105,7 +106,7 @@ libxslt_xsltGetTransformContextHashCode(PyObject *self ATTRIBUTE_UNUSED, PyObjec
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tctxt = (xsltTransformContextPtr) PytransformCtxt_Get(py_tctxt);
|
tctxt = (xsltTransformContextPtr) PytransformCtxt_Get(py_tctxt);
|
||||||
hash_code = (long) tctxt;
|
hash_code = (ptrdiff_t) tctxt;
|
||||||
|
|
||||||
ret = PyInt_FromLong(hash_code);
|
ret = PyInt_FromLong(hash_code);
|
||||||
return ret;
|
return ret;
|
||||||
@ -142,7 +143,7 @@ libxslt_xsltGetStylesheetHashCode(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
style = (xsltStylesheetPtr) Pystylesheet_Get(py_style);
|
style = (xsltStylesheetPtr) Pystylesheet_Get(py_style);
|
||||||
hash_code = (long) style;
|
hash_code = (ptrdiff_t) style;
|
||||||
|
|
||||||
ret = PyInt_FromLong(hash_code);
|
ret = PyInt_FromLong(hash_code);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef _REENTRANT
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
|
#endif
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
|
|
||||||
#if defined(LIBXML_THREAD_ENABLED) && defined(HAVE_PTHREAD_H)
|
#if defined(LIBXML_THREAD_ENABLED) && defined(HAVE_PTHREAD_H)
|
||||||
|
@ -54,18 +54,11 @@
|
|||||||
|
|
||||||
#include <libexslt/exsltconfig.h>
|
#include <libexslt/exsltconfig.h>
|
||||||
|
|
||||||
#if defined(WIN32) && !defined (__CYGWIN__)
|
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
|
||||||
#include <winsock2.h>
|
|
||||||
#define gettimeofday(p1,p2)
|
|
||||||
#endif /* _MS_VER */
|
|
||||||
#else /* WIN32 */
|
|
||||||
#if defined(HAVE_SYS_TIME_H)
|
#if defined(HAVE_SYS_TIME_H)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#elif defined(HAVE_TIME_H)
|
#elif defined(HAVE_TIME_H)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIMEB_H
|
#ifdef HAVE_SYS_TIMEB_H
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
@ -595,7 +588,7 @@ main(int argc, char **argv)
|
|||||||
(!strcmp(argv[i], "--output"))) {
|
(!strcmp(argv[i], "--output"))) {
|
||||||
i++;
|
i++;
|
||||||
#if defined(WIN32) || defined (__CYGWIN__)
|
#if defined(WIN32) || defined (__CYGWIN__)
|
||||||
output = xmlCanonicPath(argv[i]);
|
output = (char *) xmlCanonicPath((xmlChar *) argv[i]);
|
||||||
if (output == NULL)
|
if (output == NULL)
|
||||||
#endif
|
#endif
|
||||||
output = (char *) xmlStrdup((xmlChar *) argv[i]);
|
output = (char *) xmlStrdup((xmlChar *) argv[i]);
|
||||||
|
Reference in New Issue
Block a user