diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-11-01 17:26:08 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-11-03 16:44:14 +0000 |
commit | 36b290814f5c2176f67f10746d5e899ccc260a67 (patch) | |
tree | 5ad53d0b21bbf4ae574fddfcc54c181156753cfe | |
parent | 0e9faf67aa44e5de814d25925320d9e7dcfdaf09 (diff) | |
download | zsh-36b290814f5c2176f67f10746d5e899ccc260a67.tar.gz zsh-36b290814f5c2176f67f10746d5e899ccc260a67.tar.xz zsh-36b290814f5c2176f67f10746d5e899ccc260a67.zip |
39802: internal: Document and simplify multiquote().
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.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/Zle/compcore.c | 22 | ||||
-rw-r--r-- | Src/Zle/complete.c | 2 |
3 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog index 4a08d2664..63b9342c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-11-03 Daniel Shahaf <d.s@daniel.shahaf.name> + * 39802: Src/Zle/compcore.c, Src/Zle/complete.c: internal: + Document and simplify multiquote(). + * users/22063: Doc/Zsh/zle.yo: bracketed-paste: Document ability to specify a vi register. (after users/22036) diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 5443018d8..f69f68091 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 4bf238fab..73619347c 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; /**/ |