int
xml_path_pcre_add_with (xml_GNode* tree, const gchar* pathXE,
const gchar* regex,
xml_GNodeAddFunc func, gpointer data, GError** error)
{
g_return_val_if_fail (tree, 0);
g_return_val_if_fail (regex && *regex, 0);
if (! func) func = (xml_GNodeAddFunc) xml_tree_add;
___ int flag = 0;
if (*regex == '{')
{
while (*++regex)
{
switch (*regex)
{
case 'i': flag |= PCRE_CASELESS; continue;
case 'm': flag |= PCRE_MULTILINE; continue;
case 's': flag |= PCRE_DOTALL; continue;
case 'x': flag |= PCRE_EXTENDED; continue;
case 'X': flag |= PCRE_EXTRA; continue;
case 'U': flag |= PCRE_UNGREEDY; continue;
case 'A': flag |= PCRE_ANCHORED; continue;
case 'Z': flag |= PCRE_DOLLAR_ENDONLY; continue;
case 'q': flag |= PCRE_NOTEMPTY; continue;
case '}': regex++; goto breaks;
} |
} |
breaks:
;
} |
___ auto const char* errmsg; int erridx;
pcre* compiled = pcre_compile (regex, flag, &errmsg, &erridx, 0);
if (! compiled)
{
xml_g_set_error (error, 4, "errornous regex: %s", errmsg);
return -1;
} |
___ auto ForData dat = { compiled, func, (gpointer) data } | ;
if (PCRE_NOTEMPTY& flag || g_ascii_is_alnum_space ((*regex)))
xml_path_pcre_foreach (tree, pathXE,
xml_path_pcre_add_with_funcc, &dat);
else
xml_path_pcre_foreach (tree, pathXE,
xml_path_pcre_add_with_func, &dat);
pcre_free (compiled);
return dat.count;
____;____;____;
} |
|