aboutsummaryrefslogtreecommitdiff
path: root/dep/acelite/ace/ACE.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/acelite/ace/ACE.cpp')
-rw-r--r--dep/acelite/ace/ACE.cpp132
1 files changed, 32 insertions, 100 deletions
diff --git a/dep/acelite/ace/ACE.cpp b/dep/acelite/ace/ACE.cpp
index 433b5e3e788..a965eff09f6 100644
--- a/dep/acelite/ace/ACE.cpp
+++ b/dep/acelite/ace/ACE.cpp
@@ -1,4 +1,4 @@
-// $Id: ACE.cpp 92298 2010-10-21 11:15:17Z johnnyw $
+// $Id: ACE.cpp 96017 2012-08-08 22:18:09Z mitza $
#include "ace/ACE.h"
@@ -25,10 +25,6 @@
#include "ace/OS_TLI.h"
#include "ace/Truncate.h"
-#if defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
-extern "C" int maxFiles;
-#endif /* ACE_VXWORKS */
-
#if !defined (__ACE_INLINE__)
#include "ace/ACE.inl"
#endif /* __ACE_INLINE__ */
@@ -68,7 +64,7 @@ ACE::out_of_handles (int error)
#elif defined (HPUX)
// On HPUX, we need to check for EADDRNOTAVAIL also.
error == EADDRNOTAVAIL ||
-#elif defined (linux)
+#elif defined (ACE_LINUX)
// On linux, we need to check for ENOENT also.
error == ENOENT ||
// For RedHat5.2, need to check for EINVAL too.
@@ -2308,7 +2304,7 @@ ACE::format_hexdump (const char *buffer,
ACE_TEXT (" "));
++obuf;
}
- textver[j] = ACE_OS::ace_isprint (c) ? c : '.';
+ textver[j] = ACE_OS::ace_isprint (c) ? c : u_char ('.');
}
textver[j] = 0;
@@ -2340,7 +2336,7 @@ ACE::format_hexdump (const char *buffer,
ACE_TEXT (" "));
++obuf;
}
- textver[i] = ACE_OS::ace_isprint (c) ? c : '.';
+ textver[i] = ACE_OS::ace_isprint (c) ? c : u_char ('.');
}
for (i = size % 16; i < 16; i++)
@@ -2371,7 +2367,8 @@ ACE::format_hexdump (const char *buffer,
// Returns the current timestamp in the form
// "hour:minute:second:microsecond." The month, day, and year are
-// also stored in the beginning of the date_and_time array.
+// also stored in the beginning of the date_and_time array
+// using ISO-8601 format.
ACE_TCHAR *
ACE::timestamp (ACE_TCHAR date_and_time[],
@@ -2386,7 +2383,10 @@ ACE::timestamp (ACE_TCHAR date_and_time[],
// Returns the given timestamp in the form
// "hour:minute:second:microsecond." The month, day, and year are
-// also stored in the beginning of the date_and_time array.
+// also stored in the beginning of the date_and_time array
+// using ISO-8601 format.
+// 012345678901234567890123456
+// 2010-12-02 12:56:00.123456<nul>
ACE_TCHAR *
ACE::timestamp (const ACE_Time_Value& time_value,
@@ -2396,92 +2396,32 @@ ACE::timestamp (const ACE_Time_Value& time_value,
{
//ACE_TRACE ("ACE::timestamp");
- if (date_and_timelen < 35)
+ // This magic number is from the formatting statement
+ // farther down this routine.
+ if (date_and_timelen < 27)
{
errno = EINVAL;
return 0;
}
-#if defined (WIN32)
- if (time_value == ACE_Time_Value::zero)
- {
- // Emulate Unix. Win32 does NOT support all the UNIX versions
- // below, so DO we need this ifdef.
- static const ACE_TCHAR *day_of_week_name[] =
- {
- ACE_TEXT ("Sun"),
- ACE_TEXT ("Mon"),
- ACE_TEXT ("Tue"),
- ACE_TEXT ("Wed"),
- ACE_TEXT ("Thu"),
- ACE_TEXT ("Fri"),
- ACE_TEXT ("Sat")
- };
-
- static const ACE_TCHAR *month_name[] =
- {
- ACE_TEXT ("Jan"),
- ACE_TEXT ("Feb"),
- ACE_TEXT ("Mar"),
- ACE_TEXT ("Apr"),
- ACE_TEXT ("May"),
- ACE_TEXT ("Jun"),
- ACE_TEXT ("Jul"),
- ACE_TEXT ("Aug"),
- ACE_TEXT ("Sep"),
- ACE_TEXT ("Oct"),
- ACE_TEXT ("Nov"),
- ACE_TEXT ("Dec")
- };
-
- SYSTEMTIME local;
- ::GetLocalTime (&local);
-
- ACE_OS::sprintf (date_and_time,
- ACE_TEXT ("%3s %3s %2d %04d %02d:%02d:%02d.%06d"),
- day_of_week_name[local.wDayOfWeek],
- month_name[local.wMonth - 1],
- (int) local.wDay,
- (int) local.wYear,
- (int) local.wHour,
- (int) local.wMinute,
- (int) local.wSecond,
- (int) (local.wMilliseconds * 1000));
- return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
- }
-#endif /* WIN32 */
- ACE_TCHAR timebuf[26]; // This magic number is based on the ctime(3c) man page.
ACE_Time_Value cur_time =
(time_value == ACE_Time_Value::zero) ?
ACE_Time_Value (ACE_OS::gettimeofday ()) : time_value;
time_t secs = cur_time.sec ();
-
- ACE_OS::ctime_r (&secs,
- timebuf,
- sizeof timebuf / sizeof (ACE_TCHAR));
- // date_and_timelen > sizeof timebuf!
- ACE_OS::strsncpy (date_and_time,
- timebuf,
- date_and_timelen);
- ACE_TCHAR yeartmp[5];
- ACE_OS::strsncpy (yeartmp,
- &date_and_time[20],
- 5);
- ACE_TCHAR timetmp[9];
- ACE_OS::strsncpy (timetmp,
- &date_and_time[11],
- 9);
- ACE_OS::sprintf (&date_and_time[11],
-# if defined (ACE_USES_WCHAR)
- ACE_TEXT ("%ls %ls.%06ld"),
-# else
- ACE_TEXT ("%s %s.%06ld"),
-# endif /* ACE_USES_WCHAR */
- yeartmp,
- timetmp,
- cur_time.usec ());
- date_and_time[33] = '\0';
- return &date_and_time[15 + (return_pointer_to_first_digit != 0)];
+ struct tm tms;
+ ACE_OS::localtime_r (&secs, &tms);
+ ACE_OS::snprintf (date_and_time,
+ date_and_timelen,
+ ACE_TEXT ("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%06ld"),
+ tms.tm_year + 1900,
+ tms.tm_mon + 1,
+ tms.tm_mday,
+ tms.tm_hour,
+ tms.tm_min,
+ tms.tm_sec,
+ static_cast<long> (cur_time.usec()));
+ date_and_time[date_and_timelen - 1] = '\0';
+ return &date_and_time[10 + (return_pointer_to_first_digit != 0)];
}
// This function rounds the request to a multiple of the page size.
@@ -2866,9 +2806,7 @@ ACE::max_handles (void)
#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */
#if defined (_SC_OPEN_MAX)
- return ACE_OS::sysconf (_SC_OPEN_MAX);
-#elif defined (ACE_VXWORKS) && (ACE_VXWORKS < 0x620)
- return maxFiles;
+ return static_cast<int> (ACE_OS::sysconf (_SC_OPEN_MAX));
#elif defined (FD_SETSIZE)
return FD_SETSIZE;
#else
@@ -2915,7 +2853,7 @@ ACE::set_handle_limit (int new_limit,
#if !defined (ACE_LACKS_RLIMIT) && defined (RLIMIT_NOFILE)
rl.rlim_cur = new_limit;
return ACE_OS::setrlimit (RLIMIT_NOFILE, &rl);
-#elif defined (ACE_LACKS_RLIMIT_NOFILE)
+#elif !defined (RLIMIT_NOFILE)
return 0;
#else
// Must return EINVAL errno.
@@ -3342,10 +3280,7 @@ ACE::strnew (const char *s)
ACE_NEW_RETURN (t,
char [ACE_OS::strlen (s) + 1],
0);
- if (t == 0)
- return 0;
- else
- return ACE_OS::strcpy (t, s);
+ return ACE_OS::strcpy (t, s);
}
#if defined (ACE_HAS_WCHAR)
@@ -3358,10 +3293,7 @@ ACE::strnew (const wchar_t *s)
ACE_NEW_RETURN (t,
wchar_t[ACE_OS::strlen (s) + 1],
0);
- if (t == 0)
- return 0;
- else
- return ACE_OS::strcpy (t, s);
+ return ACE_OS::strcpy (t, s);
}
#endif /* ACE_HAS_WCHAR */
@@ -3400,7 +3332,7 @@ namespace
// characters are allowed as the range endpoints. These characters
// are the same values in both signed and unsigned chars so we
// don't have to account for any "pathological cases."
- for (char range = p[-1] + 1; range <= p[1]; ++range)
+ for (char range = static_cast<char> (p[-1] + 1); range <= p[1]; ++range)
{
if (equal_char (s, range, case_sensitive))
{