From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH 1/4] internal: Document and simplify multiquote().
Date: Tue, 1 Nov 2016 17:26:08 +0000 [thread overview]
Message-ID: <1478021171-22495-1-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)
The code simplifications take advantage of the fact that all callers
pass either 0 or 1 for 'ign'.
The tildequote() text is from workers/39271.
---
Src/Zle/compcore.c | 22 +++++++++++++++++-----
Src/Zle/complete.c | 2 +-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 5443018..f69f680 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1043,6 +1043,13 @@ makecomplist(char *s, int incmd, int lst)
}
}
+/*
+ * Quote 's' according to compqstack, aka $compstate[all_quotes].
+ *
+ * If 'ign' is 1, skip the innermost quoting level. Otherwise 'ign'
+ * must be 0.
+ */
+
/**/
mod_export char *
multiquote(char *s, int ign)
@@ -1050,12 +1057,11 @@ multiquote(char *s, int ign)
if (s) {
char *os = s, *p = compqstack;
- if (p && *p && (ign < 1 || p[ign])) {
- if (ign > 0)
- p += ign;
+ if (p && *p && (ign == 0 || p[1])) {
+ if (ign)
+ p++;
while (*p) {
- if (ign >= 0 || p[1])
- s = quotestring(s, *p);
+ s = quotestring(s, *p);
p++;
}
}
@@ -1065,6 +1071,12 @@ multiquote(char *s, int ign)
return NULL;
}
+/*
+ * tildequote(s, ign): Equivalent to multiquote(s, ign), except that if
+ * compqstack[0] == QT_BACKSLASH and s[0] == '~', then that tilde is not
+ * quoted.
+ */
+
/**/
mod_export char *
tildequote(char *s, int ign)
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 4bf238f..7361934 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -52,7 +52,7 @@ char **compwords,
*compqiprefix,
*compqisuffix,
*compquote,
- *compqstack,
+ *compqstack, /* compstate[all_quotes] */
*comppatmatch,
*complastprompt;
/**/
next reply other threads:[~2016-11-01 17:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 17:26 Daniel Shahaf [this message]
2016-11-01 17:26 ` [PATCH 2/4] internal: Document bin_compadd() Daniel Shahaf
2016-11-01 17:26 ` [PATCH 3/4] internal: Document matchspec flags Daniel Shahaf
2016-11-01 17:26 ` [PATCH 4/4] internal: Document some compadd internals Daniel Shahaf
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=1478021171-22495-1-git-send-email-danielsh@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@zsh.org \
/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).