summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-11-02 09:52:58 -0500
committerEliot Horowitz <eliot@10gen.com>2009-11-02 09:52:58 -0500
commitd1057d5a9dbb916ed57a2b00900884d417bbf3c0 (patch)
treeecfe0907db720d8ba4f47337027b403161a59f12 /tools
parent9ecceafbca1c0f88ec69aa659f12a7098f563095 (diff)
downloadmongo-d1057d5a9dbb916ed57a2b00900884d417bbf3c0.tar.gz
clean trailing spaces when importing json SERVER-402
Diffstat (limited to 'tools')
-rw-r--r--tools/import.cpp12
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;