diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-11-02 09:52:58 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-11-02 09:52:58 -0500 |
commit | d1057d5a9dbb916ed57a2b00900884d417bbf3c0 (patch) | |
tree | ecfe0907db720d8ba4f47337027b403161a59f12 /tools/import.cpp | |
parent | 9ecceafbca1c0f88ec69aa659f12a7098f563095 (diff) | |
download | mongo-d1057d5a9dbb916ed57a2b00900884d417bbf3c0.tar.gz |
clean trailing spaces when importing json SERVER-402
Diffstat (limited to 'tools/import.cpp')
-rw-r--r-- | tools/import.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/import.cpp b/tools/import.cpp index 339496c84d3..09f3a92b4ea 100644 --- a/tools/import.cpp +++ b/tools/import.cpp @@ -94,9 +94,15 @@ class Import : public Tool { b.append( fieldName.c_str() , data ); } - BSONObj parseLine( const char * line ){ - if ( _type == JSON ) + BSONObj parseLine( char * line ){ + if ( _type == JSON ){ + char * end = ( line + strlen( line ) ) - 1; + while ( isspace(*end) ){ + *end = 0; + end--; + } return fromjson( line ); + } BSONObjBuilder b; @@ -113,7 +119,7 @@ class Import : public Tool { } pos++; - const char * end = strstr( line , _sep ); + char * end = strstr( line , _sep ); if ( ! end ){ _append( b , name , string( line ) ); break; |