Subject: lib/29832: libstdc++ missing std::wstring support
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: J.T. Conklin <jtc@acorntoolworks.com>
List: netbsd-bugs
Date: 03/30/2005 04:49:00
>Number: 29832
>Category: lib
>Synopsis: libstdc++ missing std::wstring support
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Mar 30 04:49:00 +0000 2005
>Originator: J.T. Conklin
>Release: NetBSD 2.0.1
>Organization:
J.T. Conklin
>Environment:
System: NetBSD orac 2.0.1 NetBSD 2.0.1 (ORAC) #2: Sun Mar 13 22:46:10 PST 2005 jtc@orac:/home/jtc/netbsd/NetBSD-2.0/src/sys/arch/i386/compile/ORAC i386
Architecture: i386
Machine: i386
>Description:
libstdc++'s configure script does not enable wide string support
because NetBSD is missing the wide character versions of strftime(),
*printf(), and *scanf().
I have submitted PR/29826 which contains a wcsftime() implementation.
It turns out that the requirement for *printf() and *scanf() is legacy
cruft left over from when libstdc++ used those functions for formatted
I/O. It now has it's own code for that.
The enclosed patch changes acinclude.m4 to check only those functions
that libstdc++ currently uses. Naturally, the configure script would
have to be regenerated in order to take advantage of the change. I
have included the changed config.h/c++config.h files for the i386 and
that would result from running the updated configure script. I've
tested the same on a amd64 box, but it's not convenient to generate
diffs for that. I suspect that similar changes could safely be made
for all platforms, but I only have i386 and amd64 machines handy for
testing.
The patch also adds the appropriate #ifdefs for the missing *printf()
and *scanf() functions that are no longer required to std_cwchar.h.
I inquired about submitting a similar change to the master libstdc++
sources on libstdc++@gcc.gnu.org a few weeks ago, but Benjamin Kosnik
let me know that he'll be refactoring wide character configuration/
requirements there shortly.
>How-To-Repeat:
>Fix:
Index: gnu/dist/gcc/libstdc++-v3/acinclude.m4
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 acinclude.m4
*** gnu/dist/gcc/libstdc++-v3/acinclude.m4 18 Oct 2003 11:13:55 -0000 1.1.1.2
--- gnu/dist/gcc/libstdc++-v3/acinclude.m4 29 Mar 2005 19:14:13 -0000
***************
*** 987,999 ****
ac_wfuncs=no)
dnl Checks for names injected into std:: by the c_std headers.
! AC_CHECK_FUNCS(btowc wctob fgetwc fgetws fputwc fputws fwide \
! fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
! vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
! mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
! wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
! ac_wfuncs=no)
AC_MSG_CHECKING([for ISO C99 wchar_t support])
if test x"$has_weof" = xyes &&
--- 987,1005 ----
ac_wfuncs=no)
dnl Checks for names injected into std:: by the c_std headers.
! AC_CHECK_FUNCS([btowc wctob fgetwc fgetws fputwc fputws fwide \
! getwc getwchar mbsinit mbrlen mbrtowc \
! mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstol \
wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
! wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,
! [],[ac_wfuncs=no])
!
! dnl Checks for wide character functions that are not required
! dnl for basic wchar_t support. Don't disable support if they are missing.
! dnl Injection of these is wrapped with guard macros.
! AC_CHECK_FUNCS([fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf \
! vswprintf vswscanf vwprintf vwscanf wcstof wprintf wscanf \
! iswblank],[],[])
AC_MSG_CHECKING([for ISO C99 wchar_t support])
if test x"$has_weof" = xyes &&
Index: gnu/dist/gcc/libstdc++-v3/include/c_std/std_cwchar.h
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/libstdc++-v3/include/c_std/std_cwchar.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 std_cwchar.h
*** gnu/dist/gcc/libstdc++-v3/include/c_std/std_cwchar.h 23 Jul 2003 02:42:52 -0000 1.1.1.1
--- gnu/dist/gcc/libstdc++-v3/include/c_std/std_cwchar.h 29 Mar 2005 19:14:13 -0000
***************
*** 78,85 ****
#undef fputwc
#undef fputws
#undef fwide
! #undef fwprintf
! #undef fwscanf
#undef getwc
#undef getwchar
#undef mbrlen
--- 78,89 ----
#undef fputwc
#undef fputws
#undef fwide
! #if _GLIBCXX_HAVE_FWPRINTF
! # undef fwprintf
! #endif
! #if _GLIBCXX_HAVE_FWSCANF
! # undef fwscanf
! #endif
#undef getwc
#undef getwchar
#undef mbrlen
***************
*** 88,102 ****
#undef mbsrtowcs
#undef putwc
#undef putwchar
! #undef swprintf
! #undef swscanf
#undef ungetwc
! #undef vfwprintf
! #undef vfwscanf
! #undef vswprintf
! #undef vswscanf
! #undef vwprintf
! #undef vwscanf
#undef wcrtomb
#undef wcscat
#undef wcschr
--- 92,122 ----
#undef mbsrtowcs
#undef putwc
#undef putwchar
! #if _GLIBCXX_HAVE_SWPRINTF
! # undef swprintf
! #endif
! #if _GLIBCXX_HAVE_SWSCANF
! # undef swscanf
! #endif
#undef ungetwc
! #if _GLIBCXX_HAVE_VFWPRINTF
! # undef vfwprintf
! #endif
! #if _GLIBCXX_HAVE_VFWSCANF
! # undef vfwscanf
! #endif
! #if _GLIBCXX_HAVE_VSWPRINTF
! # undef vswprintf
! #endif
! #if _GLIBCXX_HAVE_VSWSCANF
! # undef vswscanf
! #endif
! #if _GLIBCXX_HAVE_VWPRINTF
! # undef vwprintf
! #endif
! #if _GLIBCXX_HAVE_VWSCANF
! # undef vwscanf
! #endif
#undef wcrtomb
#undef wcscat
#undef wcschr
***************
*** 115,121 ****
#undef wcsspn
#undef wcsstr
#undef wcstod
! #undef wcstof
#undef wcstok
#undef wcstol
#undef wcstoul
--- 135,143 ----
#undef wcsspn
#undef wcsstr
#undef wcstod
! #if _GLIBCXX_HAVE_WCSTOF
! # undef wcstof
! #endif
#undef wcstok
#undef wcstol
#undef wcstoul
***************
*** 126,133 ****
#undef wmemcpy
#undef wmemmove
#undef wmemset
! #undef wprintf
! #undef wscanf
#if _GLIBCPP_USE_WCHAR_T
namespace std
--- 148,159 ----
#undef wmemcpy
#undef wmemmove
#undef wmemset
! #if _GLIBCXX_HAVE_WPRINTF
! # undef wprintf
! #endif
! #if _GLIBCXX_HAVE_WSCANF
! # undef wscanf
! #endif
#if _GLIBCPP_USE_WCHAR_T
namespace std
***************
*** 140,147 ****
--- 166,177 ----
using ::fputwc;
using ::fputws;
using ::fwide;
+ #if _GLIBCXX_HAVE_FWPRINTF
using ::fwprintf;
+ #endif
+ #if _GLIBCXX_HAVE_FWSCANF
using ::fwscanf;
+ #endif
using ::getwc;
using ::getwchar;
using ::mbrlen;
***************
*** 150,164 ****
--- 180,210 ----
using ::mbsrtowcs;
using ::putwc;
using ::putwchar;
+ #if _GLIBCXX_HAVE_SWPRINTF
using ::swprintf;
+ #endif
+ #if _GLIBCXX_HAVE_SWSCANF
using ::swscanf;
+ #endif
using ::ungetwc;
+ #if _GLIBCXX_HAVE_VFWPRINTF
using ::vfwprintf;
+ #endif
+ #if _GLIBCXX_HAVE_VWSCANF
using ::vfwscanf;
+ #endif
+ #if _GLIBCXX_HAVE_VSWPRINTF
using ::vswprintf;
+ #endif
+ #if _GLIBCXX_HAVE_VSWSCANF
using ::vswscanf;
+ #endif
+ #if _GLIBCXX_HAVE_VWPRINTF
using ::vwprintf;
+ #endif
+ #if _GLIBCXX_HAVE_VWSCANF
using ::vwscanf;
+ #endif
using ::wcrtomb;
using ::wcscat;
using ::wcscmp;
***************
*** 173,179 ****
--- 219,227 ----
using ::wcsrtombs;
using ::wcsspn;
using ::wcstod;
+ #if _GLIBCXX_HAVE_WCSTOF
using ::wcstof;
+ #endif
using ::wcstok;
using ::wcstol;
using ::wcstoul;
***************
*** 183,190 ****
--- 231,242 ----
using ::wmemcpy;
using ::wmemmove;
using ::wmemset;
+ #if _GLIBCXX_HAVE_WPRINTF
using ::wprintf;
+ #endif
+ #if _GLIBCXX_HAVE_WSCANF
using ::wscanf;
+ #endif
using ::wcschr;
Index: gnu/lib/libstdc++-v3/arch/i386/c++config.h
===================================================================
RCS file: /cvsroot/src/gnu/lib/libstdc++-v3/arch/i386/c++config.h,v
retrieving revision 1.6
diff -c -r1.6 c++config.h
*** gnu/lib/libstdc++-v3/arch/i386/c++config.h 25 May 2004 13:39:35 -0000 1.6
--- gnu/lib/libstdc++-v3/arch/i386/c++config.h 29 Mar 2005 19:14:20 -0000
***************
*** 117,123 ****
/* #undef _GLIBCPP_USE_C99 */
// Define if code specialized for wchar_t should be used.
! /* #undef _GLIBCPP_USE_WCHAR_T */
// Define if using setrlimit to limit memory usage during 'make check'.
/* #undef _GLIBCPP_MEM_LIMITS */
--- 117,123 ----
/* #undef _GLIBCPP_USE_C99 */
// Define if code specialized for wchar_t should be used.
! #define _GLIBCPP_USE_WCHAR_T 1
// Define if using setrlimit to limit memory usage during 'make check'.
/* #undef _GLIBCPP_MEM_LIMITS */
***************
*** 749,755 ****
#define _GLIBCPP_HAVE_WCSCSPN 1
/* Define if you have the wcsftime function. */
! /* #undef _GLIBCPP_HAVE_WCSFTIME */
/* Define if you have the wcslen function. */
#define _GLIBCPP_HAVE_WCSLEN 1
--- 749,755 ----
#define _GLIBCPP_HAVE_WCSCSPN 1
/* Define if you have the wcsftime function. */
! #define _GLIBCPP_HAVE_WCSFTIME 1
/* Define if you have the wcslen function. */
#define _GLIBCPP_HAVE_WCSLEN 1
Index: gnu/lib/libstdc++-v3/arch/i386/config.h
===================================================================
RCS file: /cvsroot/src/gnu/lib/libstdc++-v3/arch/i386/config.h,v
retrieving revision 1.4
diff -c -r1.4 config.h
*** gnu/lib/libstdc++-v3/arch/i386/config.h 19 Feb 2004 08:11:31 -0000 1.4
--- gnu/lib/libstdc++-v3/arch/i386/config.h 29 Mar 2005 19:14:23 -0000
***************
*** 17,23 ****
/* #undef _GLIBCPP_USE_C99 */
// Define if code specialized for wchar_t should be used.
! /* #undef _GLIBCPP_USE_WCHAR_T */
// Define if using setrlimit to limit memory usage during 'make check'.
/* #undef _GLIBCPP_MEM_LIMITS */
--- 17,23 ----
/* #undef _GLIBCPP_USE_C99 */
// Define if code specialized for wchar_t should be used.
! #define _GLIBCPP_USE_WCHAR_T 1
// Define if using setrlimit to limit memory usage during 'make check'.
/* #undef _GLIBCPP_MEM_LIMITS */
***************
*** 649,655 ****
#define HAVE_WCSCSPN 1
/* Define if you have the wcsftime function. */
! /* #undef HAVE_WCSFTIME */
/* Define if you have the wcslen function. */
#define HAVE_WCSLEN 1
--- 649,655 ----
#define HAVE_WCSCSPN 1
/* Define if you have the wcsftime function. */
! #define HAVE_WCSFTIME 1
/* Define if you have the wcslen function. */
#define HAVE_WCSLEN 1
>Unformatted: