From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Seg fault in matcher-list matching
Date: Mon, 15 May 2000 11:26:19 +0200 (MET DST) [thread overview]
Message-ID: <200005150926.LAA17371@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Mon, 15 May 2000 06:10:44 +0000
Bart Schaefer wrote:
> I did this:
>
> zagzig[41] /u/s/l/z/z4/s/zsh
> ^cursor over the 4, press TAB
>
> The path this was intended to match was /usr/src/local/zsh/zsh-2.4/src/zsh.
> I had first tried TAB at the end of the line and gotten a feep, in case
> that matters.
I couldn't get it to seg-fault, but there was something broken. Matching
of the suffix, for example, and that both in C and shell code.
Oliver Kiddle wrote:
> ...
>
> It's too late too look at this in any more detail but I've just found that
> I get a seg fault when I do this:
> diff .c<tab>
> ^cursor here.
I couldn't reproduce this (neither before nor after this patch -- your
match specs would have helped), but this looks suspiciously similar to
the one above... could you try with this patch?
Bye
Sven
Index: Completion/Core/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_path_files,v
retrieving revision 1.11
diff -u -r1.11 _path_files
--- Completion/Core/_path_files 2000/05/02 08:18:54 1.11
+++ Completion/Core/_path_files 2000/05/15 09:25:35
@@ -6,7 +6,7 @@
local linepath realpath donepath prepath testpath exppath skips skipped
local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
local pats haspats ignore pfxsfx remt sopt gopt opt sdirs ignpar
-local nm=$compstate[nmatches] menu matcher mopts sort match
+local nm=$compstate[nmatches] menu matcher mopts sort match mid
typeset -U prepaths exppaths
@@ -529,6 +529,7 @@
cpre="${cpre}${tpre%%/*}/"
tpre="${tpre#*/}"
elif [[ "$tsuf" = */* ]]; then
+ mid="$testpath"
cpre="${cpre}${tpre}/"
tpre="${tsuf#*/}"
tsuf=
@@ -539,17 +540,32 @@
done
if [[ -z "$tmp4" ]]; then
- if [[ "$osuf" = */* ]]; then
- PREFIX="${opre}${osuf}"
- SUFFIX=
- else
+ if [[ "$mid" = */ ]]; then
PREFIX="${opre}"
SUFFIX="${osuf}"
+
+ tmp4="${testpath#${mid}}"
+ tmp3="${mid%/*/}"
+ tmp2="${${mid%/}##*/}"
+ compquote tmp4 tmp3 tmp2 tmp1
+ for i in "$tmp1[@]"; do
+ compadd -Qf "$mopts[@]" -p "$linepath$tmp3/" -s "/$tmp4$i" \
+ -W "$prepath$realpath${mid%/*/}/" \
+ "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp2"
+ done
+ else
+ if [[ "$osuf" = */* ]]; then
+ PREFIX="${opre}${osuf}"
+ SUFFIX=
+ else
+ PREFIX="${opre}"
+ SUFFIX="${osuf}"
+ fi
+ tmp4="$testpath"
+ compquote tmp4 tmp1
+ compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
+ "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]"
fi
- tmp4="$testpath"
- compquote tmp4 tmp1
- compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -W "$prepath$realpath$testpath" \
- "$pfxsfx[@]" -M "r:|/=* r:|=*" - "$tmp1[@]"
fi
done
Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.12
diff -u -r1.12 compmatch.c
--- Src/Zle/compmatch.c 2000/05/12 11:52:30 1.12
+++ Src/Zle/compmatch.c 2000/05/15 09:25:37
@@ -482,9 +482,10 @@
*/
bslash = 0;
- if (test && (l[ind] == w[ind] ||
- (bslash = (lw > 1 && w[ind] == '\\' &&
- (ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
+ if (test && !sfx &&
+ (l[ind] == w[ind] ||
+ (bslash = (lw > 1 && w[ind] == '\\' &&
+ (ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
/* No matcher could be used, but the strings have the same
* character here, skip over it. */
l += add; w += (bslash ? (add + add ) : add);
@@ -562,10 +563,8 @@
/* Fine, now we call ourselves recursively to find the
* string matched by the `*'. */
- if (sfx) {
- savl = l[-(llen + zoff)];
+ if (sfx && (savl = l[-(llen + zoff)]))
l[-(llen + zoff)] = '\0';
- }
for (t = 0, tp = w, ct = 0, ict = lw - alen + 1;
ict;
tp += add, ct++, ict--) {
@@ -585,11 +584,12 @@
!match_parts(l + aoff , tp - moff, alen, part))
break;
if (sfx) {
- savw = tp[-zoff];
- tp[-zoff] = '\0';
+ if ((savw = tp[-zoff]))
+ tp[-zoff] = '\0';
t = match_str(l - ll, w - lw,
NULL, 0, NULL, 1, 2, part);
- tp[-zoff] = savw;
+ if (savw)
+ tp[-zoff] = savw;
} else
t = match_str(l + llen + moff, tp + moff,
NULL, 0, NULL, 0, 1, part);
@@ -598,7 +598,7 @@
}
}
ict = ct;
- if (sfx)
+ if (sfx && savl)
l[-(llen + zoff)] = savl;
/* Have we found a position in w where the rest of l
@@ -794,9 +794,10 @@
/* Same code as at the beginning, used in top-level calls. */
bslash = 0;
- if (!test && (l[ind] == w[ind] ||
- (bslash = (lw > 1 && w[ind] == '\\' &&
- (ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
+ if ((!test || sfx) &&
+ (l[ind] == w[ind] ||
+ (bslash = (lw > 1 && w[ind] == '\\' &&
+ (ind ? (w[0] == l[0]) : (w[1] == l[0])))))) {
/* No matcher could be used, but the strings have the same
* character here, skip over it. */
l += add; w += (bslash ? (add + add ) : add);
@@ -811,6 +812,8 @@
lm = NULL;
he = 0;
} else {
+ if (!lw)
+ break;
/* No matcher and different characters: l does not match w. */
if (test)
return 0;
@@ -873,10 +876,15 @@
char lsav = l[n], wsav = w[n];
int ret;
- l[n] = w[n] = '\0';
+ if (lsav)
+ l[n] = '\0';
+ if (wsav)
+ w[n] = '\0';
ret = match_str(l, w, NULL, 0, NULL, 0, 1, part);
- l[n] = lsav;
- w[n] = wsav;
+ if (lsav)
+ l[n] = lsav;
+ if (wsav)
+ w[n] = wsav;
return ret;
}
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-05-15 9:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-15 9:26 Sven Wischnowsky [this message]
2000-05-15 11:44 ` Bart Schaefer
2000-05-15 12:09 ` seg fault fixed and Makefile change Oliver Kiddle
2000-05-15 22:57 ` PATCH: Re: Seg fault in matcher-list matching Tanaka Akira
2000-05-15 10:43 Sven Wischnowsky
2000-05-15 11:52 Sven Wischnowsky
2000-05-16 10:48 Sven Wischnowsky
2000-05-16 16:03 ` Tanaka Akira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200005150926.LAA17371@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).