Compare commits
No commits in common. "ae90325290681f784a505daede7e09ceb5dd452e" and "4b42b3819ea83fc9afea0b453fa7b08e7a6fb6b5" have entirely different histories.
ae90325290
...
4b42b3819e
@ -1,184 +0,0 @@
|
|||||||
From b5c595baa49360614ef531cb9621644e8cf5fec5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: alakatos <alakatos@redhat.com>
|
|
||||||
Date: Tue, 6 Jun 2023 15:13:17 +0200
|
|
||||||
Subject: [PATCH] Port pcre dependency to pcre2
|
|
||||||
|
|
||||||
Fixes #366
|
|
||||||
Upstream stopped the support for the old 'pcre' package. See
|
|
||||||
https://www.pcre.org/
|
|
||||||
It only supports the new 'pcre2' version, we should replace
|
|
||||||
the current pcre with the newer pcre2.
|
|
||||||
---
|
|
||||||
configure.ac | 5 ++---
|
|
||||||
src/parser.c | 6 ------
|
|
||||||
src/v1_parser.c | 50 +++++++++++++++++++++++++++++++++----------------
|
|
||||||
3 files changed, 36 insertions(+), 25 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/configure.ac b/configure.ac
|
|
||||||
index b6f92f1b..752b7d93 100644
|
|
||||||
--- a/configure.ac
|
|
||||||
+++ b/configure.ac
|
|
||||||
@@ -80,7 +80,7 @@ AC_ARG_ENABLE(regexp,
|
|
||||||
)
|
|
||||||
AM_CONDITIONAL(ENABLE_REGEXP, test x$enable_regexp = xyes)
|
|
||||||
if test "$enable_regexp" = "yes"; then
|
|
||||||
- PKG_CHECK_MODULES(PCRE, libpcre)
|
|
||||||
+ PKG_CHECK_MODULES(PCRE, [libpcre2-8 >= 10.00])
|
|
||||||
AC_DEFINE(FEATURE_REGEXP, 1, [Regular expressions support enabled.])
|
|
||||||
FEATURE_REGEXP=1
|
|
||||||
else
|
|
||||||
@@ -194,5 +194,4 @@ echo "Testbench enabled: $enable_testbench"
|
|
||||||
echo "Valgrind enabled: $enable_valgrind"
|
|
||||||
echo "Debug mode enabled: $enable_debug"
|
|
||||||
echo "Tools enabled: $enable_tools"
|
|
||||||
-echo "Docs enabled: $enable_docs"
|
|
||||||
-
|
|
||||||
+echo "Docs enabled: $enable_docs"
|
|
||||||
\ No newline at end of file
|
|
||||||
diff --git a/src/parser.c b/src/parser.c
|
|
||||||
index 2d704246..dcd5b4ee 100644
|
|
||||||
--- a/src/parser.c
|
|
||||||
+++ b/src/parser.c
|
|
||||||
@@ -42,12 +42,6 @@
|
|
||||||
#include "samp.h"
|
|
||||||
#include "helpers.h"
|
|
||||||
|
|
||||||
-#ifdef FEATURE_REGEXP
|
|
||||||
-#include <pcre.h>
|
|
||||||
-#include <errno.h>
|
|
||||||
-#endif
|
|
||||||
-
|
|
||||||
-
|
|
||||||
/* how should output values be formatted? */
|
|
||||||
enum FMT_MODE {
|
|
||||||
FMT_AS_STRING = 0,
|
|
||||||
diff --git a/src/v1_parser.c b/src/v1_parser.c
|
|
||||||
index 323ada0f..9fb3ccb2 100644
|
|
||||||
--- a/src/v1_parser.c
|
|
||||||
+++ b/src/v1_parser.c
|
|
||||||
@@ -39,7 +39,8 @@
|
|
||||||
#include "v1_samp.h"
|
|
||||||
|
|
||||||
#ifdef FEATURE_REGEXP
|
|
||||||
-#include <pcre.h>
|
|
||||||
+#define PCRE2_CODE_UNIT_WIDTH 8
|
|
||||||
+#include <pcre2.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1266,7 +1267,7 @@ void* tokenized_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
|
|
||||||
* significantly slower than other field-types.
|
|
||||||
*/
|
|
||||||
struct regex_parser_data_s {
|
|
||||||
- pcre *re;
|
|
||||||
+ pcre2_code *re;
|
|
||||||
int consume_group;
|
|
||||||
int return_group;
|
|
||||||
int max_groups;
|
|
||||||
@@ -1276,17 +1277,33 @@ PARSER(Regex)
|
|
||||||
assert(str != NULL);
|
|
||||||
assert(offs != NULL);
|
|
||||||
assert(parsed != NULL);
|
|
||||||
- unsigned int* ovector = NULL;
|
|
||||||
+ PCRE2_SIZE *ovector;
|
|
||||||
+ pcre2_match_data *match_data = NULL;
|
|
||||||
|
|
||||||
struct regex_parser_data_s *pData = (struct regex_parser_data_s*) node->parser_data;
|
|
||||||
if (pData != NULL) {
|
|
||||||
- ovector = calloc(pData->max_groups, sizeof(unsigned int) * 3);
|
|
||||||
- if (ovector == NULL) FAIL(LN_NOMEM);
|
|
||||||
+ match_data = pcre2_match_data_create_from_pattern(pData->re, NULL);
|
|
||||||
+ if (match_data == NULL) FAIL(LN_NOMEM);
|
|
||||||
+
|
|
||||||
+ int result = pcre2_match(
|
|
||||||
+ pData->re, /* the compiled pattern */
|
|
||||||
+ (PCRE2_SPTR)str, /* the subject string */
|
|
||||||
+ (PCRE2_SIZE)strLen, /* the length of the subject */
|
|
||||||
+ (PCRE2_SIZE)*offs, /* start at offset 0 in the subject */
|
|
||||||
+ 0, /* default options */
|
|
||||||
+ match_data, /* block for storing the result */
|
|
||||||
+ NULL); /* use default match context */
|
|
||||||
|
|
||||||
- int result = pcre_exec(pData->re, NULL, str, strLen, *offs, 0, (int*) ovector, pData->max_groups * 3);
|
|
||||||
if (result == 0) result = pData->max_groups;
|
|
||||||
if (result > pData->consume_group) {
|
|
||||||
- /*please check 'man 3 pcreapi' for cryptic '2 * n' and '2 * n + 1' magic*/
|
|
||||||
+ ovector = pcre2_get_ovector_pointer(match_data);
|
|
||||||
+ printf("Match succeeded at offset %d\n", (int)ovector[0]);
|
|
||||||
+
|
|
||||||
+ /* please check 'man 3 pcre2api' for cryptic '2 * n' and '2 * n + 1' magic
|
|
||||||
+ * in a nutshell, within the ovector, the first in each pair of values is set to the
|
|
||||||
+ * offset of the first code unit of a substring, and the second is set to the
|
|
||||||
+ * offset of the first code unit after the end of a substring.
|
|
||||||
+ */
|
|
||||||
if (ovector[2 * pData->consume_group] == *offs) {
|
|
||||||
*parsed = ovector[2 * pData->consume_group + 1] - ovector[2 * pData->consume_group];
|
|
||||||
if (pData->consume_group != pData->return_group) {
|
|
||||||
@@ -1294,22 +1311,20 @@ PARSER(Regex)
|
|
||||||
if((val = strndup(str + ovector[2 * pData->return_group],
|
|
||||||
ovector[2 * pData->return_group + 1] -
|
|
||||||
ovector[2 * pData->return_group])) == NULL) {
|
|
||||||
- free(ovector);
|
|
||||||
FAIL(LN_NOMEM);
|
|
||||||
}
|
|
||||||
*value = json_object_new_string(val);
|
|
||||||
free(val);
|
|
||||||
if (*value == NULL) {
|
|
||||||
- free(ovector);
|
|
||||||
FAIL(LN_NOMEM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- free(ovector);
|
|
||||||
}
|
|
||||||
r = 0; /* success */
|
|
||||||
done:
|
|
||||||
+ pcre2_match_data_free(match_data);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1346,8 +1361,8 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
|
|
||||||
char* name = NULL;
|
|
||||||
struct regex_parser_data_s *pData = NULL;
|
|
||||||
const char *unescaped_exp = NULL;
|
|
||||||
- const char *error = NULL;
|
|
||||||
- int erroffset = 0;
|
|
||||||
+ PCRE2_SIZE erroffset = 0;
|
|
||||||
+ int errcode = 0;
|
|
||||||
|
|
||||||
|
|
||||||
CHKN(name = es_str2cstr(node->name, NULL));
|
|
||||||
@@ -1365,7 +1380,7 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
|
|
||||||
if ((grp_parse_err = regex_parser_configure_consume_and_return_group(args, pData)) != NULL)
|
|
||||||
FAIL(LN_BADCONFIG);
|
|
||||||
|
|
||||||
- CHKN(pData->re = pcre_compile(exp, 0, &error, &erroffset, NULL));
|
|
||||||
+ CHKN(pData->re = pcre2_compile((PCRE2_SPTR)exp, PCRE2_ZERO_TERMINATED, 0, &errcode, &erroffset, NULL));
|
|
||||||
|
|
||||||
pData->max_groups = ((pData->consume_group > pData->return_group) ? pData->consume_group :
|
|
||||||
pData->return_group) + 1;
|
|
||||||
@@ -1387,9 +1402,12 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
|
|
||||||
ln_dbgprintf(ctx, "couldn't allocate memory for regex-string for field: '%s'", name);
|
|
||||||
else if (grp_parse_err != NULL)
|
|
||||||
ln_dbgprintf(ctx, "%s for: '%s'", grp_parse_err, name);
|
|
||||||
- else if (pData->re == NULL)
|
|
||||||
+ else if (pData->re == NULL) {
|
|
||||||
+ PCRE2_UCHAR errbuffer[256];
|
|
||||||
+ pcre2_get_error_message(errcode, errbuffer, sizeof(errbuffer));
|
|
||||||
ln_dbgprintf(ctx, "couldn't compile regex(encountered error '%s' at char '%d' in pattern) "
|
|
||||||
- "for regex-matched field: '%s'", error, erroffset, name);
|
|
||||||
+ "for regex-matched field: '%s'", errbuffer, (int)erroffset, name);
|
|
||||||
+ }
|
|
||||||
regex_parser_data_destructor((void**)&pData);
|
|
||||||
}
|
|
||||||
if (exp != NULL) free(exp);
|
|
||||||
@@ -1401,7 +1419,7 @@ void* regex_parser_data_constructor(ln_fieldList_t *node, ln_ctx ctx) {
|
|
||||||
void regex_parser_data_destructor(void** dataPtr) {
|
|
||||||
if ((*dataPtr) != NULL) {
|
|
||||||
struct regex_parser_data_s *pData = (struct regex_parser_data_s*) *dataPtr;
|
|
||||||
- if (pData->re != NULL) pcre_free(pData->re);
|
|
||||||
+ if (pData->re != NULL) pcre2_code_free(pData->re);
|
|
||||||
free(pData);
|
|
||||||
*dataPtr = NULL;
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
diff -up liblognorm-2.0.6/doc/conf.py.orig liblognorm-2.0.6/doc/conf.py
|
|
||||||
--- liblognorm-2.0.6/doc/conf.py.orig 2022-07-19 14:01:01.094313222 +0200
|
|
||||||
+++ liblognorm-2.0.6/doc/conf.py 2022-07-19 14:01:43.454310057 +0200
|
|
||||||
@@ -56,7 +56,7 @@ release = '1.1.2'
|
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
||||||
# for a list of supported languages.
|
|
||||||
-language = None
|
|
||||||
+language = 'en'
|
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
|
||||||
# non-false value, then it is used:
|
|
||||||
BIN
liblognorm-2.0.3.tar.gz
Normal file
BIN
liblognorm-2.0.3.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
@ -1,17 +1,12 @@
|
|||||||
Name: liblognorm
|
Name: liblognorm
|
||||||
Version: 2.0.6
|
Version: 2.0.3
|
||||||
Release: 3
|
Release: 7
|
||||||
Summary: A tool to normalize log data
|
Summary: A tool to normalize log data
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: http://www.liblognorm.com
|
URL: http://www.liblognorm.com
|
||||||
Source0: http://www.liblognorm.com/files/download/%{name}-%{version}.tar.gz
|
Source0: http://www.liblognorm.com/files/download/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
Patch0: fix-build-error-due-to-sphinx-upgrade.patch
|
BuildRequires: chrpath libfastjson-devel libestr-devel pcre-devel
|
||||||
# https://github.com/rsyslog/liblognorm/commit/b5c595baa49360614ef531cb9621644e8cf5fec5
|
|
||||||
Patch1: Port-pcre-dependency-to-pcre2.patch
|
|
||||||
|
|
||||||
BuildRequires: chrpath libfastjson-devel libestr-devel pcre2-devel gcc
|
|
||||||
BuildRequires: autoconf automake libtool
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Briefly described, liblognorm is a tool to normalize log data.
|
Briefly described, liblognorm is a tool to normalize log data.
|
||||||
@ -55,7 +50,6 @@ log files.
|
|||||||
%autosetup -n %{name}-%{version} -p1
|
%autosetup -n %{name}-%{version} -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
autoreconf -vfi
|
|
||||||
%configure --enable-regexp --enable-docs --docdir=%{_docdir}/liblognorm/html \
|
%configure --enable-regexp --enable-docs --docdir=%{_docdir}/liblognorm/html \
|
||||||
--includedir=%{_includedir}/%{name}/
|
--includedir=%{_includedir}/%{name}/
|
||||||
|
|
||||||
@ -88,18 +82,6 @@ chrpath -d %{buildroot}%{_libdir}/liblognorm.so
|
|||||||
%doc %{_docdir}/liblognorm/html
|
%doc %{_docdir}/liblognorm/html
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Wed Jan 17 2024 yaoxin <yao_xin001@hoperun.com> - 2.0.6-3
|
|
||||||
- Port pcre dependency to pcre2
|
|
||||||
|
|
||||||
* Sat Jul 29 2023 xu_ping <707078654@qq.com> - 2.0.6-2
|
|
||||||
- Fix build error due to sphinx upgrade.
|
|
||||||
|
|
||||||
* Thu Jun 16 2022 SimpleUpdate Robot <tc@openeuler.org> - 2.0.6-1
|
|
||||||
- Upgrade to version 2.0.6
|
|
||||||
|
|
||||||
* Tue Jun 08 2021 wulei <wulei80@huawei.com> - 2.0.3-8
|
|
||||||
- fixes failed: error: no acceptable C compiler found in $PATH
|
|
||||||
|
|
||||||
* Fri Dec 20 2019 wangzhishun <wangzhishun1@huawei.com> - 2.0.3-7
|
* Fri Dec 20 2019 wangzhishun <wangzhishun1@huawei.com> - 2.0.3-7
|
||||||
- Package init
|
- Package init
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
version_control: github
|
|
||||||
src_repo: rsyslog/liblognorm
|
|
||||||
tag_prefix: ^v
|
|
||||||
seperator: .
|
|
||||||
Loading…
x
Reference in New Issue
Block a user