Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: (Fwd) segfault with pcre_study alone



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