>From 62442f34017813d9241a2808f4ddf167e12fb68e Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Sep 2016 03:38:35 +0000 Subject: [PATCH 08/10] internals: match_str: Document several local variables. --- Src/Zle/compmatch.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 673347e..16705f6 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -500,8 +500,15 @@ int match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, const int sfx, int test, int part) { - int ll = strlen(l), lw = strlen(w), exact = 0, wexact = 0; - int il = 0, iw = 0, t, he = 0, bslash; + /* How many characters from the line string and from the word string are yet to be matched. */ + int ll = strlen(l), lw = strlen(w); + /* Number of characters from the line string and word string matched. */ + int il = 0, iw = 0; + /* How many characters were matched exactly in the line and in the word. */ + int exact = 0, wexact = 0; + int he = 0; + int bslash; + int t; char *ow; Cmlist ms; /* loop variable */ Cmatcher mp, lm = NULL; @@ -511,6 +518,8 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, const int add = (sfx ? -1 : 1); const int original_ll = ll, original_lw = lw; + /* INVARIANT: il+ll == original_ll; iw+lw == original_lw */ + if (!test) { start_match(); bp = *bpp; @@ -627,6 +636,10 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, int moff; /* * ### These two are related. + * + * ### They may have a relation similar to that of lw/iw (q.v.), + * ### at least during the 'for' loop. They may be overloaded/repurposed + * ### after it. */ int ct, ict; /*