Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (Fwd) segfault with pcre_study alone
- X-seq: zsh-workers 19634
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Clint Adams <clint@xxxxxxx>
- Subject: Re: (Fwd) segfault with pcre_study alone
- Date: Tue, 16 Mar 2004 19:05:28 +0100
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <20040316152006.GA21815@xxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <1040316145551.ZM8418@xxxxxxxxxxxxxxxxxxxxxxx> <20040316150753.GA21121@xxxxxxxxxxx> <20040316152006.GA21815@xxxxxxxxxxx>
Clint Adams wrote:
> +
> + if (pcre_pattern == NULL)
> + {
> + zwarnnam(nam, "no pattern has been compiled for study: %s",
> + pcre_error, 0);
> + return 1;
> + }
At this point, pcre_error has been declared a char * but not assigned
to by anything. You need:
zwarnnam(nam, "no pattern has been compiled for study", NULL, 0);
Also, shouldn't you initialise pcre_pattern to NULL where it is
declared since we are now relying on the compiler to initialise it to
null by doing this.
It might also be nice to put the same if statement in pcre_match:
"error in fullinfo" is not the most helpful error message.
Are you aware that zsh modules can define condition codes that can be
used inside [[ ... ]]? The completion module defines a -prefix
condition for example. This could be much nicer than the current
interface which is just a mapping onto the C calls. We'd be able to do:
if [[ value -pcre-anchored pattern ]]; then
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author