>From 6333669d7dc9525eb8103d993d6bf90c002c97d0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Sep 2016 03:38:34 +0000 Subject: [PATCH 03/10] internals: match_str: Document 'savw'. Avoid magic number. All callees checked to ensure that they only check that parameter for nonzeroness. --- Src/Zle/compmatch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 1e5f551..654eec4 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -637,7 +637,7 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, * LOST: Documentation comment. Last seen 10 years ago in the temporal lobe. * Reward promised for its safe return. Contact zsh-workers@zsh.org. */ - char *tp, savl = '\0', savw; + char *tp, savl = '\0'; /* * The anchor on this end. */ @@ -717,15 +717,18 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, !match_parts(l + aoff , tp - moff, alen, part)) break; if (sfx) { + /* Call ourselves recursively with the + * anchor removed. */ + char savw; if ((savw = tp[-alen])) tp[-alen] = '\0'; t = match_str(l - ll, w - lw, - NULL, 0, NULL, 1, 2, part); + NULL, 0, NULL, sfx, 2, part); if (savw) tp[-alen] = savw; } else t = match_str(l + llen + moff, tp + moff, - NULL, 0, NULL, 0, 1, part); + NULL, 0, NULL, sfx, 1, part); if (t || (mp->wlen == -1 && !both)) break; }