diff options
author | Alexandre De Dommelin <adedommelin@tuxz.net> | 2017-03-12 15:49:46 -0700 |
---|---|---|
committer | Lukas Schwaighofer <lukas@schwaighofer.name> | 2017-03-12 15:49:46 -0700 |
commit | 9d7dc3ecede8de44f32778fd72e6ef809d1274e0 (patch) | |
tree | 9444e875c0962117a3bcad9134d21a8fe8243cd9 /src/history.cc | |
parent | 5f65da2f46554406eda093604ae5173502466755 (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
Diffstat (limited to 'src/history.cc')
-rw-r--r-- | src/history.cc | 18 |
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 |