summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre De Dommelin <adedommelin@tuxz.net>2017-03-12 15:49:46 -0700
committerLukas Schwaighofer <lukas@schwaighofer.name>2017-03-12 15:49:46 -0700
commit9d7dc3ecede8de44f32778fd72e6ef809d1274e0 (patch)
tree9444e875c0962117a3bcad9134d21a8fe8243cd9
parent5f65da2f46554406eda093604ae5173502466755 (diff)
empty-history
# Description: Don't create an empty history file when History=0 # Author: <bdefreese@bddebian3.bddebian.com> Gbp-Pq: Name 50-empty-history.patch
-rw-r--r--src/history.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/history.cc b/src/history.cc
index 33d946c..63601aa 100644
--- a/src/history.cc
+++ b/src/history.cc
@@ -65,17 +65,19 @@ HistoryFile::sync_the_file()
if (!configuration.get_int("History", HIST_MAX_SIZE))
HIST_MAX_SIZE = 20;
- ofstream f(filename, ios::out);
+ if (HIST_MAX_SIZE) {
+ ofstream f(filename, ios::out);
- int start = 0;
- if (history.size() > (size_t)HIST_MAX_SIZE)
- start = history.size() - HIST_MAX_SIZE;
+ int start = 0;
+ if (history.size() > (size_t)HIST_MAX_SIZE)
+ start = history.size() - HIST_MAX_SIZE;
- for (size_t i = start; i < history.size(); i++)
- if (history[i].length() != 0)
- f << history[i] << endl;
+ for (size_t i = start; i < history.size(); i++)
+ if (history[i].length() != 0)
+ f << history[i] << endl;
- f.flush();
+ f.flush();
+ }
}
void