[tre] apply fixes from R fork of tre

Tom Callaway spot at fedoraproject.org
Tue Feb 4 23:05:59 UTC 2014


commit a48068513fb8e3da5b6341931f30e46cc89c383f
Author: Tom Callaway <spot at fedoraproject.org>
Date:   Tue Feb 4 17:51:45 2014 -0500

    apply fixes from R fork of tre

 tre-0.8.0-Rfixes-8e84229.patch |   48 +++++++++++++
 tre-0.8.0-Rfixes-d0a2382.patch |  150 ++++++++++++++++++++++++++++++++++++++++
 tre.spec                       |   12 +++-
 3 files changed, 209 insertions(+), 1 deletions(-)
---
diff --git a/tre-0.8.0-Rfixes-8e84229.patch b/tre-0.8.0-Rfixes-8e84229.patch
new file mode 100644
index 0000000..4ce62e6
--- /dev/null
+++ b/tre-0.8.0-Rfixes-8e84229.patch
@@ -0,0 +1,48 @@
+diff -up tre-0.8.0/lib/tre-compile.c.Rfixes tre-0.8.0/lib/tre-compile.c
+--- tre-0.8.0/lib/tre-compile.c.Rfixes	2014-02-04 17:32:59.166084511 -0500
++++ tre-0.8.0/lib/tre-compile.c	2014-02-04 17:33:17.165067538 -0500
+@@ -1890,6 +1890,8 @@ tre_compile(regex_t *preg, const tre_cha
+   parse_ctx.len = n;
+   parse_ctx.cflags = cflags;
+   parse_ctx.max_backref = -1;
++/* workaround for PR#14408: use 8-bit optimizations in 8-bit mode */
++  parse_ctx.cur_max = (cflags & REG_USEBYTES) ? 1 : TRE_MB_CUR_MAX;
+   DPRINT(("tre_compile: parsing '%.*" STRF "'\n", (int)n, regex));
+   errcode = tre_parse(&parse_ctx);
+   if (errcode != REG_OK)
+diff -up tre-0.8.0/lib/tre.h.Rfixes tre-0.8.0/lib/tre.h
+--- tre-0.8.0/lib/tre.h.Rfixes	2014-02-04 17:34:20.173008141 -0500
++++ tre-0.8.0/lib/tre.h	2014-02-04 17:39:39.044707983 -0500
+@@ -106,6 +106,8 @@ typedef enum {
+ #define REG_RIGHT_ASSOC (REG_LITERAL << 1)
+ #define REG_UNGREEDY    (REG_RIGHT_ASSOC << 1)
+ 
++#define REG_USEBYTES    (REG_UNGREEDY << 1)
++
+ /* POSIX tre_regexec() flags. */
+ #define REG_NOTBOL 1
+ #define REG_NOTEOL (REG_NOTBOL << 1)
+diff -up tre-0.8.0/lib/tre-parse.c.Rfixes tre-0.8.0/lib/tre-parse.c
+--- tre-0.8.0/lib/tre-parse.c.Rfixes	2014-02-04 17:33:24.393060723 -0500
++++ tre-0.8.0/lib/tre-parse.c	2014-02-04 17:33:44.011042227 -0500
+@@ -332,7 +332,7 @@ tre_parse_bracket_items(tre_parse_ctx_t
+ 		  if (!class)
+ 		    status = REG_ECTYPE;
+ 		  /* Optimize character classes for 8 bit character sets. */
+-		  if (status == REG_OK && TRE_MB_CUR_MAX == 1)
++		  if (status == REG_OK && ctx->cur_max == 1)
+ 		    {
+ 		      status = tre_expand_ctype(ctx->mem, class, items,
+ 						&i, &max_i, ctx->cflags);
+diff -up tre-0.8.0/lib/tre-parse.h.Rfixes tre-0.8.0/lib/tre-parse.h
+--- tre-0.8.0/lib/tre-parse.h.Rfixes	2014-02-04 17:33:51.032035608 -0500
++++ tre-0.8.0/lib/tre-parse.h	2014-02-04 17:34:14.212013759 -0500
+@@ -38,6 +38,8 @@ typedef struct {
+   int nofirstsub;
+   /* The currently set approximate matching parameters. */
+   int params[TRE_PARAM_LAST];
++  /* the CUR_MAX in use */
++  int cur_max;
+ } tre_parse_ctx_t;
+ 
+ /* Parses a wide character regexp pattern into a syntax tree.  This parser
diff --git a/tre-0.8.0-Rfixes-d0a2382.patch b/tre-0.8.0-Rfixes-d0a2382.patch
new file mode 100644
index 0000000..4519402
--- /dev/null
+++ b/tre-0.8.0-Rfixes-d0a2382.patch
@@ -0,0 +1,150 @@
+diff -up tre-0.8.0/lib/regcomp.c.Rfixes2 tre-0.8.0/lib/regcomp.c
+--- tre-0.8.0/lib/regcomp.c.Rfixes2	2014-02-04 17:35:13.915957501 -0500
++++ tre-0.8.0/lib/regcomp.c	2014-02-04 17:36:32.919883096 -0500
+@@ -99,12 +99,58 @@ tre_regncomp(regex_t *preg, const char *
+   return ret;
+ }
+ 
++/* this version takes bytes literally, to be used with raw vectors */
++int
++tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags)
++{
++  int ret;
++#if TRE_WCHAR /* wide chars = we need to convert it all to the wide format */
++  tre_char_t *wregex;
++  size_t i;
++
++  wregex = xmalloc(sizeof(tre_char_t) * n);
++  if (wregex == NULL)
++    return REG_ESPACE;
++
++  for (i = 0; i < n; i++)
++    wregex[i] = (tre_char_t) ((unsigned char) regex[i]);
++
++  ret = tre_compile(preg, wregex, n, cflags | REG_USEBYTES);
++  xfree(wregex);
++#else /* !TRE_WCHAR */
++  ret = tre_compile(preg, (const tre_char_t *)regex, n, cflags | REG_USEBYTES);
++#endif /* !TRE_WCHAR */
++
++  return ret;
++}
++
+ int
+ tre_regcomp(regex_t *preg, const char *regex, int cflags)
+ {
+   return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags);
+ }
+ 
++int
++tre_regcompb(regex_t *preg, const char *regex, int cflags)
++{
++  int ret;
++  tre_char_t *wregex;
++  size_t wlen, n = strlen(regex);
++  unsigned int i;
++  const unsigned char *str = (const unsigned char *)regex;
++  tre_char_t *wstr;
++
++  wregex = xmalloc(sizeof(tre_char_t) * (n + 1));
++  if (wregex == NULL) return REG_ESPACE;
++  wstr = wregex;
++
++  for (i = 0; i < n; i++) *(wstr++) = *(str++);
++  wlen = n;
++  wregex[wlen] = L'\0';
++  ret = tre_compile(preg, wregex, wlen, cflags | REG_USEBYTES);
++  xfree(wregex);
++  return ret;
++}
+ 
+ #ifdef TRE_WCHAR
+ int
+diff -up tre-0.8.0/lib/regexec.c.Rfixes2 tre-0.8.0/lib/regexec.c
+--- tre-0.8.0/lib/regexec.c.Rfixes2	2014-02-04 17:36:47.962868935 -0500
++++ tre-0.8.0/lib/regexec.c	2014-02-04 17:38:02.141799122 -0500
+@@ -216,6 +216,23 @@ tre_regexec(const regex_t *preg, const c
+   return tre_regnexec(preg, str, (unsigned)-1, nmatch, pmatch, eflags);
+ }
+ 
++int
++tre_regexecb(const regex_t *preg, const char *str,
++        size_t nmatch, regmatch_t pmatch[], int eflags)
++{
++  tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
++
++  return tre_match(tnfa, str, (unsigned)-1, STR_BYTE, nmatch, pmatch, eflags);
++}
++
++int
++tre_regnexecb(const regex_t *preg, const char *str, size_t len,
++        size_t nmatch, regmatch_t pmatch[], int eflags)
++{
++  tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
++
++  return tre_match(tnfa, str, len, STR_BYTE, nmatch, pmatch, eflags);
++}
+ 
+ #ifdef TRE_WCHAR
+ 
+@@ -309,6 +326,16 @@ tre_regaexec(const regex_t *preg, const
+   return tre_reganexec(preg, str, (unsigned)-1, match, params, eflags);
+ }
+ 
++int
++tre_regaexecb(const regex_t *preg, const char *str,
++          regamatch_t *match, regaparams_t params, int eflags)
++{
++  tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
++
++  return tre_match_approx(tnfa, str, (unsigned)-1, STR_BYTE,
++                          match, params, eflags);
++}
++
+ #ifdef TRE_WCHAR
+ 
+ int
+diff -up tre-0.8.0/lib/tre.h.Rfixes2 tre-0.8.0/lib/tre.h
+--- tre-0.8.0/lib/tre.h.Rfixes2	2014-02-04 17:38:11.315790492 -0500
++++ tre-0.8.0/lib/tre.h	2014-02-04 17:39:39.044707983 -0500
+@@ -137,6 +137,13 @@ extern int
+ tre_regexec(const regex_t *preg, const char *string, size_t nmatch,
+ 	regmatch_t pmatch[], int eflags);
+ 
++extern int
++tre_regcompb(regex_t *preg, const char *regex, int cflags);
++
++extern int
++tre_regexecb(const regex_t *preg, const char *string, size_t nmatch,
++	regmatch_t pmatch[], int eflags);
++
+ extern size_t
+ tre_regerror(int errcode, const regex_t *preg, char *errbuf,
+ 	 size_t errbuf_size);
+@@ -167,6 +174,14 @@ extern int
+ tre_regnexec(const regex_t *preg, const char *string, size_t len,
+ 	 size_t nmatch, regmatch_t pmatch[], int eflags);
+ 
++/* regn*b versions take byte literally as 8-bit values */
++extern int
++tre_regncompb(regex_t *preg, const char *regex, size_t n, int cflags);
++
++extern int
++tre_regnexecb(const regex_t *preg, const char *str, size_t len,
++	  size_t nmatch, regmatch_t pmatch[], int eflags);
++
+ #ifdef TRE_WCHAR
+ extern int
+ tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t len, int cflags);
+@@ -210,6 +225,11 @@ tre_regaexec(const regex_t *preg, const
+ extern int
+ tre_reganexec(const regex_t *preg, const char *string, size_t len,
+ 	  regamatch_t *match, regaparams_t params, int eflags);
++
++extern int
++tre_regaexecb(const regex_t *preg, const char *string,
++	  regamatch_t *match, regaparams_t params, int eflags);
++
+ #ifdef TRE_WCHAR
+ /* Wide character approximate matching. */
+ extern int
diff --git a/tre.spec b/tre.spec
index 2976fae..054c751 100644
--- a/tre.spec
+++ b/tre.spec
@@ -2,13 +2,17 @@
 
 Name: tre
 Version: 0.8.0
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: BSD
 Group: System Environment/Libraries
 Source0: http://laurikari.net/tre/%{name}-%{version}.tar.bz2
 Patch0: %{name}-chicken.patch
 # make internal tests of agrep work with just-built shared library
 Patch1: %{name}-tests.patch
+# add additional functions needed for R to use tre sys lib
+# https://github.com/laurikari/tre/pull/14
+Patch2: tre-0.8.0-Rfixes-8e84229.patch
+Patch3: tre-0.8.0-Rfixes-d0a2382.patch
 Summary: POSIX compatible regexp library with approximate matching
 URL: http://laurikari.net/tre/
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -58,6 +62,8 @@ regexps of any length, any number of errors, and non-uniform costs.
 ln -s lib tre
 %patch0 -p1 -b .chicken
 %patch1 -p1 -b .tests
+%patch2 -p1 -b .Rfixes
+%patch3 -p1 -b .Rfixes2
 
 %build
 %configure --disable-static --disable-rpath
@@ -112,6 +118,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/agrep.1*
 
 %changelog
+* Tue Feb  4 2014 Tom Callaway <spot at fedoraproject.org> - 0.8.0-9
+- add missing changes from R to be able to use tre in R as system lib (and resolve arm fails)
+  Credit to Orion Poplawski.
+
 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.8.0-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 


More information about the scm-commits mailing list