summaryrefslogtreecommitdiff
path: root/desktop/gmrun/patches/50-empty-history.patch
blob: 7f9477f7b60041c5e42b598cdf854e364dbe7e92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Description: Don't create an empty history file when History=0
# Author: <bdefreese@bddebian3.bddebian.com>

Index: gmrun-0.9.2/src/history.cc
===================================================================
--- gmrun-0.9.2.orig/src/history.cc	2010-02-03 12:33:29.575767540 +0800
+++ gmrun-0.9.2/src/history.cc	2010-02-03 12:34:47.349422238 +0800
@@ -65,17 +65,19 @@
   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