diff -rupN --no-dereference glib-2.66.7/gio/tests/org.gtk.test.gschema.override.orig glib-2.66.7-new/gio/tests/org.gtk.test.gschema.override.orig
--- glib-2.66.7/gio/tests/org.gtk.test.gschema.override.orig 2021-02-11 13:24:55.208942400 +0100
+++ glib-2.66.7-new/gio/tests/org.gtk.test.gschema.override.orig 1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-[org.gtk.test.per-desktop:GNOME-Classic]
-desktop = "GNOME Classic"
diff -rupN --no-dereference glib-2.66.7/gio/tests/org.gtk.test.gschema.xml.orig glib-2.66.7-new/gio/tests/org.gtk.test.gschema.xml.orig
--- glib-2.66.7/gio/tests/org.gtk.test.gschema.xml.orig 2021-02-11 13:24:55.208942400 +0100
+++ glib-2.66.7-new/gio/tests/org.gtk.test.gschema.xml.orig 1970-01-01 01:00:00.000000000 +0100
@@ -1,222 +0,0 @@
-<schemalist>
-
- <schema id="org.gtk.test" path="/tests/" gettext-domain="test">
- <key name="greeting" type="s">
- <default l10n="messages">"Hello, earthlings"</default>
- <summary>A greeting</summary>
- <description>
- Greeting of the invading martians
- </description>
- </key>
- <key name="farewell" type="s">
- <default l10n="messages">"So long"</default>
- </key>
-
- <child name='basic-types' schema='org.gtk.test.basic-types'/>
- <child name='complex-types' schema='org.gtk.test.complex-types'/>
- <child name='localized' schema='org.gtk.test.localized'/>
- </schema>
-
- <schema id="org.gtk.test.no-path">
- <key name="test-boolean" type="b">
- <default>true</default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.basic-types" path="/tests/basic-types/">
- <key name="test-boolean" type="b">
- <default>true</default>
- </key>
- <key name="test-byte" type="y">
- <default>25</default>
- </key>
- <key name="test-int16" type="n">
- <default>-1234</default>
- </key>
- <key name="test-uint16" type="q">
- <default>1234</default>
- </key>
- <key name="test-int32" type="i">
- <default>-123456</default>
- </key>
- <key name="test-uint32" type="u">
- <default>123456</default>
- </key>
- <key name="test-int64" type="x">
- <default>-123456789</default>
- </key>
- <key name="test-uint64" type="t">
- <default>123456789</default>
- </key>
- <key name="test-double" type="d">
- <default>123.456</default>
- </key>
- <key name="test-string" type="s">
- <default>"a string, it seems"</default>
- </key>
- <key name="test-objectpath" type="o">
- <default>"/a/object/path"</default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.complex-types" path="/tests/complex-types/">
- <key name="test-tuple" type="(s(ii))">
- <default>("one",(2,3))</default>
- </key>
- <key name="test-array" type="ai">
- <default>[0,1,2,3,4,5]</default>
- </key>
- <key name="test-dict" type="a{sau}">
- <default>
- {
- "AC": [0,0, 0,0,0,0,0,0],
- "IV": [0,0, 0,0,0,0,0,0]
- }
- </default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.localized" path="/tests/localized/" gettext-domain="test">
- <key name="error-message" type="s">
- <default l10n="messages">"Unnamed"</default>
- </key>
- <key name="backspace" type="s">
- <default l10n="messages" context="keyboard label">"BackSpace"</default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.binding" path="/tests/binding/">
- <key name="bool" type="b">
- <default>false</default>
- </key>
- <key name="anti-bool" type="b">
- <default>false</default>
- </key>
- <key name="byte" type="y">
- <default>0</default>
- </key>
- <key name="int16" type="n">
- <default>0</default>
- </key>
- <key name="uint16" type="q">
- <default>0</default>
- </key>
- <key name="int" type="i">
- <default>0</default>
- </key>
- <key name="uint" type="u">
- <default>0</default>
- </key>
- <key name="int64" type="x">
- <default>0</default>
- </key>
- <key name="uint64" type="t">
- <default>0</default>
- </key>
- <key name="double" type="d">
- <default>0</default>
- </key>
- <key name="string" type="s">
- <default>""</default>
- </key>
- <key name="chararray" type="ay">
- <default>[48, 49]</default>
- </key>
- <key name="strv" type="as">
- <default>[]</default>
- </key>
- <key name="enum" enum="org.gtk.test.TestEnum">
- <default>'foo'</default>
- </key>
- <key name="flags" flags="org.gtk.test.TestFlags">
- <default>['mourning', 'laughing']</default>
- </key>
- <key name="range" type='u'>
- <default>33</default>
- <range min="2" max="44"/>
- </key>
- </schema>
-
- <schema id='org.gtk.test.enums' path='/tests/enums/'>
- <key name='test' enum='org.gtk.test.TestEnum'>
- <default>'bar'</default>
- <aliases>
- <alias value='qux' target='quux'/>
- </aliases>
- </key>
- <key name='f-test' flags='org.gtk.test.TestFlags'>
- <default>[]</default>
- <aliases>
- <alias value='speaking' target='talking'/>
- </aliases>
- </key>
- </schema>
-
- <schema id='org.gtk.test.enums.direct' path='/tests/enums/'>
- <key name='f-test' type='as'>
- <default>[]</default>
- </key>
- <key name='test' type='s'>
- <default>'bar'</default>
- </key>
- </schema>
-
- <schema id='org.gtk.test.range' path='/tests/range/'>
- <key name='val' type='i'>
- <default>33</default>
- <range min='2' max='44'/>
- </key>
- </schema>
-
- <schema id='org.gtk.test.range.direct' path='/tests/range/'>
- <key name='val' type='i'>
- <default>33</default>
- </key>
- </schema>
-
- <schema id='org.gtk.test.mapped' path='/tests/mapped/'>
- <key name='val' type='i'>
- <default>0</default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.descriptions" path="/a/">
- <key name='a' type='i'>
- <summary>
- a paragraph.
-
- with some whitespace.
-
- because not everyone has a great editor.
-
-
-
-
- lots of space is as one.
- </summary>
- <default>0</default>
- </key>
- </schema>
-
- <schema id='org.gtk.test.extends.base'>
- <key name='int32' type='i'>
- <default>0</default>
- </key>
- <key name='string' type='s'>
- <default>''</default>
- </key>
- </schema>
- <schema id='org.gtk.test.extends.extended' extends='org.gtk.test.extends.base'>
- <override name="int32">42</override>
- <key name='another-int32' type='i'>
- <default>0</default>
- </key>
- </schema>
-
- <schema id="org.gtk.test.per-desktop" path="/tests/per-desktop/">
- <key name="desktop" type="s">
- <default>"GNOME"</default>
- </key>
- </schema>
-
-</schemalist>
diff -rupN --no-dereference glib-2.66.7/glib/gstdio.c glib-2.66.7-new/glib/gstdio.c
--- glib-2.66.7/glib/gstdio.c 2021-02-11 13:24:55.239942800 +0100
+++ glib-2.66.7-new/glib/gstdio.c 2021-03-05 23:02:21.918877448 +0100
@@ -1045,6 +1045,11 @@ g_open (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
+ HANDLE hFile;
+ DWORD dwDesiredAccess = 0;
+ DWORD dwFlagsAndAttributes = 0;
+ DWORD dwDisposition = OPEN_EXISTING;
+ DWORD dwSharedAccess = FILE_SHARE_READ | FILE_SHARE_DELETE;
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@@ -1055,12 +1060,114 @@ g_open (const gchar *filename,
return -1;
}
- retval = _wopen (wfilename, flags, mode);
- save_errno = errno;
+ /* Set up the access modes and other attributes */
+ if ((flags & _O_CREAT) && (mode & _S_IREAD))
+ {
+ if (! (mode & _S_IWRITE))
+ dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY; /* Sets file to 'read only' after the file gets closed */
+ }
+ if ( !(flags & _O_ACCMODE))
+ {
+ /* Equates to _O_RDONLY */
+ if (flags & _O_TRUNC)
+ {
+ errno = EINVAL;
+ g_free (wfilename);
+ return -1;
+ }
+
+ dwDesiredAccess |= GENERIC_READ;
+ dwSharedAccess |= FILE_SHARE_WRITE;
+ }
+ if (flags & _O_WRONLY)
+ {
+ if (flags & _O_RDWR)
+ {
+ errno = EINVAL;
+ g_free (wfilename);
+ return -1;
+ }
+
+ dwDesiredAccess |= GENERIC_WRITE;
+ }
+ if (flags & _O_RDWR)
+ {
+ dwDesiredAccess |= GENERIC_READ;
+ dwDesiredAccess |= GENERIC_WRITE;
+ }
+ if (flags & _O_TRUNC)
+ {
+ if (flags & _O_CREAT)
+ dwDisposition = CREATE_ALWAYS;
+ else
+ dwDisposition = TRUNCATE_EXISTING;
+ }
+ if ((flags & _O_CREAT) && !(flags & _O_TRUNC))
+ {
+ if (flags & _O_EXCL)
+ dwDisposition = CREATE_NEW;
+ else
+ dwDisposition = OPEN_ALWAYS;
+ }
+ if (flags & _O_CREAT)
+ {
+ /* Handle the other flags that can be attached to _O_CREAT */
+ if ((flags & _O_TEMPORARY) || (flags & _O_SHORT_LIVED))
+ dwFlagsAndAttributes |= FILE_ATTRIBUTE_TEMPORARY;
+
+ if (flags & _O_TEMPORARY)
+ dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE;
+ }
+ if ((flags & _O_SEQUENTIAL) || (flags & _O_APPEND))
+ {
+ dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
+ }
+ else if (flags & _O_RANDOM)
+ {
+ dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;
+ }
+
+ if (0 == dwFlagsAndAttributes)
+ dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
+ hFile = CreateFileW(wfilename, dwDesiredAccess, dwSharedAccess, NULL, dwDisposition, dwFlagsAndAttributes, NULL);
+
+ if (INVALID_HANDLE_VALUE == hFile)
+ {
+ retval = (-1);
+
+ switch (GetLastError ())
+ {
+#define CASE(a,b) case ERROR_##a: errno = b; break
+ CASE (FILE_NOT_FOUND, ENOENT);
+ CASE (PATH_NOT_FOUND, ENOENT);
+ CASE (ACCESS_DENIED, EACCES);
+ CASE (NOT_SAME_DEVICE, EXDEV);
+ CASE (LOCK_VIOLATION, EACCES);
+ CASE (SHARING_VIOLATION, EACCES);
+ CASE (FILE_EXISTS, EEXIST);
+ CASE (ALREADY_EXISTS, EEXIST);
+#undef CASE
+ default: errno = EIO;
+ }
+ }
+ else
+ retval = _open_osfhandle((long)hFile, flags);
- g_free (wfilename);
+ if ((-1) != retval)
+ {
+ /* We have a valid file handle. Set its translation mode to text or binary, as appropriate */
+ if ((!(flags & _O_TEXT)) && (_fmode == _O_BINARY))
+ _setmode(retval, _O_BINARY);
+ else if ((flags & _O_TEXT) || (_fmode == _O_TEXT))
+ _setmode(retval, _O_TEXT);
+ else
+ _setmode(retval, _O_BINARY);
+ }
+ save_errno = errno;
+ g_free (wfilename);
errno = save_errno;
+
return retval;
#else
int fd;
@@ -1108,6 +1215,8 @@ g_creat (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
+ HANDLE hFile;
+ DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@@ -1118,12 +1227,41 @@ g_creat (const gchar *filename,
return -1;
}
- retval = _wcreat (wfilename, mode);
- save_errno = errno;
+ if (mode & _S_IREAD)
+ {
+ if (! (mode & _S_IWRITE))
+ dwFlagsAndAttributes = FILE_ATTRIBUTE_READONLY; /* Sets file to 'read only' after the file gets closed */
+ }
+
+ hFile = CreateFileW(wfilename, (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_DELETE),
+ NULL, CREATE_ALWAYS, dwFlagsAndAttributes, NULL);
+
+ if (INVALID_HANDLE_VALUE == hFile)
+ {
+ retval = (-1);
+
+ switch (GetLastError ())
+ {
+#define CASE(a,b) case ERROR_##a: errno = b; break
+ CASE (FILE_NOT_FOUND, ENOENT);
+ CASE (PATH_NOT_FOUND, ENOENT);
+ CASE (ACCESS_DENIED, EACCES);
+ CASE (NOT_SAME_DEVICE, EXDEV);
+ CASE (LOCK_VIOLATION, EACCES);
+ CASE (SHARING_VIOLATION, EACCES);
+ CASE (FILE_EXISTS, EEXIST);
+ CASE (ALREADY_EXISTS, EEXIST);
+#undef CASE
+ default: errno = EIO;
+ }
+ }
+ else
+ retval = _open_osfhandle((long)hFile, _O_RDWR);
+ save_errno = errno;
g_free (wfilename);
-
errno = save_errno;
+
return retval;
#else
return creat (filename, mode);
@@ -1565,34 +1703,102 @@ g_fopen (const gchar *filename,
const gchar *mode)
{
#ifdef G_OS_WIN32
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- wchar_t *wmode;
- FILE *retval;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
-
- if (wmode == NULL)
- {
- g_free (wfilename);
- errno = EINVAL;
- return NULL;
- }
-
- _g_win32_fix_mode (wmode);
- retval = _wfopen (wfilename, wmode);
- save_errno = errno;
-
- g_free (wfilename);
- g_free (wmode);
-
- errno = save_errno;
+ int hFile;
+ int flags = 0;
+ gchar priv_mode[4];
+ FILE *retval = NULL;
+
+ if ((NULL == filename) || (NULL == mode))
+ {
+ errno = EINVAL;
+ goto out;
+ }
+ if ((strlen(mode) < 1) || (strlen(mode) > 3))
+ {
+ errno - EINVAL;
+ goto out;
+ }
+
+ strncpy(priv_mode, mode, 3);
+ priv_mode[3] = '\0';
+
+ /* Set up any flags to pass to 'g_open()' */
+ if (3 == strlen(priv_mode))
+ {
+ if (('c' == priv_mode[2]) || ('n' == priv_mode[2]))
+ priv_mode[2] = '\0';
+ else
+ {
+ if (0 == strcmp(priv_mode, "a+b"))
+ flags = _O_RDWR | _O_CREAT | _O_APPEND | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "a+t"))
+ flags = _O_RDWR | _O_CREAT | _O_APPEND | _O_TEXT;
+ else if (0 == strcmp(priv_mode, "r+b"))
+ flags = _O_RDWR | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "r+t"))
+ flags = _O_RDWR | _O_TEXT;
+ else if (0 == strcmp(priv_mode, "w+b"))
+ flags = _O_RDWR | _O_CREAT |_O_TRUNC | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "w+t"))
+ flags = _O_RDWR | _O_CREAT |_O_TRUNC | _O_TEXT;
+ else
+ {
+ errno = EINVAL;
+ goto out;
+ }
+ }
+ }
+ if (2 == strlen(priv_mode))
+ {
+ if (('c' == priv_mode[1]) || ('n' == priv_mode[1]))
+ priv_mode[1] = '\0';
+ else
+ {
+ if (0 == strcmp(priv_mode, "a+"))
+ flags = _O_RDWR | _O_CREAT | _O_APPEND;
+ else if (0 == strcmp(priv_mode, "ab"))
+ flags = _O_WRONLY | _O_CREAT | _O_APPEND | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "at"))
+ flags = _O_WRONLY | _O_CREAT | _O_APPEND | _O_TEXT;
+ else if (0 == strcmp(priv_mode, "rb"))
+ flags = _O_RDONLY | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "rt"))
+ flags = _O_RDONLY | _O_TEXT;
+ else if (0 == strcmp(priv_mode, "wb"))
+ flags = _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY;
+ else if (0 == strcmp(priv_mode, "wt"))
+ flags = _O_WRONLY | _O_CREAT | _O_TRUNC | _O_TEXT;
+ else
+ {
+ errno = EINVAL;
+ goto out;
+ }
+ }
+ }
+ if (1 == strlen(priv_mode))
+ {
+ if (0 == strcmp(priv_mode, "a"))
+ flags = _O_WRONLY | _O_CREAT | _O_APPEND;
+ else if (0 == strcmp(priv_mode, "r"))
+ flags = _O_RDONLY;
+ else if (0 == strcmp(priv_mode, "w"))
+ flags = _O_WRONLY | _O_CREAT | _O_TRUNC;
+ else if ( !((0 == strcmp(priv_mode, "c")) || (0 == strcmp(priv_mode, "n"))))
+ {
+ errno = EINVAL;
+ goto out;
+ }
+ }
+
+ hFile = g_open (filename, flags, (_S_IREAD | _S_IWRITE));
+
+ if (INVALID_HANDLE_VALUE == (HANDLE)hFile)
+ /* 'errno' will have already been set by 'g_open()' */
+ retval = NULL;
+ else
+ retval = _fdopen(hFile, mode);
+
+out:
return retval;
#else
return fopen (filename, mode);