Author: carnold
Date: Tue Nov  1 19:49:23 2005
New Revision: 330179

URL: http://svn.apache.org/viewcvs?rev=330179&view=rev
Log:
LOGCXX-110: Eliminate intptr type in thead name generation

Modified:
    logging/log4cxx/trunk/include/log4cxx/helpers/stringhelper.h
    logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.h.in
    logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.hw
    logging/log4cxx/trunk/src/loggingevent.cpp
    logging/log4cxx/trunk/src/stringhelper.cpp
    logging/log4cxx/trunk/tests/src/patternlayouttest.cpp
    logging/log4cxx/trunk/tests/src/util/threadfilter.cpp
    logging/log4cxx/trunk/tests/src/util/xmlthreadfilter.cpp

Modified: logging/log4cxx/trunk/include/log4cxx/helpers/stringhelper.h
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/include/log4cxx/helpers/stringhelper.h?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/helpers/stringhelper.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/helpers/stringhelper.h Tue Nov  1 
19:49:23 2005
@@ -53,8 +53,6 @@
 
             static LogString toString(bool val);
 
-            static LogString formatHex(const void* handle);
-
             static std::string toLowerCase(const std::string& s);
 
             static bool getline(std::string& buf, std::string& line);

Modified: logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.h.in
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.h.in?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.h.in 
(original)
+++ logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.h.in Tue Nov  
1 19:49:23 2005
@@ -43,10 +43,6 @@
 typedef log4cxx_int64_t log4cxx_time_t;
 typedef int log4cxx_status_t;
 
-//
-//   unsigned int same size as void*
-//
-typedef unsigned int log4cxx_intptr_t;
 
 #define LOG4CXX_LOCALE_ENCODING_UTF8 0
 #define LOG4CXX_LOCALE_ENCODING_ISO_8859_1 0

Modified: logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.hw
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.hw?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.hw (original)
+++ logging/log4cxx/trunk/include/log4cxx/private/log4cxx_private.hw Tue Nov  1 
19:49:23 2005
@@ -66,11 +66,5 @@
 #endif
 #endif
 
-#if defined(_WIN64)
-typedef unsigned long long log4cxx_intptr_t;
-#else
-typedef unsigned int log4cxx_intptr_t;
-#endif
-
 
 #endif

Modified: logging/log4cxx/trunk/src/loggingevent.cpp
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/src/loggingevent.cpp?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/loggingevent.cpp (original)
+++ logging/log4cxx/trunk/src/loggingevent.cpp Tue Nov  1 19:49:23 2005
@@ -26,9 +26,11 @@
 #include <log4cxx/helpers/socket.h>
 #include <log4cxx/helpers/aprinitializer.h>
 #include <log4cxx/helpers/threadspecificdata.h>
+#include <log4cxx/helpers/transcoder.h>
 
 #include <apr_time.h>
 #include <apr_portable.h>
+#include <apr_strings.h>
 #include <log4cxx/helpers/stringhelper.h>
 
 using namespace log4cxx;
@@ -192,7 +194,17 @@
 
 const LogString LoggingEvent::getCurrentThreadName() {
 #if APR_HAS_THREADS
-   return StringHelper::formatHex((const void*) apr_os_thread_current());
+   apr_os_thread_t threadId = apr_os_thread_current();
+
+   // apr_os_thread_t encoded in HEX takes needs as many characters
+   // as two times the size of the type, plus an additional null byte
+   char result[sizeof(apr_os_thread_t) * 2 + 10];
+   result[0] = '0';
+   result[1] = 'x';
+   apr_snprintf(result+2, (sizeof result) - 2, "%pt", &threadId);
+
+   LOG4CXX_DECODE_CHAR(str, result);
+   return str;
 #else
    return LOG4CXX_STR("0x00000000");
 #endif

Modified: logging/log4cxx/trunk/src/stringhelper.cpp
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/src/stringhelper.cpp?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/stringhelper.cpp (original)
+++ logging/log4cxx/trunk/src/stringhelper.cpp Tue Nov  1 19:49:23 2005
@@ -279,18 +279,3 @@
   toString((log4cxx_int64_t) n, pool, ws);
 }
 #endif
-
-
-
-LogString StringHelper::formatHex(const void* ptr) {
-    const logchar* hexdigits = LOG4CXX_STR("0123456789ABCDEF");
-    log4cxx_intptr_t iptr = (log4cxx_intptr_t) ptr;
-    int width = sizeof(ptr)*2 + 2;
-    LogString s(width, LOG4CXX_STR('x'));
-    s[0] = LOG4CXX_STR('0');
-    for(int i = width - 1; i >= 2; i--) {
-      s[i] = hexdigits[iptr & 0x0F];
-      iptr = iptr >> 4;
-    }
-    return s;
-}

Modified: logging/log4cxx/trunk/tests/src/patternlayouttest.cpp
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/tests/src/patternlayouttest.cpp?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/tests/src/patternlayouttest.cpp (original)
+++ logging/log4cxx/trunk/tests/src/patternlayouttest.cpp Tue Nov  1 19:49:23 
2005
@@ -283,7 +283,7 @@
                 //
                 //   combo of relative time and thread identifier
                 //     (the \\\\1 preserve a leading space)
-                Filter filter2(".*0x[0-9A-F]*]", "[main]");
+                Filter filter2(".*0x[0-9A-Fa-f]*]", "[main]");
 
                 std::vector<Filter *> filters;
 

Modified: logging/log4cxx/trunk/tests/src/util/threadfilter.cpp
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/tests/src/util/threadfilter.cpp?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/tests/src/util/threadfilter.cpp (original)
+++ logging/log4cxx/trunk/tests/src/util/threadfilter.cpp Tue Nov  1 19:49:23 
2005
@@ -19,4 +19,4 @@
 using namespace log4cxx;
 using namespace log4cxx::helpers;
 
-ThreadFilter::ThreadFilter() : Filter("\\[0x[0-9A-F]*]", "\\[main]") {}
+ThreadFilter::ThreadFilter() : Filter("\\[0x[0-9A-Fa-f]*]", "\\[main]") {}

Modified: logging/log4cxx/trunk/tests/src/util/xmlthreadfilter.cpp
URL: 
http://svn.apache.org/viewcvs/logging/log4cxx/trunk/tests/src/util/xmlthreadfilter.cpp?rev=330179&r1=330178&r2=330179&view=diff
==============================================================================
--- logging/log4cxx/trunk/tests/src/util/xmlthreadfilter.cpp (original)
+++ logging/log4cxx/trunk/tests/src/util/xmlthreadfilter.cpp Tue Nov  1 
19:49:23 2005
@@ -20,5 +20,5 @@
 using namespace log4cxx::helpers;
 
 XMLThreadFilter::XMLThreadFilter()
-     : Filter("0x[0-9A-F]*", "main") {
+     : Filter("0x[0-9A-Fa-f]*", "main") {
 }


Reply via email to