added solaris workaround for mbrlen bug.

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,12 @@
#include <qse/cmn/path.h> #include <qse/cmn/path.h>
#include <qse/cmn/stdio.h> #include <qse/cmn/stdio.h>
#include <qse/cmn/main.h> #include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
#include <locale.h>
#if defined(_WIN32)
# include <windows.h>
#endif
static qse_char_t* g_selector = QSE_NULL; static qse_char_t* g_selector = QSE_NULL;
@ -303,5 +309,24 @@ oops:
int qse_main (int argc, char* argv[]) int qse_main (int argc, char* 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); return qse_runmain (argc, argv, cut_main);
} }

View File

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

View File

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

View File

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

217
qse/configure vendored
View File

@ -762,6 +762,8 @@ PTHREAD_CFLAGS
PTHREAD_LIBS PTHREAD_LIBS
PTHREAD_CC PTHREAD_CC
ax_pthread_config ax_pthread_config
SENDFILE_LIBS
SOCKET_LIBS
ENABLE_CXX_FALSE ENABLE_CXX_FALSE
ENABLE_CXX_TRUE ENABLE_CXX_TRUE
BUILD_MODE BUILD_MODE
@ -5755,13 +5757,13 @@ if test "${lt_cv_nm_interface+set}" = set; then :
else else
lt_cv_nm_interface="BSD nm" lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:5758: $ac_compile\"" >&5) (eval echo "\"\$as_me:5760: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err) (eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5 cat conftest.err >&5
(eval echo "\"\$as_me:5761: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval echo "\"\$as_me:5763: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5 cat conftest.err >&5
(eval echo "\"\$as_me:5764: output\"" >&5) (eval echo "\"\$as_me:5766: output\"" >&5)
cat conftest.out >&5 cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin" lt_cv_nm_interface="MS dumpbin"
@ -6956,7 +6958,7 @@ ia64-*-hpux*)
;; ;;
*-*-irix6*) *-*-irix6*)
# Find out which ABI we are using. # Find out which ABI we are using.
echo '#line 6959 "configure"' > conftest.$ac_ext echo '#line 6961 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5 (eval $ac_compile) 2>&5
ac_status=$? ac_status=$?
@ -9012,11 +9014,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9015: $lt_compile\"" >&5) (eval echo "\"\$as_me:9017: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:9019: \$? = $ac_status" >&5 echo "$as_me:9021: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@ -9351,11 +9353,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9354: $lt_compile\"" >&5) (eval echo "\"\$as_me:9356: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:9358: \$? = $ac_status" >&5 echo "$as_me:9360: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@ -9456,11 +9458,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9459: $lt_compile\"" >&5) (eval echo "\"\$as_me:9461: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:9463: \$? = $ac_status" >&5 echo "$as_me:9465: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@ -9511,11 +9513,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:9514: $lt_compile\"" >&5) (eval echo "\"\$as_me:9516: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:9518: \$? = $ac_status" >&5 echo "$as_me:9520: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@ -11895,7 +11897,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11898 "configure" #line 11900 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -11991,7 +11993,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11994 "configure" #line 11996 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -13947,11 +13949,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:13950: $lt_compile\"" >&5) (eval echo "\"\$as_me:13952: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err) (eval "$lt_compile" 2>conftest.err)
ac_status=$? ac_status=$?
cat conftest.err >&5 cat conftest.err >&5
echo "$as_me:13954: \$? = $ac_status" >&5 echo "$as_me:13956: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output. # So say no if there are warnings other than the usual output.
@ -14046,11 +14048,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14049: $lt_compile\"" >&5) (eval echo "\"\$as_me:14051: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:14053: \$? = $ac_status" >&5 echo "$as_me:14055: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@ -14098,11 +14100,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'` -e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14101: $lt_compile\"" >&5) (eval echo "\"\$as_me:14103: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err) (eval "$lt_compile" 2>out/conftest.err)
ac_status=$? ac_status=$?
cat out/conftest.err >&5 cat out/conftest.err >&5
echo "$as_me:14105: \$? = $ac_status" >&5 echo "$as_me:14107: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext if (exit $ac_status) && test -s out/conftest2.$ac_objext
then then
# The compiler can only warn and ignore the option if not recognized # The compiler can only warn and ignore the option if not recognized
@ -17068,13 +17070,76 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 OLDLIBS="$LIBS"
$as_echo_n "checking for socket in -lsocket... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
if test "${ac_cv_lib_socket_socket+set}" = set; then : $as_echo_n "checking for library containing gethostbyname... " >&6; }
if test "${ac_cv_search_gethostbyname+set}" = set; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_func_search_save_LIBS=$LIBS
LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostbyname ();
int
main ()
{
return gethostbyname ();
;
return 0;
}
_ACEOF
for ac_lib in '' nsl; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_gethostbyname=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if test "${ac_cv_search_gethostbyname+set}" = set; then :
break
fi
done
if test "${ac_cv_search_gethostbyname+set}" = set; then :
else
ac_cv_search_gethostbyname=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
$as_echo "$ac_cv_search_gethostbyname" >&6; }
ac_res=$ac_cv_search_gethostbyname
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_gethostbyname" != "none required" -a "$ac_cv_search_gethostbyname" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lnsl"
fi
OLDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
$as_echo_n "checking for library containing socket... " >&6; }
if test "${ac_cv_search_socket+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -17093,29 +17158,53 @@ return socket ();
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : for ac_lib in '' socket; do
ac_cv_lib_socket_socket=yes if test -z "$ac_lib"; then
ac_res="none required"
else else
ac_cv_lib_socket_socket=no ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_socket=$ac_res
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext
LIBS=$ac_check_lib_save_LIBS if test "${ac_cv_search_socket+set}" = set; then :
break
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 done
$as_echo "$ac_cv_lib_socket_socket" >&6; } if test "${ac_cv_search_socket+set}" = set; then :
if test "x$ac_cv_lib_socket_socket" = x""yes; then :
SOCKET_LIBS="-lsocket"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 else
$as_echo_n "checking for socket in -lsocket... " >&6; } ac_cv_search_socket=no
if test "${ac_cv_lib_socket_socket+set}" = set; then : fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
$as_echo "$ac_cv_search_socket" >&6; }
ac_res=$ac_cv_search_socket
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_socket" != "none required" -a "$ac_cv_search_socket" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
fi
OLDLIBS="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sendfile" >&5
$as_echo_n "checking for library containing sendfile... " >&6; }
if test "${ac_cv_search_sendfile+set}" = set; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_func_search_save_LIBS=$LIBS
LIBS="-lsocket -lnsl
$LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -17125,32 +17214,51 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
char socket (); char sendfile ();
int int
main () main ()
{ {
return socket (); return sendfile ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : for ac_lib in '' sendfile; do
ac_cv_lib_socket_socket=yes if test -z "$ac_lib"; then
ac_res="none required"
else else
ac_cv_lib_socket_socket=no ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_sendfile=$ac_res
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext
LIBS=$ac_check_lib_save_LIBS if test "${ac_cv_search_sendfile+set}" = set; then :
break
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 done
$as_echo "$ac_cv_lib_socket_socket" >&6; } if test "${ac_cv_search_sendfile+set}" = set; then :
if test "x$ac_cv_lib_socket_socket" = x""yes; then :
SOCKET_LIBS="-lsocket -lnsl" else
ac_cv_search_sendfile=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sendfile" >&5
$as_echo "$ac_cv_search_sendfile" >&6; }
ac_res=$ac_cv_search_sendfile
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi fi
LIBS="$OLDLIBS"
if test "$ac_cv_search_sendfile" != "none required" -a "$ac_cv_search_socket" != "no"
then
SENDFILE_LIBS="$SENDFILE_LIBS -lsendfile"
fi fi
@ -20294,5 +20402,6 @@ echo " Wide character: ${enable_wchar_is}"
echo " Math library: ${LIBM}" echo " Math library: ${LIBM}"
echo " Pthread library: ${PTHREAD_LIBS}" echo " Pthread library: ${PTHREAD_LIBS}"
echo " Socket library: ${SOCKET_LIBS}" echo " Socket library: ${SOCKET_LIBS}"
echo " Sendfile library: ${SENDFILE_LIBS}"
echo "-------------------------------------------------------------------------" echo "-------------------------------------------------------------------------"

View File

@ -220,13 +220,32 @@ AC_ARG_ENABLE([cxx], [AS_HELP_STRING([--enable-cxx],[build the library for C++ i
AM_CONDITIONAL(ENABLE_CXX, test "${enable_cxx_is}" = "yes" ) AM_CONDITIONAL(ENABLE_CXX, test "${enable_cxx_is}" = "yes" )
AC_CHECK_LIB([socket], [socket], [SOCKET_LIBS="-lsocket"], OLDLIBS="$LIBS"
[ AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_CHECK_LIB([socket], [socket], LIBS="$OLDLIBS"
[SOCKET_LIBS="-lsocket -lnsl"], [], [-lnsl] if test "$ac_cv_search_gethostbyname" != "none required" -a "$ac_cv_search_gethostbyname" != "no"
) then
] SOCKET_LIBS="$SOCKET_LIBS -lnsl"
) fi
OLDLIBS="$LIBS"
AC_SEARCH_LIBS([socket], [socket])
LIBS="$OLDLIBS"
if test "$ac_cv_search_socket" != "none required" -a "$ac_cv_search_socket" != "no"
then
SOCKET_LIBS="$SOCKET_LIBS -lsocket"
fi
AC_SUBST(SOCKET_LIBS)
OLDLIBS="$LIBS"
AC_SEARCH_LIBS([sendfile], [sendfile])
LIBS="$OLDLIBS"
if test "$ac_cv_search_sendfile" != "none required" -a "$ac_cv_search_socket" != "no"
then
SENDFILE_LIBS="$SENDFILE_LIBS -lsendfile"
fi
AC_SUBST(SENDFILE_LIBS)
AC_ARG_ENABLE([reentrant], [AS_HELP_STRING([--enable-reentrant],[define _REENTRANT (default. yes)])], AC_ARG_ENABLE([reentrant], [AS_HELP_STRING([--enable-reentrant],[define _REENTRANT (default. yes)])],
enable_reentrant_is=$enableval,enable_reentrant_is=yes) enable_reentrant_is=$enableval,enable_reentrant_is=yes)
@ -323,5 +342,6 @@ echo " Wide character: ${enable_wchar_is}"
echo " Math library: ${LIBM}" echo " Math library: ${LIBM}"
echo " Pthread library: ${PTHREAD_LIBS}" echo " Pthread library: ${PTHREAD_LIBS}"
echo " Socket library: ${SOCKET_LIBS}" echo " Socket library: ${SOCKET_LIBS}"
echo " Sendfile library: ${SENDFILE_LIBS}"
echo "-------------------------------------------------------------------------" echo "-------------------------------------------------------------------------"
] ]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -102,7 +102,6 @@ int qse_wcsntombsn (
const qse_wchar_t* wcs, qse_size_t* wcslen, const qse_wchar_t* wcs, qse_size_t* wcslen,
qse_mchar_t* mbs, qse_size_t* mbslen) qse_mchar_t* mbs, qse_size_t* mbslen)
{ {
return qse_wcsntombsnwithcmgr (wcs, wcslen, mbs, mbslen, dfl_cmgr); return qse_wcsntombsnwithcmgr (wcs, wcslen, mbs, mbslen, dfl_cmgr);
} }

View File

@ -120,6 +120,35 @@ qse_size_t qse_slmbrtoslwc (
} }
return dbcslen; return dbcslen;
#elif defined(__sun__) && defined(HAVE_MBRTOWC)
/*
* Read comments in qse_slmbrlen().
*/
size_t n;
QSE_ASSERT (mb != QSE_NULL);
QSE_ASSERT (mbl > 0);
if (wc)
{
n = mbrtowc (wc, mb, mbl, (mbstate_t*)state);
if (n == 0)
{
*wc = QSE_WT('\0');
return 1;
}
}
else
{
qse_wchar_t dummy;
n = mbrtowc (&dummy, mb, mbl, (mbstate_t*)state);
if (n == 0) return 1;
}
if (n == (size_t)-1) return 0; /* invalid sequence */
if (n == (size_t)-2) return mbl + 1; /* incomplete sequence */
return (qse_size_t)n;
#elif defined(HAVE_MBRTOWC) #elif defined(HAVE_MBRTOWC)
size_t n; size_t n;
@ -151,9 +180,50 @@ qse_size_t qse_slmbrlen (
QSE_ASSERT (mb != QSE_NULL); QSE_ASSERT (mb != QSE_NULL);
QSE_ASSERT (mbl > 0); QSE_ASSERT (mbl > 0);
/* IsDBCSLeadByte() or IsDBCSLeadByteEx() doesn't validate
* the actual sequence. So it can't actually detect an invalid
* sequence. Thus, qse_slmbrtowc() may return a different length
* for an invalid sequence form qse_slmbrlen(). */
dbcslen = IsDBCSLeadByteEx(CP_THREAD_ACP, *mb)? 2: 1; dbcslen = IsDBCSLeadByteEx(CP_THREAD_ACP, *mb)? 2: 1;
if (mbl < dbcslen) return mbl + 1; /* incomplete sequence */ if (mbl < dbcslen) return mbl + 1; /* incomplete sequence */
return dbcslen; return dbcslen;
#elif defined(__sun__) && defined(HAVE_MBRLEN)
/* on solaris 8,
* for a valid utf8 sequence on the utf8-locale,
* mbrlen() returned -1.
* mbrtowc(NULL, mbs, mbl, state) also returned -1.
* mblen() returned the right length.
* mbrtowc(wc, mbs, mbl, state) returned the right length.
* for a cp949 sequence on the cp949 locale,
* mbrlen() returned the right length.
* mbrtowc(NULL, mbs, mbl, state) returned the right length.
* mblen() returned the right length.
* mbrtowc(wc, mbs, mbl, state) returned the right length.
*
* The problem is buggy mbrlen() that can't handle utf8 sequence
* properly. here is my quick and dirty workaround for solaris.
*
* Newer solaris 9 and 10 or later should be also affected since
* i don't check any version or something.
*
* There could be other platforms with the same issue.
*/
/* TODO:
* it seems that solaris is not the only platform with
* this kind of a bug.
*
* checking this in autoconf doesn't solve the problem.
* the underlying system could have fixed the problem already.
*
* checking this during library initialization makes sense.
* qse_slmbinit() or qse_initlib() tests if mblen() and mbrlen()
* returns consistant results and arranges properly method
* for this slmb routine.
*/
return qse_slmbrtoslwc (mb, mbl, QSE_NULL, state);
#elif defined(HAVE_MBRLEN) #elif defined(HAVE_MBRLEN)
size_t n; size_t n;
@ -211,7 +281,7 @@ qse_size_t qse_slmblenmax (void)
#if defined(_WIN32) #if defined(_WIN32)
/* Windows doesn't handle utf8 properly even when your code page /* Windows doesn't handle utf8 properly even when your code page
* is CP_UTF8(65001). you should use functions in utf8.c for utf8 * is CP_UTF8(65001). you should use functions in utf8.c for utf8
* handleing on windows. */ * handleing on windows. 2 is the maximum for DBCS encodings. */
return 2; return 2;
#else #else
return MB_CUR_MAX; return MB_CUR_MAX;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -100,5 +100,6 @@ int qse_main (int argc, qse_achar_t* argv[])
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr); qse_setdflcmgr (qse_slmbcmgr);
#endif #endif
return qse_runmain (argc,argv,awk_main); return qse_runmain (argc,argv,awk_main);
} }

View File

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

View File

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

View File

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

View File

@ -5,6 +5,7 @@
#include <qse/cmn/stdio.h> #include <qse/cmn/stdio.h>
#include <locale.h> #include <locale.h>
#include <wchar.h>
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
@ -29,6 +30,15 @@ static int test2 (void)
{ {
"\0", "\0",
"뛰어 올라봐", /* this text is in utf8. so some conversions fail on a non-utf8 locale */ "뛰어 올라봐", /* 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" "Fly to the universe"
}; };
@ -43,11 +53,26 @@ static int test2 (void)
qse_printf (QSE_T("[")); qse_printf (QSE_T("["));
while (j < k) 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) 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; break;
} }
else if (y > k-j) else if (y > k-j)

View File

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

View File

@ -20,8 +20,14 @@
#include <qse/cut/std.h> #include <qse/cut/std.h>
#include <qse/cmn/main.h> #include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/stdio.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) 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); 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[]) 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); return qse_runmain (argc, argv, cut_main);
} }

View File

@ -8,7 +8,7 @@ AM_CPPFLAGS = \
bin_PROGRAMS = http01 bin_PROGRAMS = http01
LDFLAGS += -L../../lib/cmn -L../../lib/net 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 http01_SOURCES = http01.c

View File

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

View File

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

View File

@ -88,7 +88,6 @@ int qse_main (int argc, qse_achar_t* argv[])
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
qse_setdflcmgr (qse_slmbcmgr); qse_setdflcmgr (qse_slmbcmgr);
#endif #endif
return qse_runmain (argc, argv, sed_main); return qse_runmain (argc, argv, sed_main);
} }