From e4cdad9700342b4dbc1837307580134eee274f33 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 2 May 2007 11:13:14 +0000 Subject: unposted: regex fix-ups: missing doc file plus pointer fixes --- ChangeLog | 5 +++++ Doc/Zsh/mod_regex.yo | 27 +++++++++++++++++++++++++++ Src/Modules/pcre.c | 5 +++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Doc/Zsh/mod_regex.yo diff --git a/ChangeLog b/ChangeLog index 54bd924f6..cd8c11c01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-05-02 Peter Stephenson + + * unposted: Doc/Zsh/mod_pcre.yo, Src/pcre.c: missing + documentation file (tweaked) plus pointer fixes. + 2007-05-01 Peter Stephenson * Phil Pennock + tweaks: 23375: configure.ac, Doc/Makefile.in, diff --git a/Doc/Zsh/mod_regex.yo b/Doc/Zsh/mod_regex.yo new file mode 100644 index 000000000..08e92ab9f --- /dev/null +++ b/Doc/Zsh/mod_regex.yo @@ -0,0 +1,27 @@ +COMMENT(!MOD!zsh/regex +Interface to the POSIX regex library. +!MOD!) +cindex(regular expressions) +cindex(regex) +The tt(zsh/regex) module makes available the following test condition: +startitem() +findex(regex-match) +item(var(expr) tt(-regex-match) var(regex))( +Matches a string against a POSIX extended regular expression. +The matched portion of the string will normally be placed in the tt(MATCH) +variable. If there are any capturing parentheses within the regex, then +the tt(match) array variable will contain those. + +For example, + +example([[ alphabetical -regex-match ^a+LPAR()[^a]PLUS()+RPAR()a+LPAR()[^a]+PLUS()+RPAR()a ]] && +print -l $MATCH X $match) + +If the option tt(REMATCH_PCRE) is not set, then the tt(=~) operator will +automatically load this module as needed and will invoke the +tt(-regex-match) operator. + +If tt(BASH_REMATCH) is set, then the array tt(BASH_REMATCH) will be set +instead of tt(MATCH) and tt(match). +) +enditem() diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index 21988e05c..d067d8949 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -139,7 +139,7 @@ bin_pcre_study(char *nam, UNUSED(char **args), UNUSED(Options ops), UNUSED(int f static int zpcre_get_substrings(char *arg, int *ovec, int ret, char *matchvar, char *substravar, int matchedinarr) { - char **captures, **match_all, **matches; + char **captures, *match_all, **matches; int capture_start = 1; if (matchedinarr) @@ -227,7 +227,8 @@ cond_pcre_match(char **a, int id) lhstr = cond_str(a,0,0); rhre = cond_str(a,1,0); - pcre_pat = ov = NULL; + pcre_pat = NULL; + ov = NULL; if (isset(BASHREMATCH)) avar="BASH_REMATCH"; -- cgit 1.4.1