From: Jaroslav Kysela Date: Wed, 17 May 2017 07:43:56 +0000 (+0200) Subject: EPG search: use PCRE library, too X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6ad2cd6cf5c3b096d40eb70c133362151bace25;p=thirdparty%2Ftvheadend.git EPG search: use PCRE library, too --- diff --git a/src/epg.c b/src/epg.c index 1e898d74c..aaccc814f 100644 --- a/src/epg.c +++ b/src/epg.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -2659,7 +2658,7 @@ _eq_comp_str ( epg_filter_str_t *f, const char *str ) case EC_LT: return strcmp(str, f->str) > 0; case EC_GT: return strcmp(str, f->str) < 0; case EC_IN: return strstr(str, f->str) != NULL; - case EC_RE: return regexec(&f->re, str, 0, NULL, 0) != 0; + case EC_RE: return regex_match(&f->re, str) != 0; default: return 0; } } @@ -2701,13 +2700,13 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e ) } if (fulltext) { if ((s = epg_episode_get_title(ep, lang)) == NULL || - regexec(&eq->stitle_re, s, 0, NULL, 0)) { + regex_match(&eq->stitle_re, s)) { if ((s = epg_episode_get_subtitle(ep, lang)) == NULL || - regexec(&eq->stitle_re, s, 0, NULL, 0)) { + regex_match(&eq->stitle_re, s)) { if ((s = epg_broadcast_get_summary(e, lang)) == NULL || - regexec(&eq->stitle_re, s, 0, NULL, 0)) { + regex_match(&eq->stitle_re, s)) { if ((s = epg_broadcast_get_description(e, lang)) == NULL || - regexec(&eq->stitle_re, s, 0, NULL, 0)) { + regex_match(&eq->stitle_re, s)) { return; } } @@ -2716,7 +2715,7 @@ _eq_add ( epg_query_t *eq, epg_broadcast_t *e ) } if (eq->title.comp != EC_NO || (eq->stitle && !fulltext)) { if ((s = epg_episode_get_title(ep, lang)) == NULL) return; - if (eq->stitle && !fulltext && regexec(&eq->stitle_re, s, 0, NULL, 0)) return; + if (eq->stitle && !fulltext && regex_match(&eq->stitle_re, s)) return; if (eq->title.comp != EC_NO && _eq_comp_str(&eq->title, s)) return; } if (eq->subtitle.comp != EC_NO) { @@ -2756,14 +2755,14 @@ static int _eq_init_str( epg_filter_str_t *f ) { if (f->comp != EC_RE) return 0; - return regcomp(&f->re, f->str, REG_ICASE | REG_EXTENDED | REG_NOSUB); + return regex_compile(&f->re, f->str, LS_EPG); } static void _eq_done_str( epg_filter_str_t *f ) { if (f->comp == EC_RE) - regfree(&f->re); + regex_free(&f->re); free(f->str); f->str = NULL; } @@ -2961,7 +2960,7 @@ epg_query ( epg_query_t *eq, access_t *perm ) if (_eq_init_str(&eq->channel_name)) goto fin; if (eq->stitle) - if (regcomp(&eq->stitle_re, eq->stitle, REG_ICASE | REG_EXTENDED | REG_NOSUB)) + if (regex_compile(&eq->stitle_re, eq->stitle, LS_EPG)) goto fin; channel = channel_find_by_uuid(eq->channel) ?: @@ -3038,7 +3037,7 @@ fin: _eq_done_str(&eq->channel_name); if (eq->stitle) - regfree(&eq->stitle_re); + regex_free(&eq->stitle_re); free(eq->lang); eq->lang = NULL; free(eq->channel); eq->channel = NULL; diff --git a/src/epg.h b/src/epg.h index 4d2d65e5b..bcbb694fc 100644 --- a/src/epg.h +++ b/src/epg.h @@ -19,7 +19,7 @@ #ifndef EPG_H #define EPG_H -#include +#include "tvhregex.h" #include "settings.h" #include "lang_str.h" #include "access.h" @@ -626,9 +626,9 @@ typedef enum { } epg_comp_t; typedef struct epg_filter_str { - char *str; - regex_t re; - epg_comp_t comp; + char *str; + tvh_regex_t re; + epg_comp_t comp; } epg_filter_str_t; typedef struct epg_filter_num { @@ -655,7 +655,7 @@ typedef struct epg_query { epg_filter_str_t channel_name; epg_filter_num_t channel_num; char *stitle; - regex_t stitle_re; + tvh_regex_t stitle_re; int fulltext; char *channel; char *channel_tag;