This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Include <cstdio>, qualify with std:: config/locale/*/c_locale.h


Hi,

tested x86-linux.

Paolo.

////////
2003-07-14  Paolo Carlini  <pcarlini@unitus.it>

	* config/locale/gnu/c_locale.h (__convert_from_v): Include
	<cstdio>. Qualify names.
	* config/locale/generic/c_locale.h (__convert_from_v): Ditto.
diff -cprN libstdc++-v3-orig/config/locale/generic/c_locale.h libstdc++-v3/config/locale/generic/c_locale.h
*** libstdc++-v3-orig/config/locale/generic/c_locale.h	Mon Jul 14 04:52:04 2003
--- libstdc++-v3/config/locale/generic/c_locale.h	Mon Jul 14 21:29:05 2003
***************
*** 39,46 ****
  #pragma GCC system_header
  
  #include <clocale>
! #include <cstdlib>
! #include <cstring>
  
  #define _GLIBCXX_NUM_CATEGORIES 0
  
--- 39,47 ----
  #pragma GCC system_header
  
  #include <clocale>
! #include <cstdlib>   // get std::malloc
! #include <cstring>   // get std::strlen
! #include <cstdio>    // get std::snprintf or std::sprintf
  
  #define _GLIBCXX_NUM_CATEGORIES 0
  
*************** namespace std
*** 59,84 ****
  		     const char* __fmt,
  		     _Tv __v, const __c_locale&, int __prec = -1)
      {
!       char* __old = setlocale(LC_ALL, NULL);
!       char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
        if (__sav)
!         strcpy(__sav, __old);
!       setlocale(LC_ALL, "C");
  
        int __ret;
  #ifdef _GLIBCXX_USE_C99
        if (__prec >= 0)
!         __ret = snprintf(__out, __size, __fmt, __prec, __v);
        else
!         __ret = snprintf(__out, __size, __fmt, __v);
  #else
        if (__prec >= 0)
!         __ret = sprintf(__out, __fmt, __prec, __v);
        else
!         __ret = sprintf(__out, __fmt, __v);
  #endif
!       setlocale(LC_ALL, __sav);
!       free(__sav);
        return __ret;
      }
  }
--- 60,85 ----
  		     const char* __fmt,
  		     _Tv __v, const __c_locale&, int __prec = -1)
      {
!       char* __old = std::setlocale(LC_ALL, NULL);
!       char* __sav = static_cast<char*>(std::malloc(std::strlen(__old) + 1));
        if (__sav)
!         std::strcpy(__sav, __old);
!       std::setlocale(LC_ALL, "C");
  
        int __ret;
  #ifdef _GLIBCXX_USE_C99
        if (__prec >= 0)
!         __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
        else
!         __ret = std::snprintf(__out, __size, __fmt, __v);
  #else
        if (__prec >= 0)
!         __ret = std::sprintf(__out, __fmt, __prec, __v);
        else
!         __ret = std::sprintf(__out, __fmt, __v);
  #endif
!       std::setlocale(LC_ALL, __sav);
!       std::free(__sav);
        return __ret;
      }
  }
diff -cprN libstdc++-v3-orig/config/locale/gnu/c_locale.h libstdc++-v3/config/locale/gnu/c_locale.h
*** libstdc++-v3-orig/config/locale/gnu/c_locale.h	Mon Jul 14 15:32:26 2003
--- libstdc++-v3/config/locale/gnu/c_locale.h	Mon Jul 14 21:26:12 2003
***************
*** 40,45 ****
--- 40,46 ----
  
  #include <cstring>              // get std::strlen
  #include <cstdlib>              // get std::malloc
+ #include <cstdio>               // get std::snprintf or std::sprintf
  #include <clocale>
  #include <langinfo.h>		// For codecvt
  #include <iconv.h>		// For codecvt using iconv, iconv_t
*************** namespace std
*** 84,92 ****
        int __ret;
  #ifdef _GLIBCXX_USE_C99
        if (__prec >= 0)
!         __ret = snprintf(__out, __size, __fmt, __prec, __v);
        else
!         __ret = snprintf(__out, __size, __fmt, __v);
  #else
        if (__prec >= 0)
          __ret = std::sprintf(__out, __fmt, __prec, __v);
--- 85,93 ----
        int __ret;
  #ifdef _GLIBCXX_USE_C99
        if (__prec >= 0)
!         __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
        else
!         __ret = std::snprintf(__out, __size, __fmt, __v);
  #else
        if (__prec >= 0)
          __ret = std::sprintf(__out, __fmt, __prec, __v);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]