"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "groupselect.c" between
leafnode-1.11.12.tar.bz2 and leafnode-1.12.0.tar.xz

About: Leafnode is a store & forward NNTP proxy for small (dialup) sites.

groupselect.c  (leafnode-1.11.12.tar.bz2):groupselect.c  (leafnode-1.12.0.tar.xz)
/* (C) Copyright 2002 - 2021 Matthias Andree, see COPYING for license. */
#include <string.h> #include <string.h>
#include <pcre.h>
#include "config.h" #include "config.h"
#include "groupselect.h" #include "groupselect.h"
#include "ln_log.h" #include "ln_log.h"
pcre *gs_compile(const char *regex) { pcre2_code_8 *gs_compile(const unsigned char *regex) {
const char *regex_errmsg; int regex_errcode;
int regex_errpos; size_t regex_errpos;
pcre *e; pcre2_code_8 *re;
if ((e = pcre_compile(regex, PCRE_MULTILINE, &regex_errmsg, if (NULL == (re = pcre2_compile_8(regex, PCRE2_ZERO_TERMINATED, PCRE2_MULTIL
&regex_errpos, NULL)) == NULL) { INE, &regex_errcode,
&regex_errpos, NULL))) {
unsigned char regex_errmsg[1024];
int len = pcre2_get_error_message_8(regex_errcode, regex_errmsg, sizeof(r
egex_errmsg));
ln_log(LNLOG_SERR, LNLOG_CTOP, "Invalid group pattern " ln_log(LNLOG_SERR, LNLOG_CTOP, "Invalid group pattern "
"in \"%s\" at char #%d: %s", regex, regex_errpos, regex_errmsg); "in \"%s\" at char #%lu: %s%s", regex, (unsigned long)regex_errpo
s, regex_errmsg,
len == PCRE2_ERROR_NOMEMORY ? "[...]" : "");
} }
return e; return re;
} }
/* match s against PCRE p /* match s against PCRE p
* WARNING: If p is NULL, every string s is considered a match * WARNING: If p is NULL, every string s is considered a match
* returns 1 for match, 0 for mismatch, negative for error */ * returns 1 for match, 0 for mismatch, negative for error */
int gs_match(const pcre *p, const char *s) { int gs_match(const pcre2_code_8 *re, const unsigned char *s) {
int match; int match;
if (p == NULL) return 1; pcre2_match_data_8 *match_data;
match = pcre_exec(p, NULL, s, strlen(s), 0,
PCRE_ANCHORED, NULL, 0); if (re == NULL) return 1;
match_data = pcre2_match_data_create_8(1, NULL);
if (NULL == match_data) {
ln_log(LNLOG_SERR, LNLOG_CTOP, "gs_match: out of memory allocating ma
tch_data");
return -1;
}
match = pcre2_match_8(re, s, PCRE2_ZERO_TERMINATED, 0,
PCRE2_ANCHORED, match_data, NULL);
if (match == PCRE_ERROR_NOMATCH) return 0; pcre2_match_data_free_8(match_data);
if (match == PCRE2_ERROR_NOMATCH) return 0;
if (match >= 0) return 1; if (match >= 0) return 1;
return match; return match; /* match < 0, but not PCRE2_ERROR_NOMATCH */
} }
 End of changes. 10 change blocks. 
15 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)