fixed minor source glitches

This commit is contained in:
hyung-hwan 2012-04-30 10:03:55 +00:00
parent 31739d58f4
commit c1f46c95ff
5 changed files with 126 additions and 4 deletions

View File

@ -68,8 +68,8 @@ enum qse_tio_flag_t
QSE_TIO_NOAUTOFLUSH = (1 << 1), QSE_TIO_NOAUTOFLUSH = (1 << 1),
/* for internal use only. */ /* for internal use only. */
QSE_TIO_DYNINBUF = (1 << 30), QSE_TIO_DYNINBUF = (1 << 29),
QSE_TIO_DYNOUTBUF = (1 << 31) QSE_TIO_DYNOUTBUF = (1 << 30)
}; };
enum qse_tio_misc_t enum qse_tio_misc_t

View File

@ -257,7 +257,7 @@ static mancbs_t mancbs[] =
const mancbs_t* qse_gethtbmancbs (mancbs_kind_t kind) const mancbs_t* qse_gethtbmancbs (mancbs_kind_t kind)
{ {
return &mancbs[kind]; return &mancbs[kind];
}; }
htb_t* qse_htb_open ( htb_t* qse_htb_open (
mmgr_t* mmgr, size_t xtnsize, size_t capa, mmgr_t* mmgr, size_t xtnsize, size_t capa,

View File

@ -43,7 +43,9 @@ enum
union sockaddr_t union sockaddr_t
{ {
struct sockaddr_in in4; struct sockaddr_in in4;
#if defined(AF_INET6)
struct sockaddr_in6 in6; struct sockaddr_in6 in6;
#endif
}; };
static qse_ssize_t socket_input ( static qse_ssize_t socket_input (

View File

@ -195,7 +195,7 @@ static mancbs_t mancbs[] =
const mancbs_t* qse_getrbtmancbs (mancbs_kind_t kind) const mancbs_t* qse_getrbtmancbs (mancbs_kind_t kind)
{ {
return &mancbs[kind]; return &mancbs[kind];
}; }
rbt_t* qse_rbt_open (mmgr_t* mmgr, size_t xtnsize, int kscale, int vscale) rbt_t* qse_rbt_open (mmgr_t* mmgr, size_t xtnsize, int kscale, int vscale)
{ {

120
qse/samples/cmn/sio01.c Normal file
View File

@ -0,0 +1,120 @@
#include <qse/cmn/sio.h>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/fmt.h>
#include <qse/cmn/stdio.h>
#include <locale.h>
#if defined(_WIN32)
# include <windows.h>
#endif
static qse_sio_t* g_out;
#define R(f) \
do { \
qse_sio_putstr (g_out,QSE_T("== ")); \
qse_sio_putstr (g_out,QSE_T(#f)); \
qse_sio_putstr (g_out,QSE_T(" ==\n")); \
qse_sio_flush (g_out); \
if (f() == -1) return -1; \
} while (0)
static int test1 (void)
{
const qse_wchar_t unistr[] =
{
0x00A2,
/*L"\uB108 \uBB50\uAC00 \uC798\uB0AC\uC5B4!",*/
0xB108,
L' ',
0xBB50,
0xAC00,
L' ',
0xC798,
0xB0AC,
0xC5B4,
L'!',
L'\n',
L'\0'
};
qse_sio_t* out;
out = qse_sio_openstd (
QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT,
QSE_SIO_WRITE | QSE_SIO_IGNOREMBWCERR);
qse_sio_putwcs (out, unistr);
qse_sio_close (out);
return 0;
}
static int test2 (void)
{
const qse_wchar_t unistr[] =
{
0x00A2,
/*L"\uB108 \uBB50\uAC00 \uC798\uB0AC\uC5B4!",*/
0xB108,
L' ',
0xBB50,
0xAC00,
L' ',
0xC798,
0xB0AC,
0xC5B4,
L'!',
L'\n',
L'\0'
};
qse_mchar_t mbsbuf[100];
qse_sio_t* out;
qse_size_t wlen, mlen;
out = qse_sio_openstd (
QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT,
QSE_SIO_WRITE | QSE_SIO_IGNOREMBWCERR);
mlen = QSE_COUNTOF(mbsbuf);
qse_wcstombs (unistr, &wlen, mbsbuf, &mlen);
qse_sio_putmbs (out, mbsbuf);
qse_sio_close (out);
return 0;
}
int main ()
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgr (qse_utf8cmgr);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
g_out = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, QSE_SIO_WRITE | QSE_SIO_IGNOREMBWCERR);
R (test1);
R (test2);
qse_sio_close (g_out);
return 0;
}