summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-07-05 01:39:06 -0400
committerEliot Horowitz <eliot@10gen.com>2011-07-05 01:39:06 -0400
commit5385a59f6dc438f15d276ddc0d2a26d3bac33a04 (patch)
treea097ec8a077a1e10fe9e737a3ded7d3d8046b7db /shell
parent1c44a0e5b55ef69196fe46b96a7a583292983501 (diff)
downloadmongo-5385a59f6dc438f15d276ddc0d2a26d3bac33a04.tar.gz
arrays follow lint rules
Diffstat (limited to 'shell')
-rw-r--r--shell/mongo_vstudio.cpp20
-rw-r--r--shell/utils.js20
2 files changed, 28 insertions, 12 deletions
diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp
index 651830ace7d..f2490463703 100644
--- a/shell/mongo_vstudio.cpp
+++ b/shell/mongo_vstudio.cpp
@@ -26,7 +26,10 @@ const StringData _jscode_raw_utils =
"return s;\n"
"}\n"
"\n"
-"if ( clean(a) == clean(b) )\n"
+"a = clean(a);\n"
+"b = clean(b);\n"
+"\n"
+"if ( a == b )\n"
"return true;\n"
"\n"
"return false;\n"
@@ -384,20 +387,25 @@ const StringData _jscode_raw_utils =
"}\n"
"\n"
"\n"
-"Array.tojson = function( a , indent ){\n"
+"Array.tojson = function( a , indent , nolint ){\n"
+"var lineEnding = nolint ? \" \" : \"\\n\";\n"
+"\n"
"if (!indent)\n"
"indent = \"\";\n"
"\n"
+"if ( nolint )\n"
+"indent = \"\";\n"
+"\n"
"if (a.length == 0) {\n"
"return \"[ ]\";\n"
"}\n"
"\n"
-"var s = \"[\\n\";\n"
+"var s = \"[\" + lineEnding;\n"
"indent += \"\\t\";\n"
"for ( var i=0; i<a.length; i++){\n"
-"s += indent + tojson( a[i], indent );\n"
+"s += indent + tojson( a[i], indent , nolint );\n"
"if ( i < a.length - 1 ){\n"
-"s += \",\\n\";\n"
+"s += \",\" + lineEnding;\n"
"}\n"
"}\n"
"if ( a.length == 0 ) {\n"
@@ -405,7 +413,7 @@ const StringData _jscode_raw_utils =
"}\n"
"\n"
"indent = indent.substring(1);\n"
-"s += \"\\n\"+indent+\"]\";\n"
+"s += lineEnding+indent+\"]\";\n"
"return s;\n"
"}\n"
"\n"
diff --git a/shell/utils.js b/shell/utils.js
index 10eca2356e0..9a239dbc4a9 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -21,7 +21,10 @@ friendlyEqual = function( a , b ){
return s;
}
- if ( clean(a) == clean(b) )
+ a = clean(a);
+ b = clean(b);
+
+ if ( a == b )
return true;
return false;
@@ -379,20 +382,25 @@ Array.shuffle = function( arr ){
}
-Array.tojson = function( a , indent ){
+Array.tojson = function( a , indent , nolint ){
+ var lineEnding = nolint ? " " : "\n";
+
if (!indent)
indent = "";
+
+ if ( nolint )
+ indent = "";
if (a.length == 0) {
return "[ ]";
}
- var s = "[\n";
+ var s = "[" + lineEnding;
indent += "\t";
for ( var i=0; i<a.length; i++){
- s += indent + tojson( a[i], indent );
+ s += indent + tojson( a[i], indent , nolint );
if ( i < a.length - 1 ){
- s += ",\n";
+ s += "," + lineEnding;
}
}
if ( a.length == 0 ) {
@@ -400,7 +408,7 @@ Array.tojson = function( a , indent ){
}
indent = indent.substring(1);
- s += "\n"+indent+"]";
+ s += lineEnding+indent+"]";
return s;
}