diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2774feb82b00..f208edfb0226 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,21 @@ +2000-08-22 Benjamin Kosnik + + * src/locale-inst.cc: Add codecvt instantiations for has_facet and use_facet. + * testsuite/22_locale/codecvt_unicode_wchar_t.cc: New file, for + testing two-byte unicode encodings converted to four-byte UCS4 + encodings. + + * bits/codecvt.h (codecvt<__enc_traits>): Fix do_unshift. + * testsuite/22_locale/codecvt_unicode_char.cc (test01): Add + correct state/encoding information. + + * acinclude.m4 (GLIBCPP_CHECK_WCHAR_T_SUPPORT): Add wcsrtombs, + mbsrtowcs checks as codecvt needs them + now. + Add checks for langinfo.h, nl_langinfo function call. + * libio/iofwide.c (_IO_fwide): Simplify, as nl_langinfo is assumed. + 2000-08-22 Richard B. Kreckel * config/cpu/alpha/bits/atomicity.h: Change __attribute__ diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 915b83cd03fa..da9e3c3dd52d 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1,4 +1,3 @@ - dnl dnl Initialize configure bits. dnl @@ -936,10 +935,12 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ AC_MSG_RESULT($has_weof) dnl Tests for wide character functions used in char_traits. - AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset, ac_wfuncs=yes, ac_wfuncs=no) + AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \ + wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no) AC_MSG_CHECKING([for ISO C9X wchar_t support]) - if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes && test x"$ac_wfuncs" = xyes; then + if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \ + && test x"$ac_wfuncs" = xyes; then ac_isoC9X_wchar_t=yes else ac_isoC9X_wchar_t=no @@ -949,10 +950,13 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ dnl Use iconv for wchar_t to char conversions. As such, check for dnl X/Open Portability Guide, version 2 features (XPG2). AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no) - AC_CHECK_FUNCS(iconv_open iconv_close iconv, ac_XPG2funcs=yes, ac_XPG2funcs=no) + AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no) + AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \ + ac_XPG2funcs=yes, ac_XPG2funcs=no) AC_MSG_CHECKING([for XPG2 wchar_t support]) - if test x"$ac_has_iconv_h" = xyes && test x"$ac_XPG2funcs" = xyes; then + if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \ + && test x"$ac_XPG2funcs" = xyes; then ac_XPG2_wchar_t=yes else ac_XPG2_wchar_t=no @@ -961,12 +965,9 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ dnl At the moment, only enable wchar_t specializations if all the dnl above support is present. - dnl 2000-07-07-bkoz-hack-xxx -# ac_isoC9X_wchar_t=no - dnl 2000-07-07-bkoz-hack-xxx - AC_MSG_CHECKING([for enabled wchar_t specializations]) - if test x"$ac_isoC9X_wchar_t" = xyes && test x"$ac_XPG2_wchar_t" = xyes; then + if test x"$ac_isoC9X_wchar_t" = xyes \ + && test x"$ac_XPG2_wchar_t" = xyes; then libinst_wstring_la="libinst-wstring.la" AC_DEFINE(_GLIBCPP_USE_WCHAR_T) AC_MSG_RESULT("yes") diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4 index 0c0281e77a4f..84b4baa154fa 100644 --- a/libstdc++-v3/aclocal.m4 +++ b/libstdc++-v3/aclocal.m4 @@ -10,7 +10,6 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. - dnl dnl Initialize configure bits. dnl @@ -948,10 +947,12 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ AC_MSG_RESULT($has_weof) dnl Tests for wide character functions used in char_traits. - AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset, ac_wfuncs=yes, ac_wfuncs=no) + AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \ + wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no) AC_MSG_CHECKING([for ISO C9X wchar_t support]) - if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes && test x"$ac_wfuncs" = xyes; then + if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \ + && test x"$ac_wfuncs" = xyes; then ac_isoC9X_wchar_t=yes else ac_isoC9X_wchar_t=no @@ -961,10 +962,13 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ dnl Use iconv for wchar_t to char conversions. As such, check for dnl X/Open Portability Guide, version 2 features (XPG2). AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no) - AC_CHECK_FUNCS(iconv_open iconv_close iconv, ac_XPG2funcs=yes, ac_XPG2funcs=no) + AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no) + AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \ + ac_XPG2funcs=yes, ac_XPG2funcs=no) AC_MSG_CHECKING([for XPG2 wchar_t support]) - if test x"$ac_has_iconv_h" = xyes && test x"$ac_XPG2funcs" = xyes; then + if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \ + && test x"$ac_XPG2funcs" = xyes; then ac_XPG2_wchar_t=yes else ac_XPG2_wchar_t=no @@ -973,12 +977,9 @@ AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [ dnl At the moment, only enable wchar_t specializations if all the dnl above support is present. - dnl 2000-07-07-bkoz-hack-xxx -# ac_isoC9X_wchar_t=no - dnl 2000-07-07-bkoz-hack-xxx - AC_MSG_CHECKING([for enabled wchar_t specializations]) - if test x"$ac_isoC9X_wchar_t" = xyes && test x"$ac_XPG2_wchar_t" = xyes; then + if test x"$ac_isoC9X_wchar_t" = xyes \ + && test x"$ac_XPG2_wchar_t" = xyes; then libinst_wstring_la="libinst-wstring.la" AC_DEFINE(_GLIBCPP_USE_WCHAR_T) AC_MSG_RESULT("yes") diff --git a/libstdc++-v3/bits/codecvt.h b/libstdc++-v3/bits/codecvt.h index 18339025b9bd..dd52f88af3db 100644 --- a/libstdc++-v3/bits/codecvt.h +++ b/libstdc++-v3/bits/codecvt.h @@ -416,7 +416,12 @@ namespace std if (__conv != size_t(-1)) { __to_next = reinterpret_cast(__cto); - __ret = ok; + if (__tlen == __tmultiple * (__to_end - __to)) + __ret = noconv; + else if (__tlen == 0) + __ret = ok; + else + __ret = partial; } else __ret = error; diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 99276e599748..7c35a039e456 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -510,6 +510,9 @@ /* Define if you have the logl function. */ #undef HAVE_LOGL +/* Define if you have the mbsrtowcs function. */ +#undef HAVE_MBSRTOWCS + /* Define if you have the modff function. */ #undef HAVE_MODFF @@ -519,6 +522,9 @@ /* Define if you have the nan function. */ #undef HAVE_NAN +/* Define if you have the nl_langinfo function. */ +#undef HAVE_NL_LANGINFO + /* Define if you have the powf function. */ #undef HAVE_POWF @@ -579,6 +585,9 @@ /* Define if you have the wcslen function. */ #undef HAVE_WCSLEN +/* Define if you have the wcsrtombs function. */ +#undef HAVE_WCSRTOMBS + /* Define if you have the wmemchr function. */ #undef HAVE_WMEMCHR diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index d1b4b7f6f421..fb30583ddb1b 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -17501,15 +17501,16 @@ fi rm -f conftest* echo "$ac_t""$has_weof" 1>&6 - for ac_func in wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset + for ac_func in wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \ + wcsrtombs mbsrtowcs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:17508: checking for $ac_func" >&5 +echo "configure:17509: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -17559,8 +17560,9 @@ done echo $ac_n "checking for ISO C9X wchar_t support""... $ac_c" 1>&6 -echo "configure:17563: checking for ISO C9X wchar_t support" >&5 - if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes && test x"$ac_wfuncs" = xyes; then +echo "configure:17564: checking for ISO C9X wchar_t support" >&5 + if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \ + && test x"$ac_wfuncs" = xyes; then ac_isoC9X_wchar_t=yes else ac_isoC9X_wchar_t=no @@ -17569,17 +17571,17 @@ echo "configure:17563: checking for ISO C9X wchar_t support" >&5 ac_safe=`echo "iconv.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for iconv.h""... $ac_c" 1>&6 -echo "configure:17573: checking for iconv.h" >&5 +echo "configure:17575: checking for iconv.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:17583: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:17585: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -17601,15 +17603,49 @@ else ac_has_iconv_h=no fi - for ac_func in iconv_open iconv_close iconv + ac_safe=`echo "langinfo.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for langinfo.h""... $ac_c" 1>&6 +echo "configure:17609: checking for langinfo.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:17619: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_has_langinfo_h=yes +else + echo "$ac_t""no" 1>&6 +ac_has_langinfo_h=no +fi + + for ac_func in iconv_open iconv_close iconv nl_langinfo do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:17608: checking for $ac_func" >&5 +echo "configure:17644: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:17672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -17650,7 +17686,8 @@ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then cat >> confdefs.h <&6 ac_XPG2funcs=no @@ -17659,19 +17696,19 @@ done echo $ac_n "checking for XPG2 wchar_t support""... $ac_c" 1>&6 -echo "configure:17663: checking for XPG2 wchar_t support" >&5 - if test x"$ac_has_iconv_h" = xyes && test x"$ac_XPG2funcs" = xyes; then +echo "configure:17700: checking for XPG2 wchar_t support" >&5 + if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \ + && test x"$ac_XPG2funcs" = xyes; then ac_XPG2_wchar_t=yes else ac_XPG2_wchar_t=no fi echo "$ac_t""$ac_XPG2_wchar_t" 1>&6 - # ac_isoC9X_wchar_t=no - - echo $ac_n "checking for enabled wchar_t specializations""... $ac_c" 1>&6 -echo "configure:17674: checking for enabled wchar_t specializations" >&5 - if test x"$ac_isoC9X_wchar_t" = xyes && test x"$ac_XPG2_wchar_t" = xyes; then + echo $ac_n "checking for enabled wchar_t specializations""... $ac_c" 1>&6 +echo "configure:17710: checking for enabled wchar_t specializations" >&5 + if test x"$ac_isoC9X_wchar_t" = xyes \ + && test x"$ac_XPG2_wchar_t" = xyes; then libinst_wstring_la="libinst-wstring.la" cat >> confdefs.h <<\EOF #define _GLIBCPP_USE_WCHAR_T 1 @@ -17695,17 +17732,17 @@ EOF ac_safe=`echo "ctype.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for ctype.h""... $ac_c" 1>&6 -echo "configure:17699: checking for ctype.h" >&5 +echo "configure:17736: checking for ctype.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:17709: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:17746: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -17726,9 +17763,9 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then ctype_default=yes echo $ac_n "checking for gnu-linux ""... $ac_c" 1>&6 -echo "configure:17730: checking for gnu-linux " >&5 +echo "configure:17767: checking for gnu-linux " >&5 cat > conftest.$ac_ext < int main() { @@ -17739,7 +17776,7 @@ int + __ctype_tolower[a] + __ctype_toupper[a] + __ctype_b[a];} ; return 0; } EOF -if { (eval echo configure:17743: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_linux=yes @@ -17758,9 +17795,9 @@ rm -f conftest* if test $ctype_default = "yes"; then echo $ac_n "checking for freebsd 4.0 ""... $ac_c" 1>&6 -echo "configure:17762: checking for freebsd 4.0 " >&5 +echo "configure:17799: checking for freebsd 4.0 " >&5 cat > conftest.$ac_ext < int main() { @@ -17770,7 +17807,7 @@ int + _CTYPE_D + _CTYPE_P + _CTYPE_X + _CTYPE_G ;} ; return 0; } EOF -if { (eval echo configure:17774: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17811: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_bsd=yes @@ -17790,9 +17827,9 @@ rm -f conftest* if test $ctype_default = "yes"; then echo $ac_n "checking for freebsd 3.4 ""... $ac_c" 1>&6 -echo "configure:17794: checking for freebsd 3.4 " >&5 +echo "configure:17831: checking for freebsd 3.4 " >&5 cat > conftest.$ac_ext < int main() { @@ -17802,7 +17839,7 @@ int + _D + _P + _X + _G + __istype (a, 0);} ; return 0; } EOF -if { (eval echo configure:17806: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_freebsd34=yes @@ -17822,9 +17859,9 @@ rm -f conftest* if test $ctype_default = "yes"; then echo $ac_n "checking for solaris 2.6,7,8 ""... $ac_c" 1>&6 -echo "configure:17826: checking for solaris 2.6,7,8 " >&5 +echo "configure:17863: checking for solaris 2.6,7,8 " >&5 cat > conftest.$ac_ext < int main() { @@ -17835,7 +17872,7 @@ int + __trans_lower[a] + __trans_upper[a] + __ctype_mask[a];} ; return 0; } EOF -if { (eval echo configure:17839: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17876: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_solaris=yes @@ -17850,7 +17887,7 @@ rm -f conftest* if test $ctype_solaris = "yes"; then echo $ac_n "checking for version""... $ac_c" 1>&6 -echo "configure:17854: checking for version" >&5 +echo "configure:17891: checking for version" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' @@ -17859,14 +17896,14 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < int main() { typedef long* __to_type; __to_type const& _M_toupper = __trans_upper; ; return 0; } EOF -if { (eval echo configure:17870: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17907: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_solaris26=yes @@ -17898,9 +17935,9 @@ cross_compiling=$ac_cv_prog_cc_cross if test $ctype_default = "yes"; then echo $ac_n "checking for solaris 2.5.1 ""... $ac_c" 1>&6 -echo "configure:17902: checking for solaris 2.5.1 " >&5 +echo "configure:17939: checking for solaris 2.5.1 " >&5 cat > conftest.$ac_ext < int main() { @@ -17910,7 +17947,7 @@ int + __ctype[a];} ; return 0; } EOF -if { (eval echo configure:17914: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_solaris25=yes @@ -17930,9 +17967,9 @@ rm -f conftest* if test $ctype_default = "yes"; then echo $ac_n "checking for aix ""... $ac_c" 1>&6 -echo "configure:17934: checking for aix " >&5 +echo "configure:17971: checking for aix " >&5 cat > conftest.$ac_ext < int main() { @@ -17943,7 +17980,7 @@ int + _VALC('a') + _IS('c', 0);} ; return 0; } EOF -if { (eval echo configure:17947: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:17984: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_aix=yes @@ -17963,9 +18000,9 @@ rm -f conftest* if test $ctype_default = "yes"; then echo $ac_n "checking for newlib ""... $ac_c" 1>&6 -echo "configure:17967: checking for newlib " >&5 +echo "configure:18004: checking for newlib " >&5 cat > conftest.$ac_ext < int main() { @@ -17975,7 +18012,7 @@ int + _ctype_[a];} ; return 0; } EOF -if { (eval echo configure:17979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:18016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* \ ctype_newlib=yes @@ -18009,17 +18046,17 @@ fi do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:18013: checking for $ac_hdr" >&5 +echo "configure:18050: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:18023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:18060: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -18048,12 +18085,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:18052: checking for $ac_func" >&5 +echo "configure:18089: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -18101,7 +18138,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:18105: checking for working mmap" >&5 +echo "configure:18142: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -18109,7 +18146,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:18290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -18312,19 +18349,19 @@ fi if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:18316: checking for LC_MESSAGES" >&5 +echo "configure:18353: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'ac_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:18328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:18365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_val_LC_MESSAGES=yes else diff --git a/libstdc++-v3/libio/ChangeLog b/libstdc++-v3/libio/ChangeLog index 4dc4b84622b3..4f8d0e16a78f 100644 --- a/libstdc++-v3/libio/ChangeLog +++ b/libstdc++-v3/libio/ChangeLog @@ -1,3 +1,7 @@ +2000-08-22 Benjamin Kosnik + + * iofwide.c (_IO_fwide): Simplify, as nl_langinfo is assumed. + 2000-08-14 Benjamin Kosnik * *: Merge with mainline glibc sources. diff --git a/libstdc++-v3/libio/iofwide.c b/libstdc++-v3/libio/iofwide.c index 886f36f2aa74..db1a4f1a76a8 100644 --- a/libstdc++-v3/libio/iofwide.c +++ b/libstdc++-v3/libio/iofwide.c @@ -27,15 +27,15 @@ #ifdef _LIBC # include # include +# include +# include +# include #endif #include #include -#ifdef _LIBC +#if defined(_LIBC) || defined(_GLIBCPP_USE_WCHAR_T) # include -# include -# include -# include #endif @@ -156,21 +156,14 @@ _IO_fwide (fp, mode) should come up with a solution for the determination of the currently used internal character set. */ const char *internal_ccs = _G_INTERNAL_CCS; - const char *external_ccs = NULL; + const char *external_ccs = nl_langinfo(CODESET); -# ifdef HAVE_NL_LANGINFO - external_ccs = nl_langinfo (CODESET); -# endif if (external_ccs == NULL) external_ccs = "ISO-8859-1"; cc->__cd_in = iconv_open (internal_ccs, external_ccs); if (cc->__cd_in != (iconv_t) -1) cc->__cd_out = iconv_open (external_ccs, internal_ccs); - - if (cc->__cd_in == (iconv_t) -1 || cc->__cd_out == (iconv_t) -1) - /* XXX */ - abort (); } # else # error "somehow determine this from LC_CTYPE" diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc index d17f3322adce..7a0af3575cfa 100644 --- a/libstdc++-v3/src/locale-inst.cc +++ b/libstdc++-v3/src/locale-inst.cc @@ -136,13 +136,26 @@ namespace std { template class __codecvt_abstract_base; template class __codecvt_abstract_base; #ifdef _GLIBCPP_USE_WCHAR_T + // XXX This should not be necessary. Unfortunately, the has_facet + // and use_facet defines are not in the headers, an instead in + // locale_facets.tcc for the time being, as they use std::vector and + // thus compile time double when they are pushed up to the top-level + // includes. typedef unsigned short unicode_t; + template const codecvt& use_facet >(const locale&); template bool has_facet >(const locale &); + + template + const codecvt& + use_facet >(const locale&); + template + bool + has_facet >(const locale &); #endif // collate diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc index 55e089e2a364..d7e39c8d5338 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc @@ -97,8 +97,6 @@ void test01() bool test = true; const ext_type* e_lit = "black pearl jasmine tea"; - const ext_type* efrom_next; - const int_type* ifrom_next; int size = strlen(e_lit); int_type i_lit_base[24] = @@ -108,6 +106,8 @@ void test01() }; const int_type* i_lit = i_lit_base; + const ext_type* efrom_next; + const int_type* ifrom_next; ext_type* e_arr = new ext_type[size + 1]; ext_type* eto_next; int_type* i_arr = new int_type[size + 1]; @@ -130,7 +130,7 @@ void test01() VERIFY( ito_next == i_arr + size ); // out - unicode_codecvt::state_type state02; + unicode_codecvt::state_type state02("UNICODE", "ISO_8859-1"); initialize_state(state02); result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next, e_arr, e_arr + size, eto_next); @@ -141,7 +141,7 @@ void test01() // unshift ext_traits::copy(e_arr, e_lit, size); - unicode_codecvt::state_type state03; + unicode_codecvt::state_type state03("UNICODE", "ISO_8859-1"); initialize_state(state03); result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next); VERIFY( r3 == codecvt_base::noconv ); @@ -153,7 +153,7 @@ void test01() VERIFY( !cvt.always_noconv() ); - unicode_codecvt::state_type state04; + unicode_codecvt::state_type state04("UNICODE", "ISO_8859-1"); initialize_state(state04); int j = cvt.length(state03, e_lit, e_lit + size, 5); VERIFY( j == 5 ); diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_unicode_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_wchar_t.cc new file mode 100644 index 000000000000..2ad93134f88a --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_wchar_t.cc @@ -0,0 +1,123 @@ +// 2000-08-22 Benjamin Kosnik + +// Copyright (C) 2000 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.2.1.5 - Template class codecvt [lib.locale.codecvt] + +#include +#include + +using namespace std; + +void +initialize_state(__enc_traits& state) +{ state._M_init(); } + +// Partial specialization using __enc_traits. +// codecvt +void test01() +{ + typedef codecvt_base::result result; + typedef unsigned short unicode_t; + typedef unicode_t int_type; + typedef wchar_t ext_type; + typedef __enc_traits enc_type; + typedef codecvt unicode_codecvt; + typedef char_traits int_traits; + typedef char_traits ext_traits; + + bool test = true; + const ext_type* e_lit = L"black pearl jasmine tea"; + int size = ext_traits::length(e_lit); + + int_type i_lit_base[24] = + { 25088, 27648, 24832, 25344, 27392, 8192, 28672, 25856, 24832, 29184, + 27648, 8192, 27136, 24832, 29440, 27904, 26880, 28160, 25856, 8192, 29696, + 25856, 24832, 2560 + }; + const int_type* i_lit = i_lit_base; + + const ext_type* efrom_next; + const int_type* ifrom_next; + ext_type* e_arr = new ext_type[size + 1]; + ext_type* eto_next; + int_type* i_arr = new int_type[size + 1]; + int_type* ito_next; + + // construct a locale object with the specialized facet. + locale loc(locale::classic(), new unicode_codecvt); + // sanity check the constructed locale has the specialized facet. + VERIFY( has_facet(loc) ); + const unicode_codecvt& cvt = use_facet(loc); + + // in + unicode_codecvt::state_type state01("UNICODE", "UCS4"); + initialize_state(state01); + result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next, + i_arr, i_arr + size, ito_next); + VERIFY( r1 == codecvt_base::ok ); + VERIFY( !int_traits::compare(i_arr, i_lit, size) ); + VERIFY( efrom_next == e_lit + size ); + VERIFY( ito_next == i_arr + size ); + + // out + unicode_codecvt::state_type state02("UNICODE", "UCS4"); + initialize_state(state02); + result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next, + e_arr, e_arr + size, eto_next); + VERIFY( r2 == codecvt_base::ok ); + VERIFY( !ext_traits::compare(e_arr, e_lit, size) ); + VERIFY( ifrom_next == i_lit + size ); + VERIFY( eto_next == e_arr + size ); + + // unshift + ext_traits::copy(e_arr, e_lit, size); + unicode_codecvt::state_type state03("UNICODE", "UCS4"); + initialize_state(state03); + result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next); + VERIFY( r3 == codecvt_base::noconv ); + VERIFY( !ext_traits::compare(e_arr, e_lit, size) ); + VERIFY( eto_next == e_arr ); + + int i = cvt.encoding(); + VERIFY( i == 0 ); + + VERIFY( !cvt.always_noconv() ); + + unicode_codecvt::state_type state04("UNICODE", "UCS4"); + initialize_state(state04); + int j = cvt.length(state03, e_lit, e_lit + size, 5); + VERIFY( j == 5 ); + + int k = cvt.max_length(); + VERIFY( k == 1 ); + + delete [] e_arr; + delete [] i_arr; +} + +int main () +{ + test01(); + + return 0; +} + + +