50-empty-history.patch 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Description: Don't create an empty history file when History=0
  2. # Author: <bdefreese@bddebian3.bddebian.com>
  3. Index: gmrun-0.9.2/src/history.cc
  4. ===================================================================
  5. --- gmrun-0.9.2.orig/src/history.cc 2010-02-03 12:33:29.575767540 +0800
  6. +++ gmrun-0.9.2/src/history.cc 2010-02-03 12:34:47.349422238 +0800
  7. @@ -65,17 +65,19 @@
  8. if (!configuration.get_int("History", HIST_MAX_SIZE))
  9. HIST_MAX_SIZE = 20;
  10. - ofstream f(filename, ios::out);
  11. + if (HIST_MAX_SIZE) {
  12. + ofstream f(filename, ios::out);
  13. - int start = 0;
  14. - if (history.size() > (size_t)HIST_MAX_SIZE)
  15. - start = history.size() - HIST_MAX_SIZE;
  16. + int start = 0;
  17. + if (history.size() > (size_t)HIST_MAX_SIZE)
  18. + start = history.size() - HIST_MAX_SIZE;
  19. +
  20. + for (size_t i = start; i < history.size(); i++)
  21. + if (history[i].length() != 0)
  22. + f << history[i] << endl;
  23. - for (size_t i = start; i < history.size(); i++)
  24. - if (history[i].length() != 0)
  25. - f << history[i] << endl;
  26. -
  27. - f.flush();
  28. + f.flush();
  29. + }
  30. }
  31. void