stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r454300 - /incubator/stdcxx/trunk/src/time_put.cpp
Date Mon, 09 Oct 2006 07:48:36 GMT
Author: faridz
Date: Mon Oct  9 00:48:35 2006
New Revision: 454300

URL: http://svn.apache.org/viewvc?view=rev&rev=454300
Log:
2006-10-09 Farid Zaripov <faridz@kyiv.vdiweb.com>

	STDCXX-93
	* time_put.cpp (__rw_get_timepunct): Corrected buffer size in
	wcsftime() calls; _RWSTD_SIZE_MAX changed to size of source
	string in mbstowcs() calls to deal with MSVC 8.0 CRT

Modified:
    incubator/stdcxx/trunk/src/time_put.cpp

Modified: incubator/stdcxx/trunk/src/time_put.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/time_put.cpp?view=diff&rev=454300&r1=454299&r2=454300
==============================================================================
--- incubator/stdcxx/trunk/src/time_put.cpp (original)
+++ incubator/stdcxx/trunk/src/time_put.cpp Mon Oct  9 00:48:35 2006
@@ -623,7 +623,7 @@
         // widen the narrow (multibyte) string into the allocated buffer
         // (at an appropriately aligned offset) and set its offset
         wchar_t* const pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        size = mbstowcs (pwbuf, str, size);
+        size = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
         if (_RWSTD_SIZE_MAX == size) {
             // conversion failure - should not happen
@@ -708,13 +708,13 @@
 #    ifndef _RWSTD_NO_WCSFTIME
 
         wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        len = wcsftime (pwbuf, bufsize - off, L"%a", &t);
+        len = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%a", &t);
 
         pun->abday_off [1][t.tm_wday]  = off;
         off                           += (len + 1) * sizeof (wchar_t);
 
         pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        len   = wcsftime (pwbuf, bufsize - off, L"%A", &t);
+        len   = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%A", &t);
 
         pun->day_off [1][t.tm_wday]  = off;
         off                         += (len + 1) * sizeof (wchar_t);
@@ -727,7 +727,8 @@
             _RWSTD_STATIC_CAST (const char*, pun->abday (t.tm_wday, 0));
 
         wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        _RWSTD_SIZE_T size = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+        _RWSTD_SIZE_T size =
+            mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
         if (_RWSTD_SIZE_MAX == size) {
             // conversion failure - should not happen
@@ -744,7 +745,7 @@
 
         str   = _RWSTD_STATIC_CAST (const char*, pun->day (t.tm_wday, 0));
         pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+        size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
         if (_RWSTD_SIZE_MAX == size) {
             // conversion failure - should not happen
@@ -787,13 +788,13 @@
 #    ifndef _RWSTD_NO_WCSFTIME
 
         wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        len = wcsftime (pwbuf, bufsize - off, L"%b", &t);
+        len = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%b", &t);
 
         pun->abmon_off [1][t.tm_mon]  = off;
         off                          += (len + 1) * sizeof (wchar_t);
 
         pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        len   = wcsftime (pwbuf, bufsize - off, L"%B", &t);
+        len   = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%B", &t);
 
         pun->mon_off [1][t.tm_mon]  = off;
         off                        += (len + 1) * sizeof (wchar_t);
@@ -804,9 +805,9 @@
         // (at an appropriately aligned offset) and set its offset
         const char *str =
             _RWSTD_STATIC_CAST (const char*, pun->abmon (t.tm_mon, 0));
-
         wchar_t *pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        _RWSTD_SIZE_T size = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+        _RWSTD_SIZE_T size =
+            mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
         if (_RWSTD_SIZE_MAX == size) {
             // conversion failure - should not happen
@@ -823,7 +824,7 @@
 
         str   = _RWSTD_STATIC_CAST (const char*, pun->mon (t.tm_mon, 0));
         pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-        size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+        size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
         if (_RWSTD_SIZE_MAX == size) {
             // conversion failure - should not happen
@@ -906,13 +907,13 @@
 
     t.tm_hour = 1;
     pwbuf     = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    len       = wcsftime (pwbuf, bufsize - off, L"%p", &t);
+    len       = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%p", &t);
     pun->am_pm_off [1][0] = off;
     off += (len + 1) * sizeof (wchar_t);
     
     t.tm_hour = 13;
     pwbuf     = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    len       = wcsftime (pwbuf, bufsize - off, L"%p", &t);
+    len       = wcsftime (pwbuf, (bufsize - off) / sizeof (*pwbuf), L"%p", &t);
     pun->am_pm_off [1][1] = off;
     off += (len + 1) * sizeof (wchar_t);
 
@@ -920,7 +921,7 @@
 
     str   = _RWSTD_STATIC_CAST (const char*, pun->am_pm (0, 0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen
@@ -937,7 +938,7 @@
 
     str   = _RWSTD_STATIC_CAST (const char*, pun->am_pm (1, 0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen
@@ -957,7 +958,7 @@
     // convert "%x" to its wide equivalent
     str   = _RWSTD_STATIC_CAST (const char*, pun->d_fmt (0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen
@@ -975,7 +976,7 @@
     // convert "%X" to its wide equivalent
     str   = _RWSTD_STATIC_CAST (const char*, pun->t_fmt (0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen
@@ -993,7 +994,7 @@
     // convert "%c" to its wide equivalent
     str   = _RWSTD_STATIC_CAST (const char*, pun->d_t_fmt (0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen
@@ -1011,7 +1012,7 @@
     // convert "%r" to its wide equivalent
     str   = _RWSTD_STATIC_CAST (const char*, pun->t_fmt_ampm (0));
     pwbuf = _RWSTD_REINTERPRET_CAST (wchar_t*, pbuf + off);
-    size  = mbstowcs (pwbuf, str, _RWSTD_SIZE_MAX);
+    size  = mbstowcs (pwbuf, str, (bufsize - off) / sizeof (*pwbuf));
 
     if (_RWSTD_SIZE_MAX == size) {
         // conversion failure - should not happen



Mime
View raw message