diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2020-02-14 01:58:20 +0100 |
commit | bfc5d42735c1660263904ec5254cccf539a0a458 (patch) | |
tree | 9bbb81b4a53941427e6f9e65ae55027d9108df8c /Src/pattern.c | |
parent | 74561cc51b8867e43cb2937ab2edfb36e2a829bf (diff) | |
parent | 643de931640e01aa246723d2038328ef33737965 (diff) | |
download | zsh-bfc5d42735c1660263904ec5254cccf539a0a458.tar.gz zsh-bfc5d42735c1660263904ec5254cccf539a0a458.zip |
Merge tag 'zsh-5.7.1-test-3' into debian
Test release: 5.7.1-test-3
Diffstat (limited to 'Src/pattern.c')
-rw-r--r-- | Src/pattern.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/Src/pattern.c b/Src/pattern.c index 737f5cdcb..c7c2c8bea 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -156,7 +156,7 @@ typedef union upat *Upat; * P_BRANCH, but applies to the immediately preceding branch. The code in * the corresponding branch is followed by a P_EXCSYNC, which simply * acts as a marker that a P_EXCLUDE comes next. The P_EXCLUDE - * has a pointer to char embeded in it, which works + * has a pointer to char embedded in it, which works * like P_WBRANCH: if we get to the P_EXCSYNC, and we already matched * up to the same position, fail. Thus we are forced to backtrack * on closures in the P_BRANCH if the first attempt was excluded. @@ -502,7 +502,7 @@ patcompcharsset(void) } } -/* Called before parsing a set of file matchs to initialize flags */ +/* Called before parsing a set of file matches to initialize flags */ /**/ void @@ -2030,6 +2030,16 @@ int errsfound; /* Total error count so far */ /**/ int forceerrs; /* Forced maximum error count */ +/* + * exactpos is used to remember how far down an exact string we have + * matched, if we are doing approximation and can therefore redo from + * the same point; we never need to otherwise. + * + * exactend is a pointer to the end of the string, which isn't + * null-terminated. + */ +static char *exactpos, *exactend; + /**/ void pattrystart(void) @@ -2072,7 +2082,7 @@ patmungestring(char **string, int *stringlen, int *unmetalenin) } /* - * Allocate memeory for pattern match. Note this is specific to use + * Allocate memory for pattern match. Note this is specific to use * of pattern *and* trial string. * * Unmetafy a trial string for use in pattern matching, if needed. @@ -2093,7 +2103,7 @@ patmungestring(char **string, int *stringlen, int *unmetalenin) * In patstralloc (supplied by caller, must last until last pattry is done) * unmetalen is the unmetafied length of the string; it will be * calculated if the input value is negative. - * unmetalenp is the umetafied length of a path segment preceeding + * unmetalenp is the umetafied length of a path segment preceding * the trial string needed for file mananagement; it is calculated as * needed so does not need to be initialised. * alloced is the memory allocated on the heap --- same as return value from @@ -2227,7 +2237,7 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen, * depends on both prog *and* the trial string). This should only be * done if there is no path prefix (pathpos == 0) as otherwise the path * buffer and unmetafied string may not match. To do this, - * patallocstr() is callled (use force = 1 to ensure it is alway + * patallocstr() is called (use force = 1 to ensure it is always * unmetafied); paststralloc points to existing storage. Memory is * on the heap. * @@ -2321,7 +2331,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, if (patstralloc->alloced) { /* - * Unmetafied; we need pattern sring that's also unmetafied. + * Unmetafied; we need pattern string that's also unmetafied. * We'll cache it in the patstralloc structure. * Note it's on the heap. */ @@ -2379,7 +2389,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, /* * Remember the length in case used for ${..#..} etc. * In this case, we didn't unmetafy the pattern string - * In the orignal structure, but it might be unmetafied + * in the original structure, but it might be unmetafied * for use with an unmetafied test string. */ patinlen = pstrlen; @@ -2463,6 +2473,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, patinput = patinstart; + exactpos = exactend = NULL; + /* The only external call to patmatch --- all others are recursive */ if (patmatch((Upat)progstr)) { /* * we were lazy and didn't save the globflags if an exclusion @@ -2480,7 +2492,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, * Optimization: if we didn't find any Meta characters * to begin with, we don't need to look for them now. * - * For patstralloc pased in, we want the unmetafied length. + * For patstralloc passed in, we want the unmetafied length. */ if (patstralloc == &patstralloc_struct && patstralloc->unmetalen != origlen) { @@ -2607,10 +2619,10 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, } /* - * Return length of previous succesful match. This is + * Return length of previous successful match. This is * in metafied bytes, i.e. includes a count of Meta characters, * unless the match was done on an unmetafied string using - * a patstralloc stuct, in which case it, too is unmetafed. + * a patstralloc struct, in which case it too is unmetafied. * Unusual and futile attempt at modular encapsulation. */ @@ -2653,16 +2665,6 @@ patmatchlen(void) (charmatch_cache = (expr), CHARMATCH(charmatch_cache, chpa)) /* - * exactpos is used to remember how far down an exact string we have - * matched, if we are doing approximation and can therefore redo from - * the same point; we never need to otherwise. - * - * exactend is a pointer to the end of the string, which isn't - * null-terminated. - */ -static char *exactpos, *exactend; - -/* * Main matching routine. * * Testing the tail end of a match is usually done by recursion, but |