Bite-size project

Olly Betts olly at survex.com
Mon Mar 28 10:31:32 BST 2016


Hi Richhiey,

On Sat, Mar 26, 2016 at 10:24:22AM +0530, Richhiey Thomas wrote:
> I would like to take up the bite sized project on adding a match command to
> omega script to perform a regex match.
> I would just like to know whether the way I am approaching this is right or
> wrong.
> 
> The way I am planning to approach it is:
> 
> 1. Add a new command in query.cc and write the implementation for this
> command

That's where a new command needs to be hooked up, but in this case I'd
put the actual implementation into transform.cc alongside the
implementation of $transform - then it can share $transform's regex
cache (which avoids recompiling a regex if it's used multiple times,
either explicitly or in something like $hitlist which gets evaluated
multiple times).

> 2. Inside implementation, we will use pcre library in a similar way to the
> $tranform function and take two arguments, the regex and the string to
> perform a match on.

It would be useful to also support an optional flags argument, like
$transform does.  Then the user can do things like a case insensitive
match.

> 3. Then using pcre library, we check for a regex match using pcre_exec( )
> and if the value it returns is lesser than or equal to zero, return true or
> else return false.

Isn't that backwards?

Cheers,
    Olly



More information about the Xapian-devel mailing list