From: Wayne Davison <wayne@clari.net>
To: zsh-workers@math.gatech.edu
Subject: Patch to add HIST_REDUCE_BLANKS
Date: Thu, 21 Nov 1996 15:02:21 -0800 [thread overview]
Message-ID: <199611212302.PAA28359@bebop.clari.net> (raw)
Here's a more modern version of my patch to remove superfluous blanks
from the history lines (and never any significant blanks, like those
in quotes). The previous version used the option HIST_STRIP_SPACES,
but I thought that the name HIST_REDUCE_BLANKS would be better so
that what is used in this patch. This is relative to zsh-3.1.0-test3.
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/globals.h
@@ -740,6 +740,7 @@
{"histignoredups", 'h', 0, 0},
{"histignorespace", 'g', 0, 0},
{"histnostore", 0, 0, 0},
+ {"histreduceblanks", 0, 0, 0},
{"histverify", 0, 0, 0},
{"hup", 0, 0, OPT_EMULATE|OPT_ZSH},
{"ignorebraces", 'I', 0, OPT_EMULATE|OPT_SH},
Index: Src/hist.c
@@ -636,6 +636,32 @@
return 0;
}
+/**/
+void
+histreduceblanks(void)
+{
+ int i, len, pos, needblank;
+
+ for (i = 0, len = 0; i < chwordpos; i += 2) {
+ len += chwords[i+1] - chwords[i]
+ + (i > 0 && chwords[i] > chwords[i-1]);
+ }
+ if (chline[len] == '\0')
+ return;
+
+ for (i = 0, pos = 0; i < chwordpos; i += 2) {
+ len = chwords[i+1] - chwords[i];
+ needblank = (i < chwordpos-2 && chwords[i+2] > chwords[i+1]);
+ if (pos != chwords[i]) {
+ memcpy(chline + pos, chline + chwords[i], len + needblank);
+ chwords[i] = pos;
+ chwords[i+1] = chwords[i] + len;
+ }
+ pos += len + needblank;
+ }
+ chline[pos] = '\0';
+}
+
/* say we're done using the history mechanism */
/**/
@@ -706,6 +732,9 @@
curhistent->ftim = 0L;
curhistent->flags = 0;
if (save) {
+ /* strip superfluous blanks, if desired */
+ if (isset(HISTREDUCEBLANKS))
+ histreduceblanks();
if (save == 2) {
/* Don't duplicate history entry, but use the current rather than
* the previous one, in case minor changes were made to it.
Index: Src/zsh.h
@@ -1107,6 +1107,7 @@
HISTIGNOREDUPS,
HISTIGNORESPACE,
HISTNOSTORE,
+ HISTREDUCEBLANKS,
HISTVERIFY,
HUP,
IGNOREBRACES,
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
reply other threads:[~1996-11-21 23:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199611212302.PAA28359@bebop.clari.net \
--to=wayne@clari.net \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).