Permalink
Browse files

SERVER-3168: Fixed hexadecimal output, added tests

  • Loading branch information...
1 parent 8c8f522 commit 403b7aa8a28094fb4f541a86d8f89c0c794ef329 @agirbal agirbal committed Jun 22, 2011
Showing with 22 additions and 4 deletions.
  1. +14 −0 jstests/binData.js
  2. +4 −2 scripting/sm_db.cpp
  3. +4 −2 scripting/v8_db.cpp
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -757,10 +757,12 @@ zzz
assert( holder );
const char *data = ( ( BinDataHolder* )( holder ) )->c_;
stringstream ss;
- ss << hex;
+ ss.setf (ios_base::hex , ios_base::basefield);
+ ss.fill ('0');
+ ss.setf (ios_base::right , ios_base::adjustfield);
for( int i = 0; i < len; i++ ) {
unsigned v = (unsigned char) data[i];
- ss << v;
+ ss << setw(2) << v;
}
string ret = ss.str();
return *rval = c.toval( ret.c_str() );
View
@@ -775,10 +775,12 @@ namespace mongo {
Local<External> c = External::Cast( *(it->GetInternalField( 0 )) );
char* data = (char*)(c->Value());
stringstream ss;
- ss << hex;
+ ss.setf (ios_base::hex , ios_base::basefield);
+ ss.fill ('0');
+ ss.setf (ios_base::right , ios_base::adjustfield);
for( int i = 0; i < len; i++ ) {
unsigned v = (unsigned char) data[i];
- ss << v;
+ ss << setw(2) << v;
}
return v8::String::New(ss.str().c_str());
}

0 comments on commit 403b7aa

Please sign in to comment.