mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
Some improvements, being upstreamed. (must_use_null_useddefaultchar): New
2007-11-27 Tor Lillqvist <tml@novell.com> * glib/win_iconv.c: Some improvements, being upstreamed. (must_use_null_useddefaultchar): New function, checks for those codepages for which one must pass a NULL lpUsedDefaultChar pointer to WideCharToMultiByte(). (kernel_wctomb): Use it. (kernel_wctomb): Return with E2BIG immediately if bufsize is zero. svn path=/trunk/; revision=5945
This commit is contained in:
parent
007d3ad28a
commit
37f2dc3555
@ -1,3 +1,12 @@
|
|||||||
|
2007-11-27 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
* glib/win_iconv.c: Some improvements, being upstreamed.
|
||||||
|
(must_use_null_useddefaultchar): New function, checks for those
|
||||||
|
codepages for which one must pass a NULL lpUsedDefaultChar pointer
|
||||||
|
to WideCharToMultiByte().
|
||||||
|
(kernel_wctomb): Use it.
|
||||||
|
(kernel_wctomb): Return with E2BIG immediately if bufsize is zero.
|
||||||
|
|
||||||
2007-11-27 Tor Lillqvist <tml@novell.com>
|
2007-11-27 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* glib/gutils.c (_glib_get_locale_dir) [Win32]: Use either
|
* glib/gutils.c (_glib_get_locale_dir) [Win32]: Use either
|
||||||
|
@ -137,6 +137,7 @@ static int name_to_codepage(const char *name);
|
|||||||
static uint utf16_to_ucs4(const ushort *wbuf);
|
static uint utf16_to_ucs4(const ushort *wbuf);
|
||||||
static void ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize);
|
static void ucs4_to_utf16(uint wc, ushort *wbuf, int *wbufsize);
|
||||||
static int is_unicode(int codepage);
|
static int is_unicode(int codepage);
|
||||||
|
static int must_use_null_useddefaultchar(int codepage);
|
||||||
static void check_utf_bom(rec_iconv_t *cd, ushort *wbuf, int *wbufsize);
|
static void check_utf_bom(rec_iconv_t *cd, ushort *wbuf, int *wbufsize);
|
||||||
static char *strrstr(const char *str, const char *token);
|
static char *strrstr(const char *str, const char *token);
|
||||||
|
|
||||||
@ -1001,6 +1002,18 @@ is_unicode(int codepage)
|
|||||||
codepage == 65000 || codepage == 65001);
|
codepage == 65000 || codepage == 65001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
must_use_null_useddefaultchar(int codepage)
|
||||||
|
{
|
||||||
|
return (codepage == 65000 || codepage == 65001 ||
|
||||||
|
codepage == 50220 || codepage == 50221 ||
|
||||||
|
codepage == 50222 || codepage == 50225 ||
|
||||||
|
codepage == 50227 || codepage == 50229 ||
|
||||||
|
codepage == 52936 || codepage == 54936 ||
|
||||||
|
(codepage >= 57002 && codepage <= 57011) ||
|
||||||
|
codepage == 42);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_utf_bom(rec_iconv_t *cd, ushort *wbuf, int *wbufsize)
|
check_utf_bom(rec_iconv_t *cd, ushort *wbuf, int *wbufsize)
|
||||||
{
|
{
|
||||||
@ -1269,9 +1282,11 @@ kernel_wctomb(csconv_t *cv, ushort *wbuf, int wbufsize, uchar *buf, int bufsize)
|
|||||||
BOOL usedDefaultChar = 0;
|
BOOL usedDefaultChar = 0;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
if (bufsize == 0)
|
||||||
|
return_error(E2BIG);
|
||||||
len = WideCharToMultiByte(cv->codepage, 0,
|
len = WideCharToMultiByte(cv->codepage, 0,
|
||||||
(const wchar_t *)wbuf, wbufsize, (char *)buf, bufsize, NULL,
|
(const wchar_t *)wbuf, wbufsize, (char *)buf, bufsize, NULL,
|
||||||
(cv->codepage == 65000 || cv->codepage == 65001) ? NULL : &usedDefaultChar);
|
must_use_null_useddefaultchar(cv->codepage) ? NULL : &usedDefaultChar);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
Loading…
Reference in New Issue
Block a user