Skip to content
  • Kevin Haller's avatar
    libtracker-data: Support regular expressions for fn:replace(). · 60d0f54f
    Kevin Haller authored and Carlos Garnacho's avatar Carlos Garnacho committed
    Extends the sqlite database by a new function (with the name
    SparqlReplace). The function makes use of the g_regex_replace() function
    of glib.
    
    To fullfill the XPath 2.0 standard some constraints must be checked for
    fn:replace(input, pattern, replacement, flags). The given pattern must
    not match a zero-length string. The given replacement string have to use
    $ followed by a number for backreferences. If the dollar sign shall be used
    "as is", it must be escaped (\$).
    
    For checking and interpreting the given replacement string of fn:replace()
    some regular expressions are needed. This expressions are precompiled and
    saved in the function_regex hashset of the TrackerDBInterface. The
    pre-compilation and initialization of the hashset are done by the
    prepare_database() method.
    
    The glib method g_regex_replace() make use of the backslash followed by a
    number to inidcate backreferences. So the dollar signs must be interpreted
    - the backslashes can be still used for this purpose.
    
    In the sparql expression class the corresponding section is adapted, so
    that the new SparqlReplace function is used for fn:replace(..) statements.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754961
    60d0f54f