stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r604045 - in /incubator/stdcxx/branches/4.2.x: etc/config/vacpp.config include/valarray tests/localization/22.locale.time.put.cpp
Date Thu, 13 Dec 2007 21:56:11 GMT
Author: sebor
Date: Thu Dec 13 13:56:09 2007
New Revision: 604045

URL: http://svn.apache.org/viewvc?rev=604045&view=rev
Log:
2007-12-13  Martin Sebor  <sebor@roguewave.com>

	Merged revs 601922, 601927, and 601935 from trunk:

2007-12-06 Travis Vitek <vitek@roguewave.com>

	STDCXX-443
	* etc/config/vacpp.config: Remove -Q compile flag for AIX
	optimized builds to be consistent with IBM documentation.

2007-12-05 Travis Vitek <vitek@roguewave.com>

	STDCXX-676
	* tests/locale/22.locale.time.put.cpp [_MSC_VER] (rw_strftime):
	Avoid passing unsupported format specifiers to strftime().

2007-12-04 Travis Vitek <vitek@roguewave.com>

	STDCXX-603
	* include/valarray (apply): Avoid use of typedef in function
	type to avoid linker error with VisualAge C++.

Modified:
    incubator/stdcxx/branches/4.2.x/etc/config/vacpp.config
    incubator/stdcxx/branches/4.2.x/include/valarray
    incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp

Modified: incubator/stdcxx/branches/4.2.x/etc/config/vacpp.config
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/etc/config/vacpp.config?rev=604045&r1=604044&r2=604045&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/etc/config/vacpp.config (original)
+++ incubator/stdcxx/branches/4.2.x/etc/config/vacpp.config Thu Dec 13 13:56:09 2007
@@ -175,9 +175,7 @@
 DEBUG_CPPFLAGS  =
 
 # -O enables inlining of all functions declared inline
-# -Q (same as -qinline) enables inlining of all functions
-#    up to 20 statements big
-OPTMZ_CXXFLAGS  = -O -Q
+OPTMZ_CXXFLAGS  = -O
 OPTMZ_CPPFLAGS  =
 
 # shared/archive library options

Modified: incubator/stdcxx/branches/4.2.x/include/valarray
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/include/valarray?rev=604045&r1=604044&r2=604045&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/include/valarray (original)
+++ incubator/stdcxx/branches/4.2.x/include/valarray Thu Dec 13 13:56:09 2007
@@ -596,7 +596,7 @@
 
 template <class _TypeT>
 inline valarray<_TypeT>
-valarray<_TypeT>::apply (value_type __fun (value_type)) const
+valarray<_TypeT>::apply (_TypeT __fun (_TypeT)) const
 {
     return _RW::__rw_unary_function (*this, __fun);
 }
@@ -604,7 +604,7 @@
 
 template <class _TypeT>
 inline valarray<_TypeT>
-valarray<_TypeT>::apply (value_type __fun (const value_type&)) const
+valarray<_TypeT>::apply (_TypeT __fun (const _TypeT&)) const
 {
     return _RW::__rw_unary_function (*this, __fun);
 } 

Modified: incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp?rev=604045&r1=604044&r2=604045&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp (original)
+++ incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp Thu Dec 13 13:56:09
2007
@@ -35,6 +35,7 @@
 #include <cstring>       // for memcpy(), strlen()
 #include <ctime>         // for tm
 #include <cwchar>        // for wcsftime(), wcslen()
+#include <cassert>       // for assert()
 
 #include <driver.h>      // for rw_test(), ...
 #include <environ.h>     // for rw_putenv()
@@ -124,7 +125,153 @@
 { 
     static const std::tm tmp = std::tm ();
 
-    const std::size_t n = std::strftime (buf, bufsize, pat, tmb ? tmb : &tmp);
+    if (!tmb)
+        tmb = &tmp;
+
+#ifdef _MSC_VER
+
+    // ms crt aborts if you use out of range values in debug
+    if (tmb->tm_hour < 0 || 24 <= tmb->tm_hour)
+        return 0;
+
+    if (tmb->tm_min < 0 || 60 <= tmb->tm_min)
+        return 0;
+
+    if (tmb->tm_sec < 0 || 60 <= tmb->tm_sec)
+        return 0;
+
+    // create a new pattern buffer that is windows strftime compatible...
+    char patbuf [512];
+    char *fpat = patbuf;
+
+    // assumes tm_year is relative to 1900
+    const int year    = (tmb->tm_year + 1900);
+    const int century = (tmb->tm_year + 1900) / 100;
+
+    while (*pat) {
+
+        if (*pat == '%') {
+
+            // ensure we are not within 16 chars of the end of the
+            // local pattern buffer to avoid overflow
+            assert ((fpat + 16) < (patbuf + 512));
+
+            pat += 1; // step past %
+            switch (*pat)
+            {
+            case '\0':
+                // fails miserably if the last char is %
+                *fpat++ = '%'; *fpat++ = '%';
+                break;
+            case 'C':
+                // %C is replaced by the century number (the year divided by
+                // 100 and truncated to an integer) as a decimal number.
+                *fpat++ = '0' + (century / 10) % 10;
+                *fpat++ = '0' + (century % 10);
+                pat += 1;
+                break;
+            case 'D':
+                // %D same as %m/%d/%y. 
+                *fpat++ = '%'; *fpat++ = 'm'; *fpat++ = '/';
+                *fpat++ = '%'; *fpat++ = 'd'; *fpat++ = '/';
+                *fpat++ = '%'; *fpat++ = 'y'; pat += 1;
+                break;
+            case 'e':
+                // %e is replaced by the day of the month as a decimal
+                // number [1,31]; a single digit is preceded by a space.
+                if (tmb->tm_mday < 10)
+                    *fpat++ = ' ';
+                else
+                    *fpat++ = '0' + (tmb->tm_mday / 10) % 10;
+                *fpat++ = '0' + (tmb->tm_mday % 10);
+                pat += 1;
+                break;
+            case 'F':
+                // %F Equivalent to %Y - %m - %d (the ISO 8601:2000 standard
+                // date format). [ tm_year, tm_mon, tm_mday]
+                *fpat++ = '%'; *fpat++ = 'Y';
+                *fpat++ = ' '; *fpat++ = '-'; *fpat++ = ' ';
+                *fpat++ = '%'; *fpat++ = 'm';
+                *fpat++ = ' '; *fpat++ = '-'; *fpat++ = ' ';
+                *fpat++ = '%'; *fpat++ = 'd'; pat += 1;
+                break;
+            case 'g':
+                // %g Replaced by the last 2 digits of the week-based year
+                // as a decimal number [00,99]. [ tm_year, tm_wday, tm_yday] 
+                return 0;
+            case 'G':
+                // %G Replaced by the week-based year as a decimal number
+                // (for example, 1977). [ tm_year, tm_wday, tm_yday] 
+                return 0;
+            case 'h':
+                // %h same as %b. 
+                *fpat++ = '%'; *fpat++ = 'b'; pat += 1;
+                break;
+            case 'n':
+                // %n is replaced by a newline character. 
+                *fpat++ = '\n'; pat += 1;
+                break;
+            case 'r':
+                // %r is replaced by the time in a.m. and p.m. notation; in
+                // the POSIX locale this is equivalent to %I:%M:%S %p.
+                *fpat++ = '%'; *fpat++ = 'I'; *fpat++ = ':';
+                *fpat++ = '%'; *fpat++ = 'M'; *fpat++ = ':';
+                *fpat++ = '%'; *fpat++ = 'S'; *fpat++ = ' ';
+                *fpat++ = '%'; *fpat++ = 'p'; pat += 1;
+                break;
+            case 'R':
+                // %R is replaced by the time in 24 hour notation (%H:%M).
+                *fpat++ = '%'; *fpat++ = 'H'; *fpat++ = ':';
+                *fpat++ = '%'; *fpat++ = 'M'; pat += 1;
+                break;
+            case 't':
+                // %t is replaced by a tab character. 
+                *fpat++ = '\t'; pat += 1;
+                break;
+            case 'T':
+                // %T is replaced by the time (%H:%M:%S). 
+                *fpat++ = '%'; *fpat++ = 'H'; *fpat++ = ':';
+                *fpat++ = '%'; *fpat++ = 'M'; *fpat++ = ':';
+                *fpat++ = '%'; *fpat++ = 'S'; pat += 1;
+                break;
+            case 'u':
+                // %u is replaced by the weekday as a decimal number [1,7],
+                // with 1 representing Monday.
+                *fpat++ = '0' + (tmb->tm_wday + 1);                
+                pat += 1;
+                break;
+            case 'V':
+                // %V is replaced by the week number of the year (Monday as
+                // the first day of the week) as a decimal number [01,53].
+                // If the week containing 1 January has four or more days
+                // in the new year, then it is considered week 1. Otherwise,
+                // it is the last week of the previous year, and the next
+                // week is week 1. 
+                return 0;
+            default:
+                // copy percent and format
+                *fpat++ = '%';
+                *fpat++ = *pat++;
+                break;
+            }
+
+            *fpat = 0; // null terminate
+        }
+        else {
+            *fpat++ = *pat++;
+        }
+    }
+
+    // copy the null
+    *fpat = *pat;
+
+    const std::size_t n = std::strftime (buf, bufsize, patbuf, tmb);
+
+#else   // if !defined (_MSC_VER)
+
+    const std::size_t n = std::strftime (buf, bufsize, pat, tmb);
+
+#endif   // _MSC_VER
 
     RW_ASSERT (n < bufsize);
 
@@ -137,21 +284,20 @@
 { 
     static const std::tm tmp = std::tm ();
 
-#ifndef _RWSTD_NO_WCSFTIME_WCHAR_T_FMAT
+#if !defined (_RWSTD_NO_WCSFTIME_WCHAR_T_FMAT) && !defined (_MSC_VER)
 
     std::size_t n = std::wcsftime (wbuf, bufsize, wpat, tmb ? tmb : &tmp);
 
-#else   // if defined (_RWSTD_NO_WCSFTIME)
+#else   // if defined (_RWSTD_NO_WCSFTIME) || defined (_MSC_VER)
 
     char pat [1024];
     char buf [1024];
 
     narrow (pat, wpat);
-    std::size_t n = std::strftime (buf, bufsize, pat, tmb ? tmb : &tmp);
-
+    std::size_t n = rw_strftime (buf, bufsize, pat, tmb ? tmb : &tmp);
     widen (wbuf, buf);
 
-#endif   // _RWSTD_NO_WCSFTIME
+#endif   // _RWSTD_NO_WCSFTIME, _MSC_VER
 
     RW_ASSERT (n < bufsize);
 



Mime
View raw message