interim commit
- added wide-to-multibyte charater conversion in pio
This commit is contained in:
@ -173,17 +173,26 @@ qse_pio_t* qse_pio_init (
|
||||
|
||||
if (flags & QSE_PIO_SHELL)
|
||||
{
|
||||
const qse_mchar_t* mcmd;
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
const char* mcmd = cmd;
|
||||
mcmd = cmd;
|
||||
#else
|
||||
qse_size_t n, mn;
|
||||
const char mcmd[1024];
|
||||
|
||||
mn = QSE_COUNTOF (mcmd);
|
||||
n = qse_wcstombs (cmd, mcmd, &mn);
|
||||
n = qse_wcstombslen (cmd, &mn);
|
||||
if (cmd[n] != QSE_WT('\0'))
|
||||
{
|
||||
/* cmd has illegal sequence */
|
||||
goto child_oops;
|
||||
}
|
||||
|
||||
if (cmd[n] != QSE_WT('\0')) goto child_oops;
|
||||
if (mn >= QSE_COUNTOF(mcmd)) goto child_oops;
|
||||
mn = mn + 1;
|
||||
mcmd = QSE_MMGR_ALLOC (
|
||||
pio->mmgr, mn*QSE_SIZEOF(*mcmd));
|
||||
if (mcmd == QSE_NULL) goto child_oops;
|
||||
|
||||
n = qse_wcstombs (cmd, mcmd, &mn);
|
||||
|
||||
execl ("/bin/sh", "sh", "-c", mcmd, QSE_NULL);
|
||||
}
|
||||
|
@ -238,10 +238,13 @@ qse_size_t qse_wcstombslen (const qse_wchar_t* wcs, qse_size_t* mbslen)
|
||||
p++; mlen += n;
|
||||
}
|
||||
|
||||
/* this length excludes the terminating null character. */
|
||||
*mbslen = mlen;
|
||||
|
||||
/* returns the number of characters handled. */
|
||||
return p - wcs;
|
||||
/* returns the number of characters handled.
|
||||
* if the function has encountered an illegal character in
|
||||
* the while loop above, wcs[p-wcs] will not be a null character */
|
||||
return p - wcs;
|
||||
}
|
||||
|
||||
qse_size_t qse_wcsntombsn (
|
||||
|
Reference in New Issue
Block a user