diff --git a/qse/Makefile.in b/qse/Makefile.in index 9f7f3ccd..fcc923ad 100644 --- a/qse/Makefile.in +++ b/qse/Makefile.in @@ -217,6 +217,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/cmd/Makefile.in b/qse/cmd/Makefile.in index 65dcd734..0915aa9b 100644 --- a/qse/cmd/Makefile.in +++ b/qse/cmd/Makefile.in @@ -198,6 +198,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/cmd/awk/Makefile.in b/qse/cmd/awk/Makefile.in index 23768d99..42c74210 100644 --- a/qse/cmd/awk/Makefile.in +++ b/qse/cmd/awk/Makefile.in @@ -203,6 +203,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/cmd/http/Makefile.in b/qse/cmd/http/Makefile.in index 5d6a7d06..a0467e95 100644 --- a/qse/cmd/http/Makefile.in +++ b/qse/cmd/http/Makefile.in @@ -226,6 +226,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/cmd/sed/Makefile.in b/qse/cmd/sed/Makefile.in index b8c4d6ec..d81aea3f 100644 --- a/qse/cmd/sed/Makefile.in +++ b/qse/cmd/sed/Makefile.in @@ -197,6 +197,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/cmd/xli/Makefile.in b/qse/cmd/xli/Makefile.in index 2ac57cab..a016ba62 100644 --- a/qse/cmd/xli/Makefile.in +++ b/qse/cmd/xli/Makefile.in @@ -197,6 +197,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/configure b/qse/configure index f4e8e009..8e1970a5 100755 --- a/qse/configure +++ b/qse/configure @@ -667,6 +667,7 @@ SSL_LIBS UNICOWS_LIBS SENDFILE_LIBS SOCKET_LIBS +QUADMATH_LIBS LIBM WIN32_FALSE WIN32_TRUE @@ -17091,6 +17092,10 @@ case "$host" in *-*-mingw*|*-*-cygwin*) #CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0400" platform_win32=yes + ;; +*) + platform_win32=no + ;; esac if test "${platform_win32}" = "yes" ; then WIN32_TRUE= @@ -17442,7 +17447,7 @@ fi done -for ac_header in crt_externs.h sys/prctl.h uci.h +for ac_header in quadmath.h crt_externs.h sys/prctl.h uci.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -17661,6 +17666,117 @@ done LIBS="$OLDLIBS" +if test "${platform_win32}" = "no" +then + for ac_func in quadmath_snprintf +do : + ac_fn_c_check_func "$LINENO" "quadmath_snprintf" "ac_cv_func_quadmath_snprintf" +if test "x$ac_cv_func_quadmath_snprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_QUADMATH_SNPRINTF 1 +_ACEOF + +fi +done + + if test "$ac_cv_func_quadmath_snprintf" = "no" + then + OLDLIBS="$LIBS" + LIBS="$LIBM $LIBS" + for ac_func in quadmath_snprintf +do : + ac_fn_c_check_func "$LINENO" "quadmath_snprintf" "ac_cv_func_quadmath_snprintf" +if test "x$ac_cv_func_quadmath_snprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_QUADMATH_SNPRINTF 1 +_ACEOF + +fi +done + + LIBS="$OLDLIBS" + + if test "$ac_cv_func_quadmath_snprintf" = "no" + then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for quadmath_snprintf in -lquadmath" >&5 +$as_echo_n "checking for quadmath_snprintf in -lquadmath... " >&6; } +if ${ac_cv_lib_quadmath_quadmath_snprintf+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lquadmath $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 quadmath_snprintf (); +int +main () +{ +return quadmath_snprintf (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_quadmath_quadmath_snprintf=yes +else + ac_cv_lib_quadmath_quadmath_snprintf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_quadmath_quadmath_snprintf" >&5 +$as_echo "$ac_cv_lib_quadmath_quadmath_snprintf" >&6; } +if test "x$ac_cv_lib_quadmath_quadmath_snprintf" = xyes; then : + + QUADMATH_LIBS="-lquadmath" + LIBM="$LIBM -lquadmath" + $as_echo "#define HAVE_QUADMATH_SNPRINTF 1" >>confdefs.h + + +fi + + else + QUADMATH_LIBS="$LIBM" + fi + fi + + OLDLIBS="$LIBS" + LIBS="$LIBM $LIBS" + for ac_func in powq fmodq sinq cosq tanq atanq atan2q logq log10q expq sqrtq ceilq floorq roundq +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + for ac_func in strtoflt128 +do : + ac_fn_c_check_func "$LINENO" "strtoflt128" "ac_cv_func_strtoflt128" +if test "x$ac_cv_func_strtoflt128" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRTOFLT128 1 +_ACEOF + +fi +done + + LIBS="$OLDLIBS" +fi + + for ac_func in connect gethostbyname do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/qse/configure.ac b/qse/configure.ac index cdf76196..89403511 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -103,6 +103,10 @@ case "$host" in *-*-mingw*|*-*-cygwin*) #CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0400" platform_win32=yes + ;; +*) + platform_win32=no + ;; esac AM_CONDITIONAL(WIN32, test "${platform_win32}" = "yes" ) @@ -121,7 +125,7 @@ AC_CHECK_HEADERS([net/if.h net/if_dl.h], [], [], [ #include #include ]) AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h]) -AC_CHECK_HEADERS([crt_externs.h sys/prctl.h uci.h]) +AC_CHECK_HEADERS([quadmath.h crt_externs.h sys/prctl.h uci.h]) dnl check data types AC_CHECK_TYPE([wchar_t], @@ -152,6 +156,36 @@ AC_CHECK_FUNCS([pow fmod sin cos tan atan atan2 log log10 exp sqrt ceil floor ro AC_CHECK_FUNCS([powf fmodf sinf cosf tanf atanf atan2f logf log10f expf sqrtf ceilf floorf roundf]) LIBS="$OLDLIBS" +if test "${platform_win32}" = "no" +then + AC_CHECK_FUNCS([quadmath_snprintf]) + if test "$ac_cv_func_quadmath_snprintf" = "no" + then + OLDLIBS="$LIBS" + LIBS="$LIBM $LIBS" + AC_CHECK_FUNCS([quadmath_snprintf]) + LIBS="$OLDLIBS" + + if test "$ac_cv_func_quadmath_snprintf" = "no" + then + AC_CHECK_LIB([quadmath], [quadmath_snprintf], [ + QUADMATH_LIBS="-lquadmath" + LIBM="$LIBM -lquadmath" + AC_DEFINE(HAVE_QUADMATH_SNPRINTF, 1) + ]) + else + QUADMATH_LIBS="$LIBM" + fi + fi + + OLDLIBS="$LIBS" + LIBS="$LIBM $LIBS" + AC_CHECK_FUNCS([powq fmodq sinq cosq tanq atanq atan2q logq log10q expq sqrtq ceilq floorq roundq]) + AC_CHECK_FUNCS([strtoflt128]) + LIBS="$OLDLIBS" +fi +AC_SUBST(QUADMATH_LIBS) + dnl OLDLIBS="$LIBS" dnl AC_SEARCH_LIBS([connect], [socket]) dnl LIBS="$OLDLIBS" diff --git a/qse/doc/Makefile.in b/qse/doc/Makefile.in index 12334bb1..5a8c262b 100644 --- a/qse/doc/Makefile.in +++ b/qse/doc/Makefile.in @@ -162,6 +162,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/Makefile.in b/qse/include/Makefile.in index 3b53820f..532e11e9 100644 --- a/qse/include/Makefile.in +++ b/qse/include/Makefile.in @@ -199,6 +199,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/Makefile.in b/qse/include/qse/Makefile.in index 8354dca0..be714bbd 100644 --- a/qse/include/qse/Makefile.in +++ b/qse/include/qse/Makefile.in @@ -234,6 +234,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index 5b2bb3cf..26127dca 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -1280,9 +1280,6 @@ protected: /// @} // primitive handlers - virtual int vsprintf (char_t* buf, size_t size, - const char_t* fmt, va_list arg) = 0; - virtual flt_t pow (flt_t x, flt_t y) = 0; virtual flt_t mod (flt_t x, flt_t y) = 0; virtual flt_t sin (flt_t x) = 0; @@ -1320,8 +1317,6 @@ protected: static int functionHandler (rtx_t* rtx, const fnc_info_t* fi); - static int sprintf (awk_t* awk, char_t* buf, size_t size, - const char_t* fmt, ...); static flt_t pow (awk_t* awk, flt_t x, flt_t y); static flt_t mod (awk_t* awk, flt_t x, flt_t y); static flt_t sin (awk_t* awk, flt_t x); diff --git a/qse/include/qse/awk/Makefile.in b/qse/include/qse/awk/Makefile.in index 217408bd..8fb2f1f1 100644 --- a/qse/include/qse/awk/Makefile.in +++ b/qse/include/qse/awk/Makefile.in @@ -194,6 +194,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/awk/StdAwk.hpp b/qse/include/qse/awk/StdAwk.hpp index eb4625dd..bf30eee5 100644 --- a/qse/include/qse/awk/StdAwk.hpp +++ b/qse/include/qse/awk/StdAwk.hpp @@ -156,9 +156,6 @@ protected: void* reallocMem (void* ptr, size_t n); void freeMem (void* ptr); - int vsprintf (char_t* buf, size_t size, - const char_t* fmt, va_list arg); - flt_t pow (flt_t x, flt_t y); flt_t mod (flt_t x, flt_t y); flt_t sin (flt_t x); diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index b83b584c..ac7d4a19 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -396,14 +396,6 @@ typedef struct qse_awk_fun_t qse_awk_fun_t; /* ------------------------------------------------------------------------ */ -typedef int (*qse_awk_sprintf_t) ( - qse_awk_t* awk, - qse_char_t* buf, - qse_size_t size, - const qse_char_t* fmt, - ... -); - typedef qse_flt_t (*qse_awk_math1_t) ( qse_awk_t* awk, qse_flt_t x @@ -651,8 +643,6 @@ typedef qse_ssize_t (*qse_awk_rio_impl_t) ( */ struct qse_awk_prm_t { - qse_awk_sprintf_t sprintf; - struct { qse_awk_math2_t pow; /**< floating-point power function */ diff --git a/qse/include/qse/cmn/Makefile.in b/qse/include/qse/cmn/Makefile.in index 035ee842..0a44c49c 100644 --- a/qse/include/qse/cmn/Makefile.in +++ b/qse/include/qse/cmn/Makefile.in @@ -199,6 +199,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/cmn/str.h b/qse/include/qse/cmn/str.h index e81b6520..b327887a 100644 --- a/qse/include/qse/cmn/str.h +++ b/qse/include/qse/cmn/str.h @@ -23,6 +23,7 @@ #include #include +#include /** \file * This file provides various functions, types, macros for string manipulation. @@ -692,6 +693,12 @@ QSE_EXPORT qse_size_t qse_mbsfmt ( ... ); +QSE_EXPORT qse_size_t qse_mbsvfmt ( + qse_mchar_t* buf, + const qse_mchar_t* fmt, + va_list ap +); + /** * The qse_mbsxfmt() function writes a formatted string into the buffer \a buf * of the size \a bsz using the format \a fmt and the variable arguments. It @@ -714,12 +721,25 @@ QSE_EXPORT qse_size_t qse_mbsxfmt ( ... ); +QSE_EXPORT qse_size_t qse_mbsxvfmt ( + qse_mchar_t* buf, + qse_size_t bsz, + const qse_mchar_t* fmt, + va_list ap +); + QSE_EXPORT qse_size_t qse_wcsfmt ( qse_wchar_t* buf, const qse_wchar_t* fmt, ... ); +QSE_EXPORT qse_size_t qse_wcsvfmt ( + qse_wchar_t* buf, + const qse_wchar_t* fmt, + va_list ap +); + /** * The qse_wcsxfmt() function writes a formatted string into the buffer \a buf * of the size \a bsz using the format \a fmt and the variable arguments. It @@ -742,13 +762,24 @@ QSE_EXPORT qse_size_t qse_wcsxfmt ( ... ); +QSE_EXPORT qse_size_t qse_wcsxvfmt ( + qse_wchar_t* buf, + qse_size_t bsz, + const qse_wchar_t* fmt, + va_list ap +); + #if defined(QSE_CHAR_IS_MCHAR) # define qse_strfmt qse_mbsfmt +# define qse_strvfmt qse_mbsvfmt # define qse_strxfmt qse_mbsxfmt +# define qse_strxvfmt qse_mbsxvfmt #else # define qse_strfmt qse_wcsfmt +# define qse_strvfmt qse_wcsvfmt # define qse_strxfmt qse_wcsxfmt +# define qse_strxvfmt qse_wcsxvfmt #endif /** diff --git a/qse/include/qse/config.h.in b/qse/include/qse/config.h.in index ca3109b0..3e5f39c8 100644 --- a/qse/include/qse/config.h.in +++ b/qse/include/qse/config.h.in @@ -39,12 +39,18 @@ /* Define to 1 if you have the `atan2l' function. */ #undef HAVE_ATAN2L +/* Define to 1 if you have the `atan2q' function. */ +#undef HAVE_ATAN2Q + /* Define to 1 if you have the `atanf' function. */ #undef HAVE_ATANF /* Define to 1 if you have the `atanl' function. */ #undef HAVE_ATANL +/* Define to 1 if you have the `atanq' function. */ +#undef HAVE_ATANQ + /* Define to 1 if you have the `backtrace' function. */ #undef HAVE_BACKTRACE @@ -60,6 +66,9 @@ /* Define to 1 if you have the `ceill' function. */ #undef HAVE_CEILL +/* Define to 1 if you have the `ceilq' function. */ +#undef HAVE_CEILQ + /* Define to 1 if you have the `closedir' function. */ #undef HAVE_CLOSEDIR @@ -75,6 +84,9 @@ /* Define to 1 if you have the `cosl' function. */ #undef HAVE_COSL +/* Define to 1 if you have the `cosq' function. */ +#undef HAVE_COSQ + /* Define to 1 if you have the header file. */ #undef HAVE_CRT_EXTERNS_H @@ -131,6 +143,9 @@ /* Define to 1 if you have the `expl' function. */ #undef HAVE_EXPL +/* Define to 1 if you have the `expq' function. */ +#undef HAVE_EXPQ + /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H @@ -146,6 +161,9 @@ /* Define to 1 if you have the `floorl' function. */ #undef HAVE_FLOORL +/* Define to 1 if you have the `floorq' function. */ +#undef HAVE_FLOORQ + /* Define to 1 if you have the `fmod' function. */ #undef HAVE_FMOD @@ -155,6 +173,9 @@ /* Define to 1 if you have the `fmodl' function. */ #undef HAVE_FMODL +/* Define to 1 if you have the `fmodq' function. */ +#undef HAVE_FMODQ + /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK @@ -239,12 +260,18 @@ /* Define to 1 if you have the `log10l' function. */ #undef HAVE_LOG10L +/* Define to 1 if you have the `log10q' function. */ +#undef HAVE_LOG10Q + /* Define to 1 if you have the `logf' function. */ #undef HAVE_LOGF /* Define to 1 if you have the `logl' function. */ #undef HAVE_LOGL +/* Define to 1 if you have the `logq' function. */ +#undef HAVE_LOGQ + /* Define to 1 if you have the `lseek64' function. */ #undef HAVE_LSEEK64 @@ -305,6 +332,9 @@ /* Define to 1 if you have the `powl' function. */ #undef HAVE_POWL +/* Define to 1 if you have the `powq' function. */ +#undef HAVE_POWQ + /* Define to 1 if you have the `prctl' function. */ #undef HAVE_PRCTL @@ -317,6 +347,12 @@ /* Have PTHREAD_PRIO_INHERIT. */ #undef HAVE_PTHREAD_PRIO_INHERIT +/* Define to 1 if you have the header file. */ +#undef HAVE_QUADMATH_H + +/* Define to 1 if you have the `quadmath_snprintf' function. */ +#undef HAVE_QUADMATH_SNPRINTF + /* Define to 1 if you have the `readdir' function. */ #undef HAVE_READDIR @@ -332,6 +368,9 @@ /* Define to 1 if you have the `roundl' function. */ #undef HAVE_ROUNDL +/* Define to 1 if you have the `roundq' function. */ +#undef HAVE_ROUNDQ + /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT @@ -368,6 +407,9 @@ /* Define to 1 if you have the `sinl' function. */ #undef HAVE_SINL +/* Define to 1 if you have the `sinq' function. */ +#undef HAVE_SINQ + /* Define it socklen_t typedef is in sys/socket.h. */ #undef HAVE_SOCKLEN_T @@ -383,6 +425,9 @@ /* Define to 1 if you have the `sqrtl' function. */ #undef HAVE_SQRTL +/* Define to 1 if you have the `sqrtq' function. */ +#undef HAVE_SQRTQ + /* ssl support */ #undef HAVE_SSL @@ -413,6 +458,9 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define to 1 if you have the `strtoflt128' function. */ +#undef HAVE_STRTOFLT128 + /* Define to 1 if `d_type' is a member of `struct dirent'. */ #undef HAVE_STRUCT_DIRENT_D_TYPE @@ -523,6 +571,9 @@ /* Define to 1 if you have the `tanl' function. */ #undef HAVE_TANL +/* Define to 1 if you have the `tanq' function. */ +#undef HAVE_TANQ + /* Define to 1 if you have the `timegm' function. */ #undef HAVE_TIMEGM diff --git a/qse/include/qse/http/Makefile.in b/qse/include/qse/http/Makefile.in index 5f9073fd..0c1447a0 100644 --- a/qse/include/qse/http/Makefile.in +++ b/qse/include/qse/http/Makefile.in @@ -192,6 +192,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/sed/Makefile.in b/qse/include/qse/sed/Makefile.in index f4c143c1..90953999 100644 --- a/qse/include/qse/sed/Makefile.in +++ b/qse/include/qse/sed/Makefile.in @@ -194,6 +194,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index 210d3993..5b630161 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -456,7 +456,7 @@ typedef qse_int_t qse_intptr_t; * The qse_flt_t type defines the largest floating-pointer number type * naturally supported. */ -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__MINGW32__) /* TODO: check if the support for long double is complete. * if so, use long double for qse_flt_t */ typedef double qse_flt_t; @@ -473,7 +473,9 @@ typedef qse_int_t qse_intptr_t; * The qse_fltmax_t type defines the largest floating-pointer number type * ever supported. */ -#if QSE_SIZEOF__FLOAT128 > QSE_SIZEOF_FLT_T +#if QSE_SIZEOF___FLOAT128 >= QSE_SIZEOF_FLT_T + /* the size of long double may be equal to the size of __float128 + * for alignment on some platforms */ typedef __float128 qse_fltmax_t; # define QSE_SIZEOF_FLTMAX_T QSE_SIZEOF___FLOAT128 #else @@ -481,7 +483,6 @@ typedef qse_int_t qse_intptr_t; # define QSE_SIZEOF_FLTMAX_T QSE_SIZEOF_FLT_T #endif - /** @typedef qse_ptrdiff_t */ typedef qse_ssize_t qse_ptrdiff_t; diff --git a/qse/include/qse/xli/Makefile.in b/qse/include/qse/xli/Makefile.in index f07919b9..953e9d19 100644 --- a/qse/include/qse/xli/Makefile.in +++ b/qse/include/qse/xli/Makefile.in @@ -192,6 +192,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/lib/Makefile.in b/qse/lib/Makefile.in index 06a1a07f..a10611d4 100644 --- a/qse/lib/Makefile.in +++ b/qse/lib/Makefile.in @@ -198,6 +198,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index 6832a010..a8d45634 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -1110,7 +1110,6 @@ int Awk::open () qse_awk_prm_t prm; QSE_MEMSET (&prm, 0, QSE_SIZEOF(prm)); - prm.sprintf = sprintf; prm.math.pow = pow; prm.math.mod = mod; prm.math.sin = sin; @@ -1994,18 +1993,6 @@ int Awk::functionHandler (rtx_t* rtx, const fnc_info_t* fi) return rxtn->run->awk->dispatch_function (rxtn->run, fi); } -int Awk::sprintf (awk_t* awk, char_t* buf, size_t size, - const char_t* fmt, ...) -{ - xtn_t* xtn = (xtn_t*) QSE_XTN (awk); - - va_list ap; - va_start (ap, fmt); - int n = xtn->awk->vsprintf (buf, size, fmt, ap); - va_end (ap); - return n; -} - Awk::flt_t Awk::pow (awk_t* awk, flt_t x, flt_t y) { xtn_t* xtn = (xtn_t*) QSE_XTN (awk); diff --git a/qse/lib/awk/Makefile.in b/qse/lib/awk/Makefile.in index 7b765d96..8dd84063 100644 --- a/qse/lib/awk/Makefile.in +++ b/qse/lib/awk/Makefile.in @@ -354,6 +354,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index 4207f4a8..c901d8f1 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -1163,11 +1163,6 @@ void StdAwk::freeMem (void* ptr) } // miscellaneous primitive -int StdAwk::vsprintf ( - char_t* buf, size_t size, const char_t* fmt, va_list arg) -{ - return qse_vsprintf (buf, size, fmt, arg); -} StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y) { diff --git a/qse/lib/awk/awk.c b/qse/lib/awk/awk.c index 5f01a9fa..280183de 100644 --- a/qse/lib/awk/awk.c +++ b/qse/lib/awk/awk.c @@ -118,7 +118,6 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr /* progagate the primitive functions */ QSE_ASSERT (prm != QSE_NULL); - QSE_ASSERT (prm->sprintf != QSE_NULL); QSE_ASSERT (prm->math.pow != QSE_NULL); QSE_ASSERT (prm->math.sin != QSE_NULL); QSE_ASSERT (prm->math.cos != QSE_NULL); @@ -130,7 +129,6 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr QSE_ASSERT (prm->math.exp != QSE_NULL); QSE_ASSERT (prm->math.sqrt != QSE_NULL); if (prm == QSE_NULL || - prm->sprintf == QSE_NULL || prm->math.pow == QSE_NULL || prm->math.sin == QSE_NULL || prm->math.cos == QSE_NULL || diff --git a/qse/lib/awk/misc.c b/qse/lib/awk/misc.c index e1b5f15a..8e040aa9 100644 --- a/qse/lib/awk/misc.c +++ b/qse/lib/awk/misc.c @@ -164,7 +164,7 @@ qse_long_t qse_awk_strxtolong ( /* - * qse_awk_strtoreal is almost a replica of strtod. + * qse_awk_strtoflt is almost a replica of strtod. * * strtod.c -- * @@ -184,7 +184,7 @@ qse_long_t qse_awk_strxtolong ( #define MAX_EXPONENT 511 -qse_flt_t qse_awk_strtoreal (qse_awk_t* awk, const qse_char_t* str) +qse_flt_t qse_awk_strtoflt (qse_awk_t* awk, const qse_char_t* str) { /* * Table giving binary powers of 10. Entry is 10^2^i. @@ -1383,17 +1383,3 @@ void qse_awk_rtx_freemem (qse_awk_rtx_t* rtx, void* ptr) QSE_AWK_FREE (rtx->awk, ptr); } -int qse_awk_sprintflt ( - qse_awk_t* awk, qse_char_t* buf, qse_size_t len, qse_flt_t num) -{ - return awk->prm.sprintf ( - awk, buf, len, - #if QSE_SIZEOF_LONG_DOUBLE > 0 - QSE_T("%Lf"), (long double)num - #elif QSE_SIZEOF_DOUBLE > 0 - QSE_T("%f"), (double)num - #else - #error unsupported size - #endif - ); -} diff --git a/qse/lib/awk/misc.h b/qse/lib/awk/misc.h index 15ea3fcd..e087e961 100644 --- a/qse/lib/awk/misc.h +++ b/qse/lib/awk/misc.h @@ -86,14 +86,6 @@ int qse_awk_rtx_matchrex ( qse_cstr_t* match ); -int qse_awk_sprintflt ( - qse_awk_t* awk, - qse_char_t* buf, - qse_size_t len, - qse_flt_t num -); - - #ifdef __cplusplus } #endif diff --git a/qse/lib/awk/run.c b/qse/lib/awk/run.c index a331a71e..cec83a25 100644 --- a/qse/lib/awk/run.c +++ b/qse/lib/awk/run.c @@ -7290,7 +7290,7 @@ wp_mod_main: qse_flt_t r; int n; - FMT_CHAR (QSE_T('L')); + FMT_CHAR (QSE_T('z')); FMT_CHAR (fmt[i]); if (args == QSE_NULL) @@ -7325,31 +7325,11 @@ wp_mod_main: qse_awk_rtx_refdownval (rtx, v); if (n <= -1) return QSE_NULL; - do + if (qse_str_fcat (out, QSE_STR_PTR(fbu), r) == (qse_size_t)-1) { - n = rtx->awk->prm.sprintf ( - rtx->awk, - rtx->format.tmp.ptr, - rtx->format.tmp.len, - QSE_STR_PTR(fbu), - #if defined(__MINGW32__) - (double)r - #else - (long double)r - #endif - ); - - if (n == -1) - { - GROW (&rtx->format.tmp); - continue; - } - - break; + SETERR_COD (rtx, QSE_AWK_ENOMEM); + return QSE_NULL; } - while (1); - - OUT_STR (rtx->format.tmp.ptr, n); } else if (fmt[i] == QSE_T('c')) { diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index bd7243fe..bcb883bd 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -30,12 +30,14 @@ #include #include #include -#include /* TODO: remove dependency on qse_vsprintf */ #include "../cmn/mem.h" #include #include #include +#if defined(HAVE_QUADMATH_H) +# include +#endif #if defined(_WIN32) # include @@ -299,20 +301,6 @@ static qse_flt_t custom_awk_sqrt (qse_awk_t* awk, qse_flt_t x) #endif } -static int custom_awk_sprintf ( - qse_awk_t* awk, qse_char_t* buf, qse_size_t size, - const qse_char_t* fmt, ...) -{ - int n; - - va_list ap; - va_start (ap, fmt); - n = qse_vsprintf (buf, size, fmt, ap); - va_end (ap); - - return n; -} - static void* custom_awk_modopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec) { #if defined(QSE_ENABLE_STATIC_MODULE) @@ -541,8 +529,6 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize) qse_awk_prm_t prm; xtn_t* xtn; - prm.sprintf = custom_awk_sprintf; - prm.math.pow = custom_awk_pow; prm.math.mod = custom_awk_mod; prm.math.sin = custom_awk_sin; diff --git a/qse/lib/awk/tree.c b/qse/lib/awk/tree.c index 8b74ecec..74e2b863 100644 --- a/qse/lib/awk/tree.c +++ b/qse/lib/awk/tree.c @@ -341,10 +341,14 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde) } else { - qse_char_t buf[64]; - qse_awk_sprintflt ( - awk, buf, QSE_COUNTOF(buf), - ((qse_awk_nde_flt_t*)nde)->val); + qse_char_t buf[96]; + + qse_strxfmt ( + buf, QSE_COUNTOF(buf), + QSE_T("%zf"), + ((qse_awk_nde_flt_t*)nde)->val + ); + PUT_SRCSTR (awk, buf); } break; diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index 2feef4fe..42ce5b9c 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -126,9 +126,8 @@ if ENABLE_XCMGRS libqsecmn_la_SOURCES += cp949.c cp950.c endif - libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined -libqsecmn_la_LIBADD = $(SOCKET_LIBS) +libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS) if ENABLE_CXX diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index 44fd6161..f959e104 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -84,7 +84,8 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = -libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \ alg-sort.c assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c \ fma.c fmt-intmax.c fmt-out.c fs.c fs-err.c fs-move.c glob.c \ @@ -286,6 +287,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ @@ -402,7 +404,7 @@ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \ tre-match-parallel.c tre-parse.c tre-stack.c uri.c utf8.c \ xma.c $(am__append_1) $(am__append_2) libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined -libqsecmn_la_LIBADD = $(SOCKET_LIBS) +libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS) @ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \ @ENABLE_CXX_TRUE@ Mmgr.cpp StdMmgr.cpp diff --git a/qse/lib/cmn/fmt-out.c b/qse/lib/cmn/fmt-out.c index 2add3193..9c874bdf 100644 --- a/qse/lib/cmn/fmt-out.c +++ b/qse/lib/cmn/fmt-out.c @@ -30,7 +30,10 @@ #if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) # define snprintf _snprintf #endif -/* TODO: remove stdio.h once snprintf gets replaced by own +#if defined(HAVE_QUADMATH_H) +# include /* for quadmath_snprintf */ +#endif +/* TODO: remove stdio.h and quadmath.h once snprintf gets replaced by own floting-point conversion implementation*/ /* number of bits in a byte */ @@ -52,7 +55,9 @@ enum LF_Z = (1 << 6), /* long double */ - LF_LD = (1 << 7) + LF_LD = (1 << 7), + /* __float128 */ + LF_QD = (1 << 8) }; static struct @@ -93,9 +98,9 @@ static struct enum { FLAGC_DOT = (1 << 0), - FLAGC_SHARP = (1 << 1), - FLAGC_SIGN = (1 << 2), - FLAGC_SPACE = (1 << 3), + FLAGC_SPACE = (1 << 1), + FLAGC_SHARP = (1 << 2), + FLAGC_SIGN = (1 << 3), FLAGC_LEFTADJ = (1 << 4), FLAGC_ZEROPAD = (1 << 5), FLAGC_WIDTH = (1 << 6), diff --git a/qse/lib/cmn/fmt-out.h b/qse/lib/cmn/fmt-out.h index e00e8c4b..2ab11da2 100644 --- a/qse/lib/cmn/fmt-out.h +++ b/qse/lib/cmn/fmt-out.h @@ -264,7 +264,7 @@ reswitch: case T('j'): /* uintmax_t */ case T('z'): /* size_t */ case T('t'): /* ptrdiff_t */ - if (lm_flag & LF_LD) goto invalid_format; + if (lm_flag & (LF_LD | LF_QD)) goto invalid_format; flagc |= FLAGC_LENMOD; if (lm_dflag) @@ -297,12 +297,23 @@ reswitch: case T('L'): /* long double */ if (flagc & FLAGC_LENMOD) { - /* conflict integral length modifier */ + /* conflict with other length modifier */ goto invalid_format; } flagc |= FLAGC_LENMOD; lm_flag |= LF_LD; goto reswitch; + + case T('Q'): /* __float128 */ + if (flagc & FLAGC_LENMOD) + { + /* conflict with other length modifier */ + goto invalid_format; + } + flagc |= FLAGC_LENMOD; + lm_flag |= LF_QD; + goto reswitch; + /* end of length modifiers */ case T('n'): @@ -320,6 +331,8 @@ reswitch: *(va_arg(ap, short int*)) = data->count; else if (lm_flag & LF_C) /* hh */ *(va_arg(ap, char*)) = data->count; + else if (flagc & FLAGC_LENMOD) + goto oops; else *(va_arg(ap, int*)) = data->count; break; @@ -531,20 +544,62 @@ reswitch: case T('A'): */ { - /* let me rely on snprintf until i implement - * float-point to string conversion */ + /* let me rely on snprintf until i implement float-point to string conversion */ int q; qse_size_t fmtlen; - qse_fltmax_t v_fltmax; + #if (QSE_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) + __float128 v_qd; + #endif long double v_ld; double v_d; + int dtype = 0; if (lm_flag & LF_J) - v_fltmax = va_arg (ap, qse_fltmax_t); - else if (lm_flag & (LF_LD | LF_L | LF_Q | LF_Z)) + { + #if (QSE_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) && (QSE_SIZEOF_FLTMAX_T == QSE_SIZEOF___FLOAT128) + v_qd = va_arg (ap, qse_fltmax_t); + dtype = LF_QD; + #elif QSE_SIZEOF_FLTMAX_T == QSE_SIZEOF_LONG_DOUBLE + v_ld = va_arg (ap, qse_fltmax_t); + dtype = LF_LD; + #elif QSE_SIZEOF_FLTMAX_T == QSE_SIZEOF_DOUBLE + v_d = va_arg (ap, qse_fltmax_t); + #else + #error Unsupported qse_flt_t + #endif + } + else if (lm_flag & LF_Z) + { + /* qse_flt_t is limited to double or long double */ + #if QSE_SIZEOF_FLT_T == QSE_SIZEOF_LONG_DOUBLE + v_ld = va_arg (ap, qse_flt_t); + dtype = LF_LD; + #elif QSE_SIZEOF_FLT_T == QSE_SIZEOF_DOUBLE + v_d = va_arg (ap, qse_flt_t); + #else + #error Unsupported qse_flt_t + #endif + } + else if (lm_flag & (LF_LD | LF_L)) + { v_ld = va_arg (ap, long double); + dtype = LF_LD; + } + #if (QSE_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) + else if (lm_flag & (LF_QD | LF_Q)) + { + v_qd = va_arg (ap, __float128); + dtype = LF_QD; + } + #endif + else if (flagc & FLAGC_LENMOD) + { + goto oops; + } else + { v_d = va_arg (ap, double); + } fmtlen = fmt - percent; if (fmtlen > fltfmt.capa) @@ -566,27 +621,59 @@ reswitch: fltfmt.capa = fmtlen; } - fltfmt.ptr[fmtlen] = QSE_MT('\0'); - while (fmtlen > 0) + /* compose back the format specifier */ + fmtlen = 0; + fltfmt.ptr[fmtlen++] = QSE_MT('%'); + if (flagc & FLAGC_SPACE) fltfmt.ptr[fmtlen++] = QSE_T(' '); + if (flagc & FLAGC_SHARP) fltfmt.ptr[fmtlen++] = QSE_T('#'); + if (flagc & FLAGC_SIGN) fltfmt.ptr[fmtlen++] = QSE_T('+'); + if (flagc & FLAGC_LEFTADJ) fltfmt.ptr[fmtlen++] = QSE_T('-'); + if (flagc & FLAGC_ZEROPAD) fltfmt.ptr[fmtlen++] = QSE_T('0'); + + if (flagc & FLAGC_STAR1) fltfmt.ptr[fmtlen++] = QSE_T('*'); + else if (flagc & FLAGC_WIDTH) { - fmtlen--; - fltfmt.ptr[fmtlen] = percent[fmtlen]; + fmtlen += qse_fmtuintmaxtombs ( + &fltfmt.ptr[fmtlen], fltfmt.capa - fmtlen, + width, 10, -1, QSE_MT('\0'), QSE_NULL); } + if (flagc & FLAGC_DOT) fltfmt.ptr[fmtlen++] = QSE_T('.'); + if (flagc & FLAGC_STAR2) fltfmt.ptr[fmtlen++] = QSE_T('*'); + else if (flagc & FLAGC_PRECISION) + { + fmtlen += qse_fmtuintmaxtombs ( + &fltfmt.ptr[fmtlen], fltfmt.capa - fmtlen, + precision, 10, -1, QSE_MT('\0'), QSE_NULL); + } + + if (dtype == LF_LD) + fltfmt.ptr[fmtlen++] = QSE_MT('L'); + #if (QSE_SIZEOF___FLOAT128 > 0) + else if (dtype == LF_QD) + fltfmt.ptr[fmtlen++] = QSE_MT('Q'); + #endif + + fltfmt.ptr[fmtlen++] = ch; + fltfmt.ptr[fmtlen] = QSE_MT('\0'); while (1) { qse_size_t newcapa; - if (lm_flag & LF_J) - q = snprintf ((qse_mchar_t*)fltout.ptr, fltout.capa + 1, fltfmt.ptr, v_fltmax); - else if (lm_flag & (LF_LD | LF_L | LF_Q | LF_Z)) + if (dtype == LF_LD) q = snprintf ((qse_mchar_t*)fltout.ptr, fltout.capa + 1, fltfmt.ptr, v_ld); + #if (QSE_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) + else if (dtype == LF_QD) + q = quadmath_snprintf ((qse_mchar_t*)fltout.ptr, fltout.capa + 1, fltfmt.ptr, v_qd); + #endif else q = snprintf ((qse_mchar_t*)fltout.ptr, fltout.capa + 1, fltfmt.ptr, v_d); if (q <= -1) goto oops; if (q <= fltout.capa) break; newcapa = fltout.capa * 2; + if (newcapa < q) newcapa = q; + if (fltout.ptr == fltout.sbuf) { fltout.ptr = QSE_MMGR_ALLOC (QSE_MMGR_GETDFL(), QSE_SIZEOF(char_t) * (newcapa + 1)); diff --git a/qse/lib/cmn/str-dyn.c b/qse/lib/cmn/str-dyn.c index 09ffe6e7..2eb851f7 100644 --- a/qse/lib/cmn/str-dyn.c +++ b/qse/lib/cmn/str-dyn.c @@ -53,7 +53,7 @@ static int put_mchar_nocheck (qse_mchar_t c, void* ctx) return 1; } -static int put_wchar_nocheck (qse_wchar_t* c, void* ctx) +static int put_wchar_nocheck (qse_wchar_t c, void* ctx) { qse_wcs_t* str = (qse_wcs_t*)ctx; str->val.ptr[str->val.len++] = c; diff --git a/qse/lib/cmn/str-dyn.h b/qse/lib/cmn/str-dyn.h index ec0f5249..1037bcae 100644 --- a/qse/lib/cmn/str-dyn.h +++ b/qse/lib/cmn/str-dyn.h @@ -425,8 +425,6 @@ qse_size_t str_pac (str_t* str) return str->val.len; } - - qse_size_t str_vfcat (str_t* str, const char_t* fmt, va_list ap) { va_list orgap; @@ -471,50 +469,6 @@ qse_size_t str_vfcat (str_t* str, const char_t* fmt, va_list ap) qse_size_t str_fcat (str_t* str, const char_t* fmt, ...) { -#if 0 - va_list ap; - fmtout_t fo; - int x; - qse_size_t old_len, inc; - - old_len = str->val.len; - - fo.limit = QSE_TYPE_MAX(qse_size_t) - 1; - fo.ctx = str; - fo.put = str->val.ptr? put_char: put_char_null; - fo.conv = conv_char; - - va_start (ap, fmt); - x = fmtout (fmt, &fo, ap); - va_end (ap); - - if (x <= -1) - { - str->val.len = old_len; - return (qse_size_t)-1; - } - - if (str->val.ptr == QSE_NULL || str->val.len - old_len < fo.count) - { - str->val.len = old_len; - - /* resizing is required */ - x = resize_for_ncat (str, fo.count); - - if (x <= -1) return (qse_size_t)-1; - if (x >= 1) - { - fo.put = put_char; - - va_start (ap, fmt); - x = fmtout (fmt, &fo, ap); - va_end (ap); - } - } - - str->val.ptr[str->val.len] = T('\0'); - return str->val.len; -#endif qse_size_t x; va_list ap; diff --git a/qse/lib/cmn/str-fmt.c b/qse/lib/cmn/str-fmt.c index 50eca019..ab62b93f 100644 --- a/qse/lib/cmn/str-fmt.c +++ b/qse/lib/cmn/str-fmt.c @@ -103,6 +103,8 @@ static int mbs_to_wcs ( #undef conv_char #undef strfmt #undef strxfmt +#undef strvfmt +#undef strxvfmt #define T(x) QSE_MT(x) #define char_t qse_mchar_t @@ -114,6 +116,8 @@ static int mbs_to_wcs ( #define conv_char wcs_to_mbs #define strfmt qse_mbsfmt #define strxfmt qse_mbsxfmt +#define strvfmt qse_mbsvfmt +#define strxvfmt qse_mbsxvfmt #include "str-fmt.h" /* ----------------------------------- */ @@ -128,6 +132,8 @@ static int mbs_to_wcs ( #undef conv_char #undef strfmt #undef strxfmt +#undef strvfmt +#undef strxvfmt #define T(x) QSE_WT(x) #define char_t qse_wchar_t @@ -139,5 +145,7 @@ static int mbs_to_wcs ( #define conv_char mbs_to_wcs #define strfmt qse_wcsfmt #define strxfmt qse_wcsxfmt +#define strvfmt qse_wcsvfmt +#define strxvfmt qse_wcsxvfmt #include "str-fmt.h" diff --git a/qse/lib/cmn/str-fmt.h b/qse/lib/cmn/str-fmt.h index 81836edb..a59bb4df 100644 --- a/qse/lib/cmn/str-fmt.h +++ b/qse/lib/cmn/str-fmt.h @@ -19,10 +19,9 @@ */ -qse_size_t strfmt (char_t* buf, const char_t* fmt, ...) +qse_size_t strvfmt (char_t* buf, const char_t* fmt, va_list ap) { buf_t b; - va_list ap; fmtout_t fo; int x; @@ -37,9 +36,7 @@ qse_size_t strfmt (char_t* buf, const char_t* fmt, ...) /* no I/O error must occurred by fmtout but there can be * encoding conversion error by fmtout */ - va_start (ap, fmt); x = fmtout (fmt, &fo, ap); - va_end (ap); /* fmtout must produce no I/O error but it can produce * an encoding conversion error. if you didn't use a conversion @@ -57,10 +54,21 @@ qse_size_t strfmt (char_t* buf, const char_t* fmt, ...) return fo.count; } -qse_size_t strxfmt (char_t* buf, qse_size_t len, const char_t* fmt, ...) +qse_size_t strfmt (char_t* buf, const char_t* fmt, ...) +{ + qse_size_t x; + va_list ap; + + va_start (ap, fmt); + x = strvfmt (buf, fmt, ap); + va_end (ap); + + return x; +} + +qse_size_t strxvfmt (char_t* buf, qse_size_t len, const char_t* fmt, va_list ap) { buf_t b; - va_list ap; fmtout_t fo; int x; @@ -79,9 +87,7 @@ qse_size_t strxfmt (char_t* buf, qse_size_t len, const char_t* fmt, ...) fo.put = b.ptr? put_char: put_char_null; fo.conv = conv_char; - va_start (ap, fmt); x = fmtout (fmt, &fo, ap); - va_end (ap); /* fmtout must produce no I/O error but it can produce * an encoding conversion error. if you didn't use a conversion @@ -99,3 +105,14 @@ qse_size_t strxfmt (char_t* buf, qse_size_t len, const char_t* fmt, ...) return fo.count; } +qse_size_t strxfmt (char_t* buf, qse_size_t len, const char_t* fmt, ...) +{ + qse_size_t x; + va_list ap; + + va_start (ap, fmt); + x = strxvfmt (buf, len, fmt, ap); + va_end (ap); + + return x; +} diff --git a/qse/lib/http/Makefile.in b/qse/lib/http/Makefile.in index cd4723c0..57ef2d50 100644 --- a/qse/lib/http/Makefile.in +++ b/qse/lib/http/Makefile.in @@ -225,6 +225,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/lib/http/httpd-task.c b/qse/lib/http/httpd-task.c index aab5f295..2cedb86e 100644 --- a/qse/lib/http/httpd-task.c +++ b/qse/lib/http/httpd-task.c @@ -20,13 +20,8 @@ #include "httpd.h" #include -#include #include "../cmn/mem.h" -#include -#include /* TODO: remove this */ - - /* TODO: * many functions in this file use qse_size_t. * so the size data transfers is limited by this type. @@ -115,61 +110,27 @@ qse_httpd_task_t* qse_httpd_entaskformat ( task_format_t data; va_list ap; - qse_mchar_t n[2]; qse_mchar_t* buf; int bytes_req, l; va_start (ap, fmt); - bytes_req = vsnprintf (n, 1, fmt, ap); + bytes_req = qse_mbsxvfmt (QSE_NULL, 0, fmt, ap); va_end (ap); - if (bytes_req == -1) + buf = (qse_mchar_t*) qse_httpd_allocmem ( + httpd, (bytes_req + 1) * QSE_SIZEOF(*buf)); + if (buf == QSE_NULL) return QSE_NULL; + + va_start (ap, fmt); + l = qse_mbsxvfmt (buf, bytes_req + 1, fmt, ap); + va_end (ap); + + if (l != bytes_req) { - qse_size_t capa = 256; - - buf = (qse_mchar_t*) qse_httpd_allocmem ( - httpd, (capa + 1) * QSE_SIZEOF(*buf)); - if (buf == QSE_NULL) return QSE_NULL; - - /* an old vsnprintf behaves differently from C99 standard. - * thus, it returns -1 when it can't write all the input given. */ - for (;;) - { - va_start (ap, fmt); - l = vsnprintf (buf, capa + 1, fmt, ap); - va_end (ap); - - if (l == -1) - { - qse_httpd_freemem (httpd, buf); - - capa = capa * 2; - buf = (qse_mchar_t*) qse_httpd_allocmem (httpd, (capa + 1) * QSE_SIZEOF(*buf)); - if (buf == QSE_NULL) return QSE_NULL; - } - else break; - } - } - else - { - /* vsnprintf returns the number of characters that would - * have been written not including the terminating '\0' - * if the _data buffer were large enough */ - buf = (qse_mchar_t*) qse_httpd_allocmem ( - httpd, (bytes_req + 1) * QSE_SIZEOF(*buf)); - if (buf == QSE_NULL) return QSE_NULL; - - va_start (ap, fmt); - l = vsnprintf (buf, bytes_req + 1, fmt, ap); - va_end (ap); - - if (l != bytes_req) - { - /* something got wrong ... */ - qse_httpd_freemem (httpd, buf); - httpd->errnum = QSE_HTTPD_EINTERN; - return QSE_NULL; - } + /* something got wrong ... */ + qse_httpd_freemem (httpd, buf); + httpd->errnum = QSE_HTTPD_EINTERN; + return QSE_NULL; } QSE_MEMSET (&data, 0, QSE_SIZEOF(data)); diff --git a/qse/lib/http/httpd.h b/qse/lib/http/httpd.h index 3ea4026e..e27fd492 100644 --- a/qse/lib/http/httpd.h +++ b/qse/lib/http/httpd.h @@ -107,11 +107,6 @@ struct qse_httpd_real_task_t #define CLIENT_HANDLE_IN_MUX (CLIENT_HANDLE_READ_IN_MUX|CLIENT_HANDLE_WRITE_IN_MUX) #define CLIENT_TASK_TRIGGER_IN_MUX(i) (1 << ((i) + 8)) -#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) -# define snprintf _snprintf -# define vsnprintf _vsnprintf -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/qse/lib/sed/Makefile.in b/qse/lib/sed/Makefile.in index 7fed0f2a..21ad630e 100644 --- a/qse/lib/sed/Makefile.in +++ b/qse/lib/sed/Makefile.in @@ -247,6 +247,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/lib/xli/Makefile.in b/qse/lib/xli/Makefile.in index b3e2715b..fd1d977c 100644 --- a/qse/lib/xli/Makefile.in +++ b/qse/lib/xli/Makefile.in @@ -220,6 +220,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/regress/Makefile.in b/qse/regress/Makefile.in index 1f3825ef..7b11c218 100644 --- a/qse/regress/Makefile.in +++ b/qse/regress/Makefile.in @@ -199,6 +199,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/regress/awk/Makefile.in b/qse/regress/awk/Makefile.in index 0f3f32af..72282f15 100644 --- a/qse/regress/awk/Makefile.in +++ b/qse/regress/awk/Makefile.in @@ -162,6 +162,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/regress/sed/Makefile.in b/qse/regress/sed/Makefile.in index 62c353b9..275ab3ce 100644 --- a/qse/regress/sed/Makefile.in +++ b/qse/regress/sed/Makefile.in @@ -164,6 +164,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/samples/Makefile.in b/qse/samples/Makefile.in index 58a7c765..4874a993 100644 --- a/qse/samples/Makefile.in +++ b/qse/samples/Makefile.in @@ -199,6 +199,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/samples/awk/Makefile.in b/qse/samples/awk/Makefile.in index 34175693..48527454 100644 --- a/qse/samples/awk/Makefile.in +++ b/qse/samples/awk/Makefile.in @@ -322,6 +322,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/samples/cmn/Makefile.in b/qse/samples/cmn/Makefile.in index 4073247f..a5833592 100644 --- a/qse/samples/cmn/Makefile.in +++ b/qse/samples/cmn/Makefile.in @@ -373,6 +373,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/samples/http/Makefile.in b/qse/samples/http/Makefile.in index f84a1a33..f58f8510 100644 --- a/qse/samples/http/Makefile.in +++ b/qse/samples/http/Makefile.in @@ -204,6 +204,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/samples/sed/Makefile.in b/qse/samples/sed/Makefile.in index 7824cd5e..acd181bd 100644 --- a/qse/samples/sed/Makefile.in +++ b/qse/samples/sed/Makefile.in @@ -233,6 +233,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@ diff --git a/qse/tools/Makefile.in b/qse/tools/Makefile.in index a30e4796..d81d44ad 100644 --- a/qse/tools/Makefile.in +++ b/qse/tools/Makefile.in @@ -161,6 +161,7 @@ QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@ QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@ QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@ QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@ +QUADMATH_LIBS = @QUADMATH_LIBS@ RANLIB = @RANLIB@ RM = @RM@ RMDIR = @RMDIR@