From f37fa9293fa128e657d4e124ac1aa25086f65847 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 14 Sep 2016 03:38:35 +0000 Subject: 39310/0008: internals: match_str: Document several local variables. --- ChangeLog | 3 +++ Src/Zle/compmatch.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7ff75b86..f1d2c02d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-09-16 Daniel Shahaf + * 39310/0008: Src/Zle/compmatch.c: internals: match_str: + Document several local variables. + * 39310/0007: Src/Zle/compmatch.c: internals: match_str: Rename and constify local variables 'oll', 'olw'. diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index f670de781..0c6270dee 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -500,8 +500,16 @@ 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 +519,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; @@ -629,6 +639,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; /* -- cgit 1.4.1