[wiki] [sites] [dmenu][patch][navhistory] Bug fix: Write first entry to history file || Max Schillinger

From: <git_AT_suckless.org>
Date: Fri, 09 Jul 2021 17:47:12 +0200

commit f759877d393eaed126dfc8e56932c49e7581a181
Author: Max Schillinger <maxschillinger_AT_web.de>
Date: Fri Jul 9 17:41:34 2021 +0200

    [dmenu][patch][navhistory] Bug fix: Write first entry to history file
    
    - Bug fix: Don't skip writing first entry to history file. This happened for
      `histnodup` = 1 (default) plus `histsz` = 0 (value when starting with an
      empty history).
    - Rename `dmenu-navhistory-20200709.diff` to `dmenu-navhistory-5.0.diff`
      because the only change to dmenu since 2020-07-09 was bumping the
      version number to 5.0.

diff --git a/tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-20200709.diff b/tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-5.0.diff
similarity index 89%
rename from tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-20200709.diff
rename to tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-5.0.diff
index 4acd9970..1f7cf6c8 100644
--- a/tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-20200709.diff
+++ b/tools.suckless.org/dmenu/patches/navhistory/dmenu-navhistory-5.0.diff
_AT_@ -1,3 +1,15 @@
+From a4a08baf35edb6b50ed14f76e99d0c6fe790759d Mon Sep 17 00:00:00 2001
+From: Max Schillinger <maxschillinger_AT_web.de>
+Date: Fri, 9 Jul 2021 17:17:36 +0200
+Subject: [PATCH] Bug fix: Writing first entry to history file was skipped
+
+---
+ config.def.h | 2 +
+ dmenu.1 | 5 ++
+ dmenu.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++-
+ dmenu_run | 2 +-
+ 4 files changed, 151 insertions(+), 2 deletions(-)
+
 diff --git a/config.def.h b/config.def.h
 index 1edb647..e3e1b53 100644
 --- a/config.def.h
_AT_@ -8,7 +20,7 @@ index 1edb647..e3e1b53 100644
  static unsigned int lines = 0;
 +static unsigned int maxhist = 64;
 +static int histnodup = 1; /* if 0, record repeated histories */
-
+
  /*
   * Characters not considered part of a word while deleting words
 diff --git a/dmenu.1 b/dmenu.1
_AT_@ -35,24 +47,24 @@ index 323f93c..ff496dd 100644
  dmenu is completely controlled by the keyboard. Items are selected using the
  arrow keys, page up, page down, home, and end.
 diff --git a/dmenu.c b/dmenu.c
-index 65f25ce..9d15f78 100644
+index 65f25ce..5023257 100644
 --- a/dmenu.c
 +++ b/dmenu.c
 _AT_@ -53,6 +53,10 @@ static XIC xic;
  static Drw *drw;
  static Clr *scheme[SchemeLast];
-
+
 +static char *histfile;
 +static char **history;
 +static size_t histsz, histpos;
 +
  #include "config.h"
-
+
  static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
 _AT_@ -304,6 +308,129 @@ movewordedge(int dir)
          }
  }
-
+
 +static void
 +loadhistory(void)
 +{
_AT_@ -160,7 +172,7 @@ index 65f25ce..9d15f78 100644
 + die("failed to write to %s", histfile);
 + }
 + }
-+ if (!histnodup || (histsz > 0 && strcmp(input, history[histsz-1]) != 0)) { /* TODO */
++ if (histsz == 0 || !histnodup || (histsz > 0 && strcmp(input, history[histsz-1]) != 0)) { /* TODO */
 + if (0 >= fputs(input, fp)) {
 + die("failed to write to %s", histfile);
 + }
_AT_@ -212,7 +224,7 @@ index 65f25ce..9d15f78 100644
 + " [-H histfile]", stderr);
          exit(1);
  }
-
+
 _AT_@ -715,6 +853,8 @@ main(int argc, char *argv[])
                  } else if (i + 1 == argc)
                          usage();
_AT_@ -225,7 +237,7 @@ index 65f25ce..9d15f78 100644
 _AT_@ -757,6 +897,8 @@ main(int argc, char *argv[])
                  die("pledge");
  #endif
-
+
 + loadhistory();
 +
          if (fast && !isatty(0)) {
_AT_@ -239,3 +251,6 @@ index 834ede5..59ec622 100755
  #!/bin/sh
 -dmenu_path | dmenu "$_AT_" | ${SHELL:-"/bin/sh"} &
 +dmenu_path | dmenu -H "${XDG_CACHE_HOME:-$HOME/.cache/}/dmenu_run.hist" "$_AT_" | ${SHELL:-"/bin/sh"} &
+--
+2.25.1
+
diff --git a/tools.suckless.org/dmenu/patches/navhistory/index.md b/tools.suckless.org/dmenu/patches/navhistory/index.md
index b49125a7..067b7f8f 100644
--- a/tools.suckless.org/dmenu/patches/navhistory/index.md
+++ b/tools.suckless.org/dmenu/patches/navhistory/index.md
_AT_@ -14,8 +14,8 @@ To change this behaviour, set 'histnodup' to 0 in config.h.
 
 Download
 --------
+* [dmenu-navhistory-5.0.diff](dmenu-navhistory-5.0.diff)
 * [dmenu-navhistory-4.6.diff](dmenu-navhistory-4.6.diff)
-* [dmenu-navhistory-20200709.diff](dmenu-navhistory-20200709.diff)
 
 ### With Search
 This patch extends navhist with history-search functionality. Press
Received on Fri Jul 09 2021 - 17:47:12 CEST

This archive was generated by hypermail 2.3.0 : Fri Jul 09 2021 - 17:48:43 CEST