This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[Patch] Remove redundant sizeof(char) (was: Re: [PATCH] Consistently...)


Benjamin Kosnik wrote:

>>Quite to the contrary, maybe the few instances already present of 
>>sizeof(char) should be removed?
>>
>Yep.
>
Fine.
I'm testing the below. Ok if it passes?

Ciao, Paolo.

//////////////////////////////

2002-03-31  Paolo Carlini  <pcarlini@unitus.it>

        * config/locale/ieee_1003.1-2001/codecvt_specializations.h
        (codecvt::do_out, codecvt::do_unshift, codecvt::do_in):
        By definition, sizeof(char) == 1.
        * include/bits/locale_facets.tcc (money_get::do_get,
        money_put::do_put): Ditto.
        * testsuite/21_strings/inserters_extractors.cc
        (test04): Ditto.

diff -urN 
libstdc++-v3-orig/config/locale/ieee_1003.1-2001/codecvt_specializations.h 
libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h
--- 
libstdc++-v3-orig/config/locale/ieee_1003.1-2001/codecvt_specializations.h    
2002-03-09 03:16:33.000000000 +0100
+++ 
libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h    
2002-03-31 19:50:06.000000000 +0200
@@ -285,9 +285,9 @@
     {
       typedef state_type::__desc_type    __desc_type;
       const __desc_type* __desc = __state._M_get_out_descriptor();
-      const size_t __fmultiple = sizeof(intern_type) / sizeof(char);
+      const size_t __fmultiple = sizeof(intern_type);
       size_t __fbytes = __fmultiple * (__from_end - __from);
-      const size_t __tmultiple = sizeof(extern_type) / sizeof(char);
+      const size_t __tmultiple = sizeof(extern_type);
       size_t __tbytes = __tmultiple * (__to_end - __to);
      
       // Argument list for iconv specifies a byte sequence. Thus,
@@ -352,7 +352,7 @@
     {
       typedef state_type::__desc_type    __desc_type;
       const __desc_type* __desc = __state._M_get_in_descriptor();
-      const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
+      const size_t __tmultiple = sizeof(intern_type);
       size_t __tlen = __tmultiple * (__to_end - __to);
      
       // Argument list for iconv specifies a byte sequence. Thus,
@@ -390,9 +390,9 @@
     {
       typedef state_type::__desc_type    __desc_type;
       const __desc_type* __desc = __state._M_get_in_descriptor();
-      const size_t __fmultiple = sizeof(extern_type) / sizeof(char);
+      const size_t __fmultiple = sizeof(extern_type);
       size_t __flen = __fmultiple * (__from_end - __from);
-      const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
+      const size_t __tmultiple = sizeof(intern_type);
       size_t __tlen = __tmultiple * (__to_end - __to);
      
       // Argument list for iconv specifies a byte sequence. Thus,
diff -urN libstdc++-v3-orig/include/bits/locale_facets.tcc 
libstdc++-v3/include/bits/locale_facets.tcc
--- libstdc++-v3-orig/include/bits/locale_facets.tcc    2002-03-19 
21:59:38.000000000 +0100
+++ libstdc++-v3/include/bits/locale_facets.tcc    2002-03-31 
19:51:48.000000000 +0200
@@ -938,7 +938,7 @@
       __beg = this->do_get(__beg, __end, __intl, __io, __err, __str);
 
       const int __n = numeric_limits<long double>::digits10;
-      char* __cs = static_cast<char*>(__builtin_alloca(sizeof(char) * 
__n));
+      char* __cs = static_cast<char*>(__builtin_alloca(__n));
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       const _CharT* __wcs = __str.c_str();
@@ -1152,20 +1152,20 @@
 #ifdef _GLIBCPP_USE_C99
       // First try a buffer perhaps big enough.
       int __cs_size = 64;
-      char* __cs = static_cast<char*>(__builtin_alloca(sizeof(char) * 
__cs_size));
+      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
       int __len = __convert_from_v(__cs, __cs_size, "%.01Lf", __units, 
_S_c_locale);
       // If the buffer was not large enough, try again with the correct 
size.
       if (__len >= __cs_size)
     {
       __cs_size = __len + 1;
-      __cs = static_cast<char*>(__builtin_alloca(sizeof(char) * 
__cs_size));
+      __cs = static_cast<char*>(__builtin_alloca(__cs_size));
       __len = __convert_from_v(__cs, __cs_size, "%.01Lf", __units, 
_S_c_locale);
     }
 #else
       // max_exponent10 + 1 for the integer part, + 4 for sign, decimal 
point,
       // decimal digit, '\0'.
       const int __cs_size = numeric_limits<long double>::max_exponent10 
+ 5;
-      char* __cs = static_cast<char*>(__builtin_alloca(sizeof(char) * 
__cs_size));
+      char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
       int __len = __convert_from_v(__cs, 0, "%.01Lf", __units, 
_S_c_locale);
 #endif
       _CharT* __ws = 
static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __cs_size));
diff -urN libstdc++-v3-orig/testsuite/21_strings/inserters_extractors.cc 
libstdc++-v3/testsuite/21_strings/inserters_extractors.cc
--- libstdc++-v3-orig/testsuite/21_strings/inserters_extractors.cc    
2001-08-07 05:38:28.000000000 +0200
+++ libstdc++-v3/testsuite/21_strings/inserters_extractors.cc    
2002-03-31 19:53:43.000000000 +0200
@@ -155,7 +155,7 @@
 {
   bool test = true;
   std::string str(size, 's');
-  int expected_size = (2 * (size + sizeof(char)));
+  int expected_size = 2 * (size + 1);
   std::ostringstream oss(str);
  
   // sanity checks



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