summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-01-20 11:16:22 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-01-20 11:16:22 +0000
commitaf68ff74cd5e740d69020ad4ff20f1d5a8dcb4de (patch)
tree4b3232caa414d1717aca990dd7b3588b973ad372
parent1c71dfd735f34b2b3c7cf8abc3144e763fc96b60 (diff)
downloadzsh-af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de.tar.gz
zsh-af68ff74cd5e740d69020ad4ff20f1d5a8dcb4de.zip
27608: fix memory for mbegin, mend & regexp test
-rw-r--r--ChangeLog8
-rw-r--r--Src/Modules/pcre.c4
-rw-r--r--Src/Modules/regex.c8
-rw-r--r--Test/C02cond.ztst13
4 files changed, 20 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 6bf85e2f4..a9f0b7da9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 $
*****************************************************
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index f8b79adea..e1a897944 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -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;
diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c
index 25dbddf07..08e815003 100644
--- a/Src/Modules/regex.c
+++ b/Src/Modules/regex.c
@@ -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];
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index b0e278f4b..a824709d3 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -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