mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-12 09:17:37 +03:00
574393 – utf-8 filename magic for compressed files
* xmlIO.c: windows specific magic to have UTF-8 file name work with compressed files too.
This commit is contained in:
parent
489f9671e7
commit
2ad41cad3e
54
xmlIO.c
54
xmlIO.c
@ -142,7 +142,7 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Tree memory error handler *
|
||||
* Tree memory error handler *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
@ -482,7 +482,7 @@ __xmlLoaderErr(void *ctx, const char *msg, const char *filename)
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Tree memory error handler *
|
||||
* Tree memory error handler *
|
||||
* *
|
||||
************************************************************************/
|
||||
/**
|
||||
@ -613,6 +613,32 @@ xmlWrapOpenUtf8(const char *path,int mode)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static gzFile
|
||||
xmlWrapGzOpenUtf8(const char *path, const char *mode)
|
||||
{
|
||||
gzFile fd;
|
||||
wchar_t *wPath;
|
||||
|
||||
fd = gzopen (path, mode);
|
||||
if (fd)
|
||||
return fd;
|
||||
|
||||
wPath = __xmlIOWin32UTF8ToWChar(path);
|
||||
if(wPath)
|
||||
{
|
||||
int d, m = (strstr(mode, "r") ? O_RDONLY : O_RDWR);
|
||||
#ifdef _O_BINARY
|
||||
m |= (strstr(mode, "b") ? _O_BINARY : 0);
|
||||
#endif
|
||||
d = _wopen(wPath, m);
|
||||
if (d >= 0)
|
||||
fd = gzdopen(d, mode);
|
||||
xmlFree(wPath);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlWrapStatUtf8:
|
||||
* @path: the path in utf-8 encoding
|
||||
@ -679,6 +705,8 @@ typedef int (* xmlWrapStatFunc) (const char *f, struct stat *s);
|
||||
static xmlWrapStatFunc xmlWrapStat = xmlWrapStatNative;
|
||||
typedef FILE* (* xmlWrapOpenFunc)(const char *f,int mode);
|
||||
static xmlWrapOpenFunc xmlWrapOpen = xmlWrapOpenNative;
|
||||
typedef gzFile (* xmlWrapGzOpenFunc) (const char *f, const char *mode);
|
||||
static xmlWrapGzOpenFunc xmlWrapGzOpen = gzopen;
|
||||
|
||||
/**
|
||||
* xmlInitPlatformSpecificIo:
|
||||
@ -699,9 +727,11 @@ xmlInitPlatformSpecificIo(void)
|
||||
if(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
|
||||
xmlWrapStat = xmlWrapStatUtf8;
|
||||
xmlWrapOpen = xmlWrapOpenUtf8;
|
||||
xmlWrapGzOpen = xmlWrapGzOpenUtf8;
|
||||
} else {
|
||||
xmlWrapStat = xmlWrapStatNative;
|
||||
xmlWrapOpen = xmlWrapOpenNative;
|
||||
xmlWrapGzOpen = gzopen;
|
||||
}
|
||||
|
||||
xmlPlatformIoInitialized = 1;
|
||||
@ -950,7 +980,7 @@ xmlFileOpenW (const char *filename) {
|
||||
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
|
||||
fd = xmlWrapOpen(path, 1);
|
||||
#else
|
||||
fd = fopen(path, "wb");
|
||||
fd = fopen(path, "wb");
|
||||
#endif /* WIN32 */
|
||||
|
||||
if (fd == NULL) xmlIOErr(0, path);
|
||||
@ -1132,7 +1162,11 @@ xmlGzfileOpen_real (const char *filename) {
|
||||
if (!xmlCheckFilename(path))
|
||||
return(NULL);
|
||||
|
||||
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
|
||||
fd = xmlWrapGzOpen(path, "rb");
|
||||
#else
|
||||
fd = gzopen(path, "rb");
|
||||
#endif
|
||||
return((void *) fd);
|
||||
}
|
||||
|
||||
@ -1200,7 +1234,11 @@ xmlGzfileOpenW (const char *filename, int compression) {
|
||||
if (path == NULL)
|
||||
return(NULL);
|
||||
|
||||
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
|
||||
fd = xmlWrapGzOpen(path, mode);
|
||||
#else
|
||||
fd = gzopen(path, mode);
|
||||
#endif
|
||||
return((void *) fd);
|
||||
}
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
@ -3142,7 +3180,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
||||
in->rawconsumed += (use - in->raw->use);
|
||||
} else {
|
||||
nbchars = len;
|
||||
in->buffer->use += nbchars;
|
||||
in->buffer->use += nbchars;
|
||||
buffer[nbchars] = 0;
|
||||
}
|
||||
#ifdef DEBUG_INPUT
|
||||
@ -3304,7 +3342,7 @@ xmlEscapeContent(unsigned char* out, int *outlen,
|
||||
inend = in + (*inlen);
|
||||
|
||||
while ((in < inend) && (out < outend)) {
|
||||
if (*in == '<') {
|
||||
if (*in == '<') {
|
||||
if (outend - out < 4) break;
|
||||
*out++ = '&';
|
||||
*out++ = 'l';
|
||||
@ -3897,9 +3935,9 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Disabling Network access *
|
||||
* *
|
||||
* *
|
||||
* Disabling Network access *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user