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

Fix Windows compiler warnings in python/types.c

This commit is contained in:
Nick Wellnhofer
2022-09-04 16:41:43 +02:00
parent 71736b4e9a
commit 0d90125859
6 changed files with 48 additions and 52 deletions

View File

@@ -78,7 +78,6 @@ myInvalidParameterHandler(const wchar_t *expression,
FILE *
libxml_PyFileGet(PyObject *f) {
int flags;
FILE *res;
const char *mode;
int fd = PyObject_AsFileDescriptor(f);
@@ -112,8 +111,9 @@ libxml_PyFileGet(PyObject *f) {
if (hntdll == NULL)
return(NULL);
XML_IGNORE_FPTR_CAST_WARNINGS
NtQueryInformationFile = (t_NtQueryInformationFile)GetProcAddress(hntdll, "NtQueryInformationFile");
XML_POP_WARNINGS
if (NtQueryInformationFile != NULL &&
(NtQueryInformationFile((HANDLE)w_fh,
@@ -129,23 +129,24 @@ libxml_PyFileGet(PyObject *f) {
if (ai.AccessFlags & FILE_APPEND_DATA)
is_append = TRUE;
if (is_write && is_read)
if (is_append)
mode = "a+";
else
mode = "rw";
if (!is_write && is_read)
if (is_write) {
if (is_read) {
if (is_append)
mode = "a+";
else
mode = "rw";
} else {
if (is_append)
mode = "a";
else
mode = "w";
}
} else {
if (is_append)
mode = "r+";
else
mode = "r";
if (is_write && !is_read)
if (is_append)
mode = "a";
else
mode = "w";
}
}
FreeLibrary(hntdll);
@@ -153,6 +154,8 @@ libxml_PyFileGet(PyObject *f) {
if (!is_write && !is_read) /* also happens if we did not load or run NtQueryInformationFile() successfully */
return(NULL);
#else
int flags;
/*
* macOS returns O_RDWR for standard streams, but fails to write to
* stdout or stderr when opened with fdopen(dup_fd, "rw").