Cygwin: pty: Drop handling for UTF-7 in convert_mb_str().
- Charset conversion for UTF-7, ISO-2022 and ISCII, which are not supported in cygwin, does not work properly as a result. At the expense of the above, the code has been simplified a bit.
This commit is contained in:
parent
f4a1b6ae18
commit
2ed80d04f4
|
@ -122,17 +122,9 @@ convert_mb_str (UINT cp_to, char *ptr_to, size_t *len_to,
|
||||||
UINT cp_from, const char *ptr_from, size_t len_from,
|
UINT cp_from, const char *ptr_from, size_t len_from,
|
||||||
mbstate_t *mbp)
|
mbstate_t *mbp)
|
||||||
{
|
{
|
||||||
size_t nlen;
|
|
||||||
tmp_pathbuf tp;
|
tmp_pathbuf tp;
|
||||||
wchar_t *wbuf = tp.w_get ();
|
wchar_t *wbuf = tp.w_get ();
|
||||||
int wlen = 0;
|
int wlen = 0;
|
||||||
if (cp_from == CP_UTF7)
|
|
||||||
/* MB_ERR_INVALID_CHARS does not work properly for UTF-7.
|
|
||||||
Therefore, just convert string without checking */
|
|
||||||
wlen = MultiByteToWideChar (cp_from, 0, ptr_from, len_from,
|
|
||||||
wbuf, NT_MAX_PATH);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *tmpbuf = tp.c_get ();
|
char *tmpbuf = tp.c_get ();
|
||||||
memcpy (tmpbuf, mbp->__value.__wchb, mbp->__count);
|
memcpy (tmpbuf, mbp->__value.__wchb, mbp->__count);
|
||||||
if (mbp->__count + len_from > NT_MAX_PATH)
|
if (mbp->__count + len_from > NT_MAX_PATH)
|
||||||
|
@ -142,7 +134,7 @@ convert_mb_str (UINT cp_to, char *ptr_to, size_t *len_to,
|
||||||
mbp->__count = 0;
|
mbp->__count = 0;
|
||||||
int mblen = 0;
|
int mblen = 0;
|
||||||
for (const char *p = tmpbuf; p < tmpbuf + total_len; p += mblen)
|
for (const char *p = tmpbuf; p < tmpbuf + total_len; p += mblen)
|
||||||
/* Max bytes in multibyte char is 4. */
|
/* Max bytes in multibyte char supported is 4. */
|
||||||
for (mblen = 1; mblen <= 4; mblen ++)
|
for (mblen = 1; mblen <= 4; mblen ++)
|
||||||
{
|
{
|
||||||
/* Try conversion */
|
/* Try conversion */
|
||||||
|
@ -170,10 +162,8 @@ convert_mb_str (UINT cp_to, char *ptr_to, size_t *len_to,
|
||||||
}
|
}
|
||||||
/* Retry conversion with extended length */
|
/* Retry conversion with extended length */
|
||||||
}
|
}
|
||||||
}
|
*len_to = WideCharToMultiByte (cp_to, 0, wbuf, wlen,
|
||||||
nlen = WideCharToMultiByte (cp_to, 0, wbuf, wlen,
|
|
||||||
ptr_to, *len_to, NULL, NULL);
|
ptr_to, *len_to, NULL, NULL);
|
||||||
*len_to = nlen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue