1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

27608: fix memory for mbegin, mend & regexp test

This commit is contained in:
Peter Stephenson 2010-01-20 11:16:22 +00:00
parent 1c71dfd735
commit af68ff74cd
4 changed files with 20 additions and 13 deletions

View file

@ -1,3 +1,9 @@
2010-01-20 Peter Stephenson <pws@csr.com>
* 27608: Src/Modules/pcre.c, Src/Modules/regex.c,
Test/C02cond.ztst: test was broken and sizes of variables
for arrays were wrong.
2010-01-19 Peter Stephenson <pws@csr.com>
* unposted: Doc/Zsh/contrib.yo, Functions/Misc/regexp-replace:
@ -12609,5 +12615,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4867 $
* $Revision: 1.4868 $
*****************************************************

View file

@ -194,8 +194,8 @@ zpcre_get_substrings(char *arg, int *ovec, int ret, char *matchvar,
char **mbegin, **mend, **bptr, **eptr;
int i, *ipair;
bptr = mbegin = zalloc(nelem+1);
eptr = mend = zalloc(nelem+1);
bptr = mbegin = zalloc(sizeof(char*)*(nelem+1));
eptr = mend = zalloc(sizeof(char*)*(nelem+1));
for (ipair = ovec + 2, i = 0;
i < nelem;

View file

@ -135,11 +135,11 @@ zcond_regex_match(char **a, int id)
setiparam("MEND", offs + !isset(KSHARRAYS) - 1);
if (nelem) {
char **mbegin, **mend, **bptr, **eptr;
bptr = mbegin = (char **)zalloc(nelem+1);
eptr = mend = (char **)zalloc(nelem+1);
bptr = mbegin = (char **)zalloc(sizeof(char *)*(nelem+1));
eptr = mend = (char **)zalloc(sizeof(char *)*(nelem+1));
for (m = matches + start, n = start;
n <= (int)re.re_nsub;
for (m = matches + start, n = 0;
n < nelem;
++n, ++m, ++bptr, ++eptr)
{
char buf[DIGBUFSIZE];

View file

@ -251,7 +251,7 @@ F:Failures in these cases do not indicate a problem in the shell.
fi
0:regex tests shouldn't crash
if zmodload -i zsh/regex 2>/dev/null; then
(if zmodload -i zsh/regex 2>/dev/null; then
string="this has stuff in it"
bad_regex=0
if [[ $string =~ "h([a-z]*) s([a-z]*) " ]]; then
@ -259,7 +259,7 @@ F:Failures in these cases do not indicate a problem in the shell.
print -r "regex variables MATCH MBEGIN MEND:
'$MATCH $MBEGIN $MEND'
should be:
'has stuff 6 15'" >&2
'has stuff 6 15'"
bad_regex=1
else
results=("as 7 8" "tuff 11 14")
@ -268,19 +268,20 @@ F:Failures in these cases do not indicate a problem in the shell.
print -r "regex variables match[$i] mbegin[$i] mend[$i]:
'$match[$i] $mbegin[$i] $mend[$i]'
should be
'$results[$i]'" >&2
'$results[$i]'"
bad_regex=1
break
fi
done
fi
(( bad_regex )) || print OK
else
print -r "regex failed to match '$string'" >&2
print -r "regex failed to match '$string'"
fi
(( bad_regex )) || print OK
else
# if it didn't load, tough, but not a test error
print OK
fi
fi)
0:MATCH, MBEGIN, MEND, match, mbegin, mend
>OK