about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2004-03-16 15:14:30 +0000
committerClint Adams <clint@users.sourceforge.net>2004-03-16 15:14:30 +0000
commitbefd90b84787b2508ee32549f7a38859d0056b55 (patch)
treef8dfcd86944cea0a9e8028a94622f85f658ac7ff
parent8860363e5c989b0026e482a2cd9d04d4492816af (diff)
downloadzsh-befd90b84787b2508ee32549f7a38859d0056b55.tar.gz
zsh-befd90b84787b2508ee32549f7a38859d0056b55.tar.xz
zsh-befd90b84787b2508ee32549f7a38859d0056b55.zip
* 19631: Doc/Zsh/mod_pcre.yo, Src/Modules/pcre.c: avoid segfault
      when pcre_study is called before pcre_compile; documentation on
      pcre_compile options.
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/mod_pcre.yo7
-rw-r--r--Src/Modules/pcre.c9
3 files changed, 21 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e0f3142e..862f71a61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-16  Clint Adams  <clint@zsh.org>
+
+	* 19631: Doc/Zsh/mod_pcre.yo, Src/Modules/pcre.c: avoid segfault
+	when pcre_study is called before pcre_compile; documentation on
+	pcre_compile options.
+
 2004-03-16  Peter Stephenson  <pws@csr.com>
 
 	* 19140 (patch reversed): Nicholas George: Src/builtin.c: Release
diff --git a/Doc/Zsh/mod_pcre.yo b/Doc/Zsh/mod_pcre.yo
index 8eadee38b..1d3d18954 100644
--- a/Doc/Zsh/mod_pcre.yo
+++ b/Doc/Zsh/mod_pcre.yo
@@ -8,6 +8,13 @@ startitem()
 findex(pcre_compile)
 item(tt(pcre_compile) [ tt(-aimx) ] var(PCRE))(
 Compiles a perl-compatible regular expression.
+
+Option tt(-a) will force the pattern to be anchored.
+Option tt(-i) will compile a case-insensitive pattern.
+Option tt(-m) will compile a multi-line pattern; that is,
+tt(^) and tt($) will match newlines within the pattern.
+Option tt(-x) will compile an extended pattern, wherein
+whitespace and tt(#) comments are ignored.
 )
 findex(pcre_study)
 item(tt(pcre_study))(
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 36c437bc3..030d1c78a 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -3,7 +3,7 @@
  *
  * This file is part of zsh, the Z shell.
  *
- * Copyright (c) 2001 Clint Adams
+ * Copyright (c) 2001, 2002, 2003, 2004 Clint Adams
  * All rights reserved.
  *
  * Permission is hereby granted, without written agreement and without
@@ -71,6 +71,13 @@ static int
 bin_pcre_study(char *nam, char **args, Options ops, int func)
 {
     const char *pcre_error;
+
+    if (pcre_pattern == NULL)
+    {
+	zwarnnam(nam, "no pattern has been compiled for study: %s",
+		 pcre_error, 0);
+	return 1;
+    }
     
     pcre_hints = pcre_study(pcre_pattern, 0, &pcre_error);
     if (pcre_error != NULL)