summaryrefslogtreecommitdiff
path: root/ace/OS.i
diff options
context:
space:
mode:
Diffstat (limited to 'ace/OS.i')
-rw-r--r--ace/OS.i34
1 files changed, 19 insertions, 15 deletions
diff --git a/ace/OS.i b/ace/OS.i
index baccaa91c4f..d98d66bc6ad 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -8471,6 +8471,9 @@ ACE_OS::difftime (time_t t1, time_t t0)
}
#endif /* ! ACE_LACKS_DIFFTIME */
+// Magic number declaration and definition for ctime and ctime_r ()
+static int ctime_buf_size = 26;
+
ACE_INLINE ACE_TCHAR *
ACE_OS::ctime (const time_t *t)
{
@@ -8480,8 +8483,10 @@ ACE_OS::ctime (const time_t *t)
#elif defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
return "ctime-return";
#elif defined (ACE_HAS_WINCE)
- static ACE_TCHAR buf[26]; // 26 is a "magic number" ;)
- return ACE_OS::ctime_r (t, buf, 26);
+ static ACE_TCHAR buf [ctime_buf_size];
+ return ACE_OS::ctime_r (t,
+ buf,
+ ctime_buf_size);
#elif defined (ACE_USES_WCHAR)
ACE_OSCALL_RETURN (::_wctime (t), wchar_t *, 0);
#else
@@ -8493,19 +8498,20 @@ ACE_OS::ctime (const time_t *t)
ACE_INLINE ACE_TCHAR *
ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen)
{
- ACE_OS_TRACE ("ACE_OS::ctime_r");
+ACE_OS_TRACE ("ACE_OS::ctime_r");
+
#if defined (ACE_HAS_REENTRANT_FUNCTIONS)
# if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R)
- ACE_TCHAR *result;
+ ACE_TCHAR *result ;
+ ACE_TCHAR result_buf[ctime_buf_size];
+
# if defined (DIGITAL_UNIX)
- ACE_OSCALL (::_Pctime_r (t, buf), ACE_TCHAR *, 0, result);
+ ACE_OSCALL (::_Pctime_r (t, result_buf), ACE_TCHAR *, 0, result);
# else /* DIGITAL_UNIX */
- ACE_OSCALL (::ctime_r (t, buf), ACE_TCHAR *, 0, result);
+ ACE_OSCALL (::ctime_r (t, result_buf), ACE_TCHAR *, 0, result);
# endif /* DIGITAL_UNIX */
if (result != 0)
- // This needs to be <ACE_OS::strncpy> rather than
- // <ACE_OS::strsncpy> to avoid problems on certain platforms.
- ACE_OS::strncpy (buf, result, buflen);
+ ACE_OS::strsncpy (buf, result, buflen);
return buf;
# else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
@@ -8517,8 +8523,8 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen)
# endif /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */
#else /* ACE_HAS_REENTRANT_FUNCTIONS */
-# if defined (ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
- ACE_OS::strsncpy (buf, "ctime-return", buflen);
+# if defined(ACE_PSOS) && ! defined (ACE_PSOS_HAS_TIME)
+ ACE_OS::strsncpy(buf, "ctime-return", buflen);
return buf;
# else /* ACE_PSOS && !ACE_PSOS_HAS_TIME */
@@ -8526,12 +8532,10 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen)
# if defined (ACE_USES_WCHAR)
ACE_OSCALL (::_wctime (t), wchar_t *, 0, result);
# else /* ACE_WIN32 */
- ACE_OSCALL (::ctime (t), char *, 0, result);
+ACE_OSCALL (::ctime (t), char *, 0, result);
# endif /* ACE_WIN32 */
if (result != 0)
- // This needs to be <ACE_OS::strncpy> rather than
- // <ACE_OS::strsncpy> to avoid problems on certain platforms.
- ACE_OS::strncpy (buf, result, buflen);
+ ACE_OS::strsncpy (buf, result, buflen);
return buf;
# endif /* ACE_PSOS && !ACE_PSOS_HAS_TIME */
#endif /* ACE_HAS_REENTRANT_FUNCTIONS */