locale_facets.h (time_get::_M_extract_name): Add ctype argument.
authorBenjamin Kosnik <bkoz@redhat.com>
Tue, 4 Nov 2003 02:06:59 +0000 (02:06 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Tue, 4 Nov 2003 02:06:59 +0000 (02:06 +0000)
2003-11-03  Benjamin Kosnik  <bkoz@redhat.com>

* include/bits/locale_facets.h (time_get::_M_extract_name): Add
ctype argument.
* include/bits/locale_facets.tcc: Same, use it to allow
capitalized names.

* include/bits/fstream.tcc: Spacing tweak.
* include/bits/istream.tcc: Same.
* include/bits/ostream.tcc: Same.

From-SVN: r73241

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/include/bits/ostream.tcc

index eec8bf9bb4666d8118b380b7eb8fa70d0e15f8f1..cb0c9a384d6e5b4be9a8e2f80da8844b050e3a17 100644 (file)
@@ -1,3 +1,14 @@
+2003-11-03  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/locale_facets.h (time_get::_M_extract_name): Add
+       ctype argument. 
+       * include/bits/locale_facets.tcc: Same, use it to allow
+       capitalized names.
+       
+       * include/bits/fstream.tcc: Spacing tweak.
+       * include/bits/istream.tcc: Same.
+       * include/bits/ostream.tcc: Same.
+
 2003-10-30  Paolo Carlini  <pcarlini@suse.de>
 
        * include/bits/locale_facets.tcc (time_get::_M_extract_via_format):
index a93459a71f3477764106240fc198fbbe98cb9b36..29fe0e8d6c6ffe6120c07b1671b977c90e80a7d2 100644 (file)
@@ -610,7 +610,6 @@ namespace std
                  __computed_off += _M_ext_buf + __gptr_off - _M_ext_end;
                }
            }
-         
          __ret = _M_seek(__computed_off, __way);
        }
       _M_last_overflowed = false;      
index 1ae7cba126ff542c1af86917ef4035ab6463e4ca..f9ff41d35f87b3bf60522c1e0497c337aaee476e 100644 (file)
@@ -63,7 +63,8 @@ namespace std
                  __c = __sb->snextc();
 
              // _GLIBCXX_RESOLVE_LIB_DEFECTS
-             // 195. Should basic_istream::sentry's constructor ever set eofbit? 
+             // 195. Should basic_istream::sentry's constructor ever
+             // 195. set eofbit?
              if (traits_type::eq_int_type(__c, __eof))
                __in.setstate(ios_base::eofbit);
            }
index f55685d09a6bd938eec6422c65a25655257c65c7..a433e6c69ac33bf2eca15e54f500409103e94a99 100644 (file)
@@ -1519,6 +1519,7 @@ namespace std
       void
       _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
                      const _CharT** __names, size_t __indexlen, 
+                     const ctype<_CharT>& __ctype, 
                      ios_base::iostate& __err) const;
 
       // Extract on a component-by-component basis, via __format argument.
index 8dd98efe0685823cf96f89616eb0a3d048dd7675..58e028441c73d8a720357b6396d1d9d9a9868610 100644 (file)
@@ -1533,7 +1533,7 @@ namespace std
                          const _CharT* __format) const
     {  
       const locale __loc = __io.getloc();
-      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
+      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
       const size_t __len = char_traits<_CharT>::length(__format);
 
@@ -1556,14 +1556,14 @@ namespace std
                  const char_type*  __days1[7];
                  __tp._M_days_abbreviated(__days1);
                  _M_extract_name(__beg, __end, __tm->tm_wday, __days1, 7, 
-                                 __err);
+                                 __ctype, __err);
                  break;
                case 'A':
                  // Weekday name [tm_wday].
                  const char_type*  __days2[7];
                  __tp._M_days(__days2);
                  _M_extract_name(__beg, __end, __tm->tm_wday, __days2, 7, 
-                                 __err);
+                                 __ctype, __err);
                  break;
                case 'h':
                case 'b':
@@ -1571,14 +1571,14 @@ namespace std
                  const char_type*  __months1[12];
                  __tp._M_months_abbreviated(__months1);
                  _M_extract_name(__beg, __end, __tm->tm_mon, __months1, 12, 
-                                 __err);
+                                 __ctype, __err);
                  break;
                case 'B':
                  // Month name [tm_mon].
                  const char_type*  __months2[12];
                  __tp._M_months(__months2);
                  _M_extract_name(__beg, __end, __tm->tm_mon, __months2, 12, 
-                                 __err);
+                                 __ctype, __err);
                  break;
                case 'c':
                  // Default time and date representation.
@@ -1697,7 +1697,7 @@ namespace std
                      int __tmp;
                      _M_extract_name(__beg, __end, __tmp, 
                                      __timepunct_cache<_CharT>::_S_timezones, 
-                                     14, __err);
+                                     14, __ctype, __err);
                      
                      // GMT requires special effort.
                      if (__beg != __end && !__err && __tmp == 0
@@ -1764,6 +1764,7 @@ namespace std
     time_get<_CharT, _InIter>::
     _M_extract_name(iter_type& __beg, iter_type& __end, int& __member,
                    const _CharT** __names, size_t __indexlen, 
+                   const ctype<_CharT>& __ctype, 
                    ios_base::iostate& __err) const
     {
       typedef char_traits<_CharT>              __traits_type;
@@ -1774,12 +1775,16 @@ namespace std
       bool __testvalid = true;
       const char_type* __name;
 
-      // Look for initial matches.
+      // Look for initial matches.  
+      // NB: Some of the locale data is in the form of all lowercase
+      // names, and some is in the form of initially-capitalized
+      // names. Look for both.
       if (__beg != __end)
        {
          const char_type __c = *__beg;
          for (size_t __i1 = 0; __i1 < __indexlen; ++__i1)
-           if (__c == __names[__i1][0])
+           if (__c == __names[__i1][0] 
+               || __c == __ctype.toupper(__names[__i1][0]))
              __matches[__nmatches++] = __i1;
        }
       
@@ -1807,6 +1812,13 @@ namespace std
 
       if (__nmatches == 1)
        {
+         // If there was only one match, the first compare is redundant.
+         if (__pos == 0)
+           {
+             ++__pos;
+             ++__beg;
+           }
+
          // Make sure found name is completely extracted.
          __name = __names[__matches[0]];
          const size_t __len = __traits_type::length(__name);
@@ -1866,11 +1878,12 @@ namespace std
     {
       typedef char_traits<_CharT>              __traits_type;
       const locale __loc = __io.getloc();
-      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
+      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
+      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
       const char_type*  __days[7];
       __tp._M_days_abbreviated(__days);
       int __tmpwday;
-      _M_extract_name(__beg, __end, __tmpwday, __days, 7, __err);
+      _M_extract_name(__beg, __end, __tmpwday, __days, 7, __ctype, __err);
 
       // Check to see if non-abbreviated name exists, and extract.
       // NB: Assumes both _M_days and _M_days_abbreviated organized in
@@ -1909,11 +1922,12 @@ namespace std
     {
       typedef char_traits<_CharT>              __traits_type;
       const locale __loc = __io.getloc();
-      __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
+      const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
+      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
       const char_type*  __months[12];
       __tp._M_months_abbreviated(__months);
       int __tmpmon;
-      _M_extract_name(__beg, __end, __tmpmon, __months, 12, __err);
+      _M_extract_name(__beg, __end, __tmpmon, __months, 12, __ctype, __err);
 
       // Check to see if non-abbreviated name exists, and extract.
       // NB: Assumes both _M_months and _M_months_abbreviated organized in
index df63364522b0bad1137aad7f9a2271c81028a71c..c126eb8df25378dd9c6ba5c2c3b4df1697a7f87a 100644 (file)
@@ -673,8 +673,7 @@ namespace std
          // 25. String operator<< uses width() value wrong
          if (__w > __len)
            {
-             _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
-                                                                  * __w));
+             _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
              __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, __s,
                                             __w, __len, false);
              __s = __cs;