summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2011-04-15 19:55:50 -0400
committerMathias Stearn <mathias@10gen.com>2011-04-15 19:55:50 -0400
commitd3574a11cb6930aaaa1915ad5965426d492f3b7a (patch)
tree1b083c75926aa6ac5a21c603885290863655b1d4 /third_party
parent2892c6daf9d6c5a9686805380cc8b1457db19faf (diff)
downloadmongo-d3574a11cb6930aaaa1915ad5965426d492f3b7a.tar.gz
don't save or load blank history lines
Diffstat (limited to 'third_party')
-rw-r--r--third_party/linenoise/linenoise.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/third_party/linenoise/linenoise.cpp b/third_party/linenoise/linenoise.cpp
index 2443177b984..c20d3a552b3 100644
--- a/third_party/linenoise/linenoise.cpp
+++ b/third_party/linenoise/linenoise.cpp
@@ -723,8 +723,10 @@ int linenoiseHistorySave(const char *filename) {
int j;
if (fp == NULL) return -1;
- for (j = 0; j < history_len; j++)
- fprintf(fp,"%s\n",history[j]);
+ for (j = 0; j < history_len; j++){
+ if (history[j][0] != '\0')
+ fprintf(fp,"%s\n",history[j]);
+ }
fclose(fp);
return 0;
}
@@ -746,7 +748,8 @@ int linenoiseHistoryLoad(const char *filename) {
p = strchr(buf,'\r');
if (!p) p = strchr(buf,'\n');
if (p) *p = '\0';
- linenoiseHistoryAdd(buf);
+ if (p != buf)
+ linenoiseHistoryAdd(buf);
}
fclose(fp);
return 0;