added solaris workaround for mbrlen bug.

enhanced socket libarary detection in configure.ac
This commit is contained in:
2012-01-10 15:05:40 +00:00
parent 70090bc117
commit a3eed193d5
52 changed files with 482 additions and 129 deletions

View File

@ -172,8 +172,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@

View File

@ -216,8 +216,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@

View File

@ -83,7 +83,7 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -92,13 +92,14 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc,argv,awk_main);
}

View File

@ -110,7 +110,7 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -119,12 +119,12 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc,argv,awk_main);

View File

@ -155,7 +155,7 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -164,12 +164,12 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc,argv,awk_main);

View File

@ -296,8 +296,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@

View File

@ -17,12 +17,15 @@
} while (0)
/* the texts here are all in utf-8. you will see many errors
* on a non-utf8 locale */
static int test1 (void)
{
int i;
const qse_mchar_t* x[] =
{
QSE_MT(""),
QSE_MT("This is good."),
QSE_MT("이거슨"),
QSE_MT("뭐냐이거"),
QSE_MT("過去一個月"),
@ -83,6 +86,7 @@ static int test2 (void)
const qse_mchar_t* x[] =
{
QSE_MT("\0\0\0"),
QSE_MT("This is good."),
QSE_MT("이거슨"),
QSE_MT("뭐냐이거"),
QSE_MT("過去一個月"),
@ -107,10 +111,12 @@ static int test2 (void)
while (j < k)
{
int y;
wlen = QSE_COUNTOF(buf);
mlen = k - j;
int y = qse_mbsntowcsn (&x[i][j], &mlen, buf, &wlen);
y = qse_mbsntowcsn (&x[i][j], &mlen, buf, &wlen);
if (y <= -1 && y != -2)
@ -148,6 +154,7 @@ static int test3 (void)
const qse_mchar_t* x[] =
{
QSE_MT(""),
QSE_MT("This is good."),
QSE_MT("이거슨"),
QSE_MT("뭐냐이거"),
QSE_MT("過去一個月"),
@ -180,6 +187,7 @@ static int test4 (void)
const qse_mchar_t* x[] =
{
QSE_MT("\0\0\0"),
QSE_MT("This is good."),
QSE_MT("이거슨"),
QSE_MT("뭐냐이거"),
QSE_MT("過去一個月"),
@ -206,17 +214,22 @@ static int test4 (void)
int main ()
{
#if defined(_WIN32)
char codepage[100];
UINT old_cp = GetConsoleOutputCP();
SetConsoleOutputCP (CP_UTF8);
/* TODO: on windows this set locale only affects those mbcs fucntions in clib.
* it doesn't support utf8 i guess find a working way. the following won't work
sprintf (codepage, ".%d", GetACP());
setlocale (LC_ALL, codepage);
*/
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
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
@ -228,8 +241,5 @@ int main ()
R (test3);
R (test4);
#if defined(_WIN32)
SetConsoleOutputCP (old_cp);
#endif
return 0;
}

View File

@ -149,7 +149,7 @@ static int test2 (void)
qse_printf (QSE_T("Converting %d wide-character - "), (int)len);
wlen = len;
n = qse_wcsntombsn (&x[i][j], &wlen, QSE_NULL, &mlen);
n = qse_wcsntombsn (x[i], &wlen, QSE_NULL, &mlen);
if (n == -1)
{
qse_printf (QSE_T("***illegal character[mlen=%d/wlen=%d]*** ["), (int)mlen, (int)wlen);
@ -294,17 +294,22 @@ static int test4 (void)
int main ()
{
#if defined(_WIN32)
char codepage[100];
UINT old_cp = GetConsoleOutputCP();
SetConsoleOutputCP (CP_UTF8);
/* TODO: on windows this set locale only affects those mbcs fucntions in clib.
* it doesn't support utf8 i guess find a working way. the following won't work
sprintf (codepage, ".%d", GetACP());
setlocale (LC_ALL, codepage);
*/
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
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
@ -316,8 +321,5 @@ int main ()
R (test3);
R (test4);
#if defined(_WIN32)
SetConsoleOutputCP (old_cp);
#endif
return 0;
}

View File

@ -5,6 +5,7 @@
#include <qse/cmn/stdio.h>
#include <locale.h>
#include <wchar.h>
#if defined(_WIN32)
# include <windows.h>
@ -29,6 +30,15 @@ static int test2 (void)
{
"\0",
"뛰어 올라봐", /* this text is in utf8. so some conversions fail on a non-utf8 locale */
#if defined(QSE_ENDIAN_BIG)
/* this text is in cp949. 뛰어올라봐 */
"\xD9\xB6\xEE\xBE \xC3\xBF\xF3\xB6\xC1\xBA",
#elif defined(QSE_ENDIAN_LITTLE)
/* this text is in cp949. 뛰어올라봐 */
"\xB6\xD9\xBE\xEE \xBF\xC3\xB6\xF3\xBA\xC1",
#else
# error ENDIAN UNKNOWN
#endif
"Fly to the universe"
};
@ -43,11 +53,26 @@ static int test2 (void)
qse_printf (QSE_T("["));
while (j < k)
{
qse_size_t y = qse_slmblen (&x[i][j], k-j);
mbstate_t state;
qse_size_t y, ym, ymr;
y = qse_slmblen (&x[i][j], k-j);
ym = mblen (&x[i][j], k-j);
memset (&state, 0, sizeof(state));
ymr = mbrlen (&x[i][j], k-j, &state);
if (ym != ymr)
{
/* if this line is shown, the c runtime library is buggy.
* note that i assume we handle stateless encoding only
* since the state is initlized to 0 above all the time */
qse_printf (QSE_T("***buggy clib [mblen=%d],[mbrlen=%d]***"), (int)ym, (int)ymr);
}
if (y == 0)
{
qse_printf (QSE_T("***illegal sequence***"));
qse_printf (QSE_T("***illegal sequence[y=%d][ym=%d][ymr=%d]***"), (int)y, (int)ym, (int)ymr);
break;
}
else if (y > k-j)

View File

@ -156,8 +156,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@

View File

@ -20,8 +20,14 @@
#include <qse/cut/std.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/stdio.h>
#include <locale.h>
#if defined(_WIN32)
# include <windows.h>
#endif
void print_usage (QSE_FILE* s, const qse_char_t* argv0)
{
qse_fprintf (s, QSE_T("USAGE: %s selector [input-file [output-file]]\n"), argv0);
@ -74,6 +80,24 @@ oops:
int qse_main (int argc, qse_achar_t* argv[])
{
#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
return qse_runmain (argc, argv, cut_main);
}

View File

@ -8,7 +8,7 @@ AM_CPPFLAGS = \
bin_PROGRAMS = http01
LDFLAGS += -L../../lib/cmn -L../../lib/net
LDADD = -lqsenet -lqsecmn $(PTHREAD_LIBS) $(SOCKET_LIBS)
LDADD = -lqsenet -lqsecmn $(PTHREAD_LIBS) $(SOCKET_LIBS) $(SENDFILE_LIBS)
http01_SOURCES = http01.c

View File

@ -55,7 +55,8 @@ am_http01_OBJECTS = http01.$(OBJEXT)
http01_OBJECTS = $(am_http01_OBJECTS)
http01_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
http01_DEPENDENCIES = $(am__DEPENDENCIES_1)
http01_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__depfiles_maybe = depfiles
@ -156,8 +157,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@
@ -221,7 +224,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(includedir)
LDADD = -lqsenet -lqsecmn $(PTHREAD_LIBS) $(SOCKET_LIBS)
LDADD = -lqsenet -lqsecmn $(PTHREAD_LIBS) $(SOCKET_LIBS) $(SENDFILE_LIBS)
http01_SOURCES = http01.c
all: all-am

View File

@ -177,8 +177,10 @@ RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
VERSION = @VERSION@

View File

@ -71,7 +71,7 @@ oops:
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -80,15 +80,14 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc, argv, sed_main);
}

View File

@ -79,7 +79,7 @@ int sed_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -88,12 +88,12 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc, argv, sed_main);

View File

@ -94,7 +94,7 @@ int sed_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
@ -103,12 +103,12 @@ int qse_main (int argc, qse_achar_t* argv[])
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgr (qse_slmbcmgr);
}
#else
setlocale (LC_ALL, "");
setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr);
#endif
return qse_runmain (argc, argv, sed_main);