You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/04/14 00:02:37 UTC

svn commit: r1325978 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang: Integer.cpp Long.cpp

Author: tabish
Date: Fri Apr 13 22:02:37 2012
New Revision: 1325978

URL: http://svn.apache.org/viewvc?rev=1325978&view=rev
Log:
Apply patch: https://issues.apache.org/jira/browse/AMQCPP-375

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp?rev=1325978&r1=1325977&r2=1325978&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp Fri Apr 13 22:02:37 2012
@@ -193,9 +193,10 @@ std::string Integer::toBinaryString( int
 std::string Integer::toOctalString( int value ) {
 
     int count = 1, j = value;
+    unsigned int uvalue = (unsigned int) value;
 
     if( value < 0 ) {
-        count = 11;
+        count = 11;  // (8 * sizeof(value) + 2) / 3;
     } else {
         while ( (j >>= 3) != 0 ) {
             count++;
@@ -208,8 +209,8 @@ std::string Integer::toOctalString( int 
     char* buffer = new char[length + 1];
 
     do {
-        buffer[--count] = (char)( (value & 7) + '0' );
-        value >>= 3;
+        buffer[--count] = (char)( (uvalue & 7) + '0' );
+        uvalue >>= 3;
     } while( count > 0 );
 
     // Ensure there's a null

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp?rev=1325978&r1=1325977&r2=1325978&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp Fri Apr 13 22:02:37 2012
@@ -378,7 +378,7 @@ std::string Long::toBinaryString( long l
     long long j = value;
 
     if( value < 0 ) {
-        count = 32;
+        count = 64;  // 8 * sizeof(long long);
     } else {
         while ( (j >>= 1) != 0) {
             count++;
@@ -408,9 +408,10 @@ std::string Long::toOctalString( long lo
 
     int count = 1;
     long long j = value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     if( value < 0 ) {
-        count = 11;
+        count = 22; // (8 * sizeof(long long) + 2) / 3;
     } else {
         while ( (j >>= 3) != 0 ) {
             count++;
@@ -424,7 +425,7 @@ std::string Long::toOctalString( long lo
 
     do {
         buffer[--count] = (char)( (value & 7) + '0' );
-        value >>= 3;
+        uvalue >>= 3;
     } while( count > 0 );
 
     // Ensure there's a null
@@ -442,7 +443,7 @@ std::string Long::toHexString( long long
     long long j = value;
 
     if( value < 0 ) {
-        count = 8;
+        count = 16; // 8 * sizeof(long long) / 4
     } else {
         while( (j >>= 4) != 0 ) {
             count++;