Hi,
The attached patch adds support for the _wopen function in libmingwex. The
old static function vopen in mingwex/wince/open.c is split into vwopen,
taking a wchar_t string as a parameter, used by the new _wopen wrapper,
and a smaller function vopen that does the charset conversion and passes
the string on to vwopen.
// Martin
Index: mingw/include/io.h
===================================================================
--- mingw/include/io.h (revision 1345)
+++ mingw/include/io.h (working copy)
@@ -286,10 +286,10 @@
#if defined (__MSVCRT__) || defined (__COREDLL__)
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext(long, struct _wfinddata_t *);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
#endif
#if defined (__MSVCRT__)
_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
_CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
Index: mingw/include/wchar.h
===================================================================
--- mingw/include/wchar.h (revision 1345)
+++ mingw/include/wchar.h (working copy)
@@ -380,10 +380,10 @@
#if defined (__MSVCRT__) || defined (__COREDLL__)
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t*, struct _wfinddata_t *);
_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext (long, struct _wfinddata_t *);
+_CRTIMP int __cdecl __MINGW_NOTHROW _wopen (const wchar_t*, int, ...);
#endif
#if defined (__MSVCRT__)
_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink (const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wopen (const wchar_t*, int, ...);
_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen (const wchar_t*, int, int, ...);
_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wmktemp (wchar_t*);
_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64 (const wchar_t*, struct _wfinddatai64_t*);
Index: mingw/mingwex/wince/open.c
===================================================================
--- mingw/mingwex/wince/open.c (revision 1345)
+++ mingw/mingwex/wince/open.c (working copy)
@@ -4,19 +4,14 @@
#include <sys/stat.h>
static int
-vopen (const char *path, int oflag, va_list ap)
+vwopen (const wchar_t *wpath, int oflag, va_list ap)
{
- wchar_t wpath[MAX_PATH];
DWORD fileaccess;
DWORD fileshare;
DWORD filecreate;
DWORD fileattrib;
HANDLE hnd;
- size_t path_len = strlen (path);
- if (path_len >= MAX_PATH)
- return -1;
-
switch (oflag & (O_RDONLY | O_WRONLY | O_RDWR))
{
case O_RDONLY:
@@ -58,8 +53,6 @@
return -1;
}
- mbstowcs (wpath, path, path_len + 1);
-
fileshare = 0;
if (oflag & O_CREAT)
{
@@ -83,6 +76,20 @@
return (int) hnd;
}
+static int
+vopen (const char *path, int oflag, va_list ap)
+{
+ wchar_t wpath[MAX_PATH];
+
+ size_t path_len = strlen (path);
+ if (path_len >= MAX_PATH)
+ return -1;
+
+ mbstowcs (wpath, path, path_len + 1);
+
+ return vwopen (wpath, oflag, ap);
+}
+
int
_open (const char *path, int oflag, ...)
{
@@ -104,3 +111,14 @@
va_end (ap);
return ret;
}
+
+int
+_wopen (const wchar_t *path, int oflag, ...)
+{
+ va_list ap;
+ int ret;
+ va_start (ap, oflag);
+ ret = vwopen (path, oflag, ap);
+ va_end (ap);
+ return ret;
+}
------------------------------------------------------------------------------
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel