added qse_sio_truncate(), qse_sio_seek(),
changed qse_sio_getpos() to flush first. renamed qse_Xio_purge() to qse_Xio_drain().
This commit is contained in:
@ -3,7 +3,6 @@
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/fmt.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
|
||||
#include <locale.h>
|
||||
@ -110,7 +109,7 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/fmt.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
#include <locale.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -160,7 +159,7 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <qse/cmn/sio.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/mem.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
@ -9,9 +8,11 @@
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
static qse_sio_t* g_out;
|
||||
|
||||
#define R(f) \
|
||||
do { \
|
||||
qse_printf (QSE_T("== %s ==\n"), QSE_T(#f)); \
|
||||
qse_sio_putstrf (g_out, QSE_T("== %s ==\n"), QSE_T(#f)); \
|
||||
if (f() == -1) return -1; \
|
||||
} while (0)
|
||||
|
||||
@ -57,7 +58,8 @@ static int test1 (void)
|
||||
x[1] = unistr;
|
||||
x[2] = unistr2;
|
||||
|
||||
sio = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_NOAUTOFLUSH);
|
||||
sio = qse_sio_openstd (QSE_MMGR_GETDFL(), 0,
|
||||
QSE_SIO_STDOUT, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_NOAUTOFLUSH);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
|
||||
for (i = 0; i < QSE_COUNTOF(x); i++)
|
||||
@ -74,16 +76,16 @@ static int test2 (void)
|
||||
{
|
||||
/* this file is in utf8, the following strings may not be shown properly
|
||||
* if your locale/codepage is not utf8 */
|
||||
const qse_mchar_t* x[] =
|
||||
{
|
||||
QSE_MT("\0\0\0"),
|
||||
QSE_MT("이거슨"),
|
||||
QSE_MT("뭐냐이거"),
|
||||
QSE_MT("過去一個月"),
|
||||
QSE_MT("是成功的建商"),
|
||||
QSE_MT("뛰어 올라봐. 멀리멀리 잘난척하기는"),
|
||||
QSE_MT("Fly to the universe")
|
||||
};
|
||||
const qse_mchar_t* x[] =
|
||||
{
|
||||
QSE_MT("\0\0\0"),
|
||||
QSE_MT("이거슨"),
|
||||
QSE_MT("뭐냐이거"),
|
||||
QSE_MT("過去一個月"),
|
||||
QSE_MT("是成功的建商"),
|
||||
QSE_MT("뛰어 올라봐. 멀리멀리 잘난척하기는"),
|
||||
QSE_MT("Fly to the universe")
|
||||
};
|
||||
int i;
|
||||
qse_sio_t* sio;
|
||||
|
||||
@ -104,20 +106,21 @@ static int test3 (void)
|
||||
{
|
||||
/* this file is in utf8, the following strings may not be shown properly
|
||||
* if your locale/codepage is not utf8 */
|
||||
const qse_mchar_t* x[] =
|
||||
{
|
||||
QSE_MT("\0\0\0"),
|
||||
QSE_MT("이거슨"),
|
||||
QSE_MT("뭐냐이거"),
|
||||
QSE_MT("過去一個月"),
|
||||
QSE_MT("是成功的建商"),
|
||||
QSE_MT("뛰어 올라봐. 멀리멀리 잘난척하기는"),
|
||||
QSE_MT("Fly to the universe")
|
||||
};
|
||||
const qse_mchar_t* x[] =
|
||||
{
|
||||
QSE_MT("\0\0\0"),
|
||||
QSE_MT("이거슨"),
|
||||
QSE_MT("뭐냐이거"),
|
||||
QSE_MT("過去一個月"),
|
||||
QSE_MT("是成功的建商"),
|
||||
QSE_MT("뛰어 올라봐. 멀리멀리 잘난척하기는"),
|
||||
QSE_MT("Fly to the universe")
|
||||
};
|
||||
int i;
|
||||
qse_sio_t* sio;
|
||||
|
||||
sio = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_NOAUTOFLUSH);
|
||||
sio = qse_sio_openstd (QSE_MMGR_GETDFL(), 0,
|
||||
QSE_SIO_STDOUT, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_NOAUTOFLUSH);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
|
||||
for (i = 0; i < QSE_COUNTOF(x); i++)
|
||||
@ -130,6 +133,37 @@ static int test3 (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test4 (void)
|
||||
{
|
||||
qse_sio_t* sio;
|
||||
qse_sio_pos_t pos;
|
||||
|
||||
sio = qse_sio_open (QSE_MMGR_GETDFL(), 0, QSE_T("sio03.txt"),
|
||||
QSE_SIO_WRITE | QSE_SIO_READ | QSE_SIO_TRUNCATE | QSE_SIO_CREATE);
|
||||
if (sio == QSE_NULL) return -1;
|
||||
|
||||
qse_sio_putstr (sio, QSE_T("이거 좋다. this is good"));
|
||||
qse_sio_getpos (sio, &pos);
|
||||
qse_sio_putstrf (g_out, QSE_T("position = %lld\n"), (long long int)pos);
|
||||
|
||||
qse_sio_setpos (sio, pos - 2);
|
||||
qse_sio_putstrf (sio, QSE_T("wonderful"));
|
||||
|
||||
qse_sio_getpos (sio, &pos);
|
||||
qse_sio_truncate (sio, pos - 2);
|
||||
|
||||
pos = 0;
|
||||
qse_sio_seek (sio, &pos, QSE_SIO_BEGIN);
|
||||
qse_sio_putstr (sio, QSE_T("오홍"));
|
||||
|
||||
qse_sio_putstrf (g_out, QSE_T("position returned by seek = %lld\n"), (long long int)pos);
|
||||
qse_sio_getpos (sio, &pos);
|
||||
qse_sio_putstrf (g_out, QSE_T("position returned by getpos = %lld\n"), (long long int)pos);
|
||||
|
||||
qse_sio_close (sio);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
@ -152,13 +186,18 @@ int main ()
|
||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||
#endif
|
||||
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
g_out = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, QSE_SIO_WRITE | QSE_SIO_IGNOREMBWCERR);
|
||||
|
||||
qse_sio_putstr (g_out, QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
qse_sio_putstr (g_out, QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
||||
qse_sio_putstr (g_out, QSE_T("--------------------------------------------------------------------------------\n"));
|
||||
|
||||
R (test1);
|
||||
R (test2);
|
||||
R (test3);
|
||||
R (test4);
|
||||
|
||||
qse_sio_close (g_out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user