From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13947 invoked by alias); 1 Nov 2016 17:26:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39802 Received: (qmail 28437 invoked from network); 1 Nov 2016 17:26:20 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.153627 secs); 01 Nov 2016 17:26:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=5Fh htp8TTik0OaMSc+2AS/cWXGs=; b=idf45gwQWC4xHpKEBydYRF0Ry+yy7xKlSfr sX2kTpcgdWwMWoVtlgJDsueAHJVR6Di4ii66m9tNRYuADSohWsIz2JFFI+u3vhNj 6Vp5yqlLaFAxHP0wASR/xjdKZ6r/sBsH9mDG9llvl7vRlwYpQNMcYiRuILpy3KZW syWs/JSQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=5F hhtp8TTik0OaMSc+2AS/cWXGs=; b=VIco1a1YmosUT2kI+h+fBiKgOMRydk3PYw cGz9ALaS9gYQTDEeFeRFBAF7uAnfZL26USrO+SWxSv2VblMLljHX+qv/PnakUskH vh9PvgDZKIPNCA/wzCVCtcsY2E74gokoGXvN+rjonzfdvESIx5SlB/kBhe3cszzp AlA0W6Nak= X-ME-Sender: X-Sasl-enc: Ko2BII8er3PS3jxs5AXOqyMd2cxjV9QbrBKxbvjldMvH 1478021177 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 1/4] internal: Document and simplify multiquote(). Date: Tue, 1 Nov 2016 17:26:08 +0000 Message-Id: <1478021171-22495-1-git-send-email-danielsh@fujitsu.shahaf.local2> X-Mailer: git-send-email 2.1.4 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; /**/