From: Clint Adams <clint@zsh.org>
To: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
Cc: zsh-workers@sunsite.dk
Subject: Re: PATCH: zsh/pcre module
Date: Tue, 3 Jul 2001 12:21:35 -0400 [thread overview]
Message-ID: <20010703122135.A4396@dman.com> (raw)
In-Reply-To: <001e01c1038d$784822b0$21c9ca95@mow.siemens.ru>; from Andrej.Borsenkow@mow.siemens.ru on Tue, Jul 03, 2001 at 10:57:48AM +0400
> I urge everybody to use AC_SEARCH_LIB. AC_CHECK_LIB has nasty habit of
> adding library even when it is not needed; moreover, it does it in front,
> thus sometimes preventing you from using your own library.
This switches AC_CHECK_LIB to AC_SEARCH_LIBS. It sets
positional parameters with the contents of capture buffers.
Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.15
diff -u -r1.15 zshconfig.ac
--- zshconfig.ac 2001/07/03 05:59:55 1.15
+++ zshconfig.ac 2001/07/03 16:04:11
@@ -644,7 +644,7 @@
AC_CHECK_LIB(socket, socket)
dnl pcre-config should probably be employed here
-AC_CHECK_LIB(pcre, pcre_compile)
+AC_SEARCH_LIBS(pcre_compile, pcre)
dnl ---------------------
dnl CHECK TERMCAP LIBRARY
Index: Src/Modules/pcre.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/pcre.c,v
retrieving revision 1.1
diff -u -r1.1 pcre.c
--- Src/Modules/pcre.c 2001/07/02 19:39:35 1.1
+++ Src/Modules/pcre.c 2001/07/03 16:04:11
@@ -27,11 +27,12 @@
*
*/
-/**/
-#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
#include "pcre.mdh"
#include "pcre.pro"
+
+/**/
+#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
#include <pcre.h>
static pcre *pcre_pattern;
@@ -49,6 +50,8 @@
if(ops['m']) pcre_opts |= PCRE_MULTILINE;
if(ops['x']) pcre_opts |= PCRE_EXTENDED;
+ pcre_hints = NULL; /* Is this necessary? */
+
pcre_pattern = pcre_compile(*args, pcre_opts, &pcre_error, &pcre_errptr, NULL);
if (pcre_pattern == NULL)
@@ -86,11 +89,38 @@
static int
bin_pcre_match(char *nam, char **args, char *ops, int func)
{
-#define PCRE_OVEC_SIZE 50
+ int ret, capcount, *ovec, ovecsize;
+ char **captures;
- int ovec[PCRE_OVEC_SIZE]; /* throwing this away now, but will be useful someday */
+ if (pcre_fullinfo(pcre_pattern, pcre_hints, PCRE_INFO_CAPTURECOUNT, &capcount))
+ {
+ zwarnnam(nam, "error in fullinfo", NULL, 0);
+ return 1;
+ }
+
+ ovecsize = (capcount+1)*3;
+ ovec = zalloc(ovecsize*sizeof(int));
+
+ ret = pcre_exec(pcre_pattern, pcre_hints, *args, strlen(*args), 0, 0, ovec, ovecsize);
+
+ if (ret==0) return 0;
+ else if (ret==PCRE_ERROR_NOMATCH) return 1; /* no match */
+ else if (ret>0) {
+ if(!pcre_get_substring_list(*args, ovec, ret, (const char ***)&captures)) {
+
+ freearray(pparams);
+ pparams = zarrdup(&captures[1]); /* first one would be entire string */
+
+ pcre_free_substring_list((const char **)captures);
+ return 0;
+ }
+ }
+ else {
+ zwarnnam(nam, "error in pcre_exec", NULL, 0);
+ return 1;
+ }
- return !(pcre_exec(pcre_pattern, pcre_hints, *args, strlen(*args), 0, 0, ovec, PCRE_OVEC_SIZE) >= 0);
+ return 1;
}
static struct builtin bintab[] = {
prev parent reply other threads:[~2001-07-03 16:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-02 19:35 Clint Adams
2001-07-02 23:10 ` Bart Schaefer
2001-07-03 5:54 ` Andrej Borsenkow
2001-07-03 6:25 ` Bart Schaefer
2001-07-03 6:30 ` Andrej Borsenkow
2001-07-03 16:32 ` Bart Schaefer
2001-07-03 16:35 ` Clint Adams
2001-07-03 16:55 ` Oliver Kiddle
2001-07-03 16:59 ` Clint Adams
2001-07-03 17:19 ` Andrej Borsenkow
2001-07-03 17:18 ` Andrej Borsenkow
2001-07-03 17:21 ` Bart Schaefer
2001-07-03 17:43 ` Clint Adams
2001-07-17 16:28 ` Fletch
2001-07-03 6:57 ` Andrej Borsenkow
2001-07-03 16:21 ` Clint Adams [this message]
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=20010703122135.A4396@dman.com \
--to=clint@zsh.org \
--cc=Andrej.Borsenkow@mow.siemens.ru \
--cc=zsh-workers@sunsite.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).