Hello community,

here is the log from the commit of package libt3highlight for openSUSE:Factory 
checked in at 2019-08-23 11:09:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libt3highlight (Old)
 and      /work/SRC/openSUSE:Factory/.libt3highlight.new.7948 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libt3highlight"

Fri Aug 23 11:09:33 2019 rev:9 rq:725407 version:0.4.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/libt3highlight/libt3highlight.changes    
2019-01-08 12:31:32.648071775 +0100
+++ /work/SRC/openSUSE:Factory/.libt3highlight.new.7948/libt3highlight.changes  
2019-08-23 11:09:38.246459172 +0200
@@ -1,0 +2,7 @@
+Thu Aug 22 19:43:41 UTC 2019 - Jan Engelhardt <[email protected]>
+
+- Update to new upstream release 0.4.8
+  * These releases fixes incorrect calls to free when validation of
+    highlight data failed.
+
+-------------------------------------------------------------------

Old:
----
  libt3highlight-0.4.6.tar.bz2

New:
----
  libt3highlight-0.4.8.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libt3highlight.spec ++++++
--- /var/tmp/diff_new_pack.dxHEwt/_old  2019-08-23 11:09:39.098459067 +0200
+++ /var/tmp/diff_new_pack.dxHEwt/_new  2019-08-23 11:09:39.098459067 +0200
@@ -18,16 +18,15 @@
 
 Name:           libt3highlight
 %define lname  libt3highlight2
-Version:        0.4.6
+Version:        0.4.8
 Release:        0
 Summary:        The Tilde Toolkit's syntax highlighting library
 License:        GPL-3.0-only
 Group:          Development/Libraries/C and C++
-Url:            http://os.ghalkes.nl/t3/libt3highlight.html
+URL:            https://os.ghalkes.nl/t3/libt3highlight.html
 
 #Git-Clone:    git://github.com/gphalkes/t3highlight
-Source:         http://os.ghalkes.nl/dist/%name-%version.tar.bz2
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+Source:         https://os.ghalkes.nl/dist/%name-%version.tar.bz2
 BuildRequires:  fdupes
 BuildRequires:  gettext-tools
 BuildRequires:  libtool
@@ -70,7 +69,7 @@
 This subpackage contains the T3 highlighting utility.
 
 %prep
-%setup -q
+%autosetup -p1
 
 %build
 export CC=gcc
@@ -86,13 +85,11 @@
 %postun -p /sbin/ldconfig -n %lname
 
 %files -n %lname
-%defattr(-,root,root)
 %_libdir/libt3highlight.so.2*
-%doc COPYING
 %_datadir/%lname/
+%license COPYING
 
 %files devel
-%defattr(-,root,root)
 %_includedir/t3/
 %_libdir/libt3highlight.so
 %_libdir/pkgconfig/libt3highlight.pc
@@ -100,7 +97,6 @@
 %exclude %_docdir/%name/COPYING
 
 %files utils
-%defattr(-,root,root)
 %_bindir/t3*
 %_mandir/man1/t3*.1*
 

++++++ libt3highlight-0.4.6.tar.bz2 -> libt3highlight-0.4.8.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/Changelog 
new/libt3highlight-0.4.8/Changelog
--- old/libt3highlight-0.4.6/Changelog  2018-12-31 10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/Changelog  2019-05-10 09:35:30.000000000 +0200
@@ -1,3 +1,12 @@
+Version 0.4.8:
+    Bug fixes:
+    - Fixed incorrect free on uninitialized pointers when validation of
+      highlighting data fails.
+
+Version 0.4.7:
+    Introduce a PCRE2 compatibility layer using PCRE, to allow compilation on
+    platforms which don't provide PCRE2.
+
 Version 0.4.6:
     New features:
     - Migrated to using PCRE2. This allows using the PCRE2 JIT, which provides 
a
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/README 
new/libt3highlight-0.4.8/README
--- old/libt3highlight-0.4.6/README     2018-12-31 10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/README     2019-05-10 09:35:30.000000000 +0200
@@ -23,7 +23,7 @@
 ==============================
 
 libt3highlight requires the GNU libtool utility to be compiled. Furthermore, it
-requires libpcre and libt3config (version 0.2.0 or higher).
+requires libpcre2 (or libpcre) and libt3config (version 0.2.0 or higher).
 
 There are two ways in which to compile libt3highlight:
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/config.pkg 
new/libt3highlight-0.4.8/config.pkg
--- old/libt3highlight-0.4.6/config.pkg 2018-12-31 10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/config.pkg 2019-05-10 09:35:30.000000000 +0200
@@ -23,14 +23,28 @@
 #define PCRE2_CODE_UNIT_WIDTH 8
 #include <pcre2.h>
 int main(int argc, char *argv[]) {
-       int *err;
+       int err;
        PCRE2_SIZE err_offset;
        pcre2_code_8 *pcre = pcre2_compile("pattern", PCRE2_ZERO_TERMINATED, 
PCRE2_UTF, &err, &err_offset, NULL);
        return 0;
 }
 EOF
 
-       pkgconfig libpcre2-8 LIBPCRE test_link PKGCONFIG_REQUIRES_PRIVATE || \
+       pkgconfig libpcre2-8 LIBPCRE test_link PKGCONFIG_REQUIRES_PRIVATE || {
+               clean_c
+               cat > .config.c <<EOF
+#include <pcre.h>
+int main(int argc, char *argv[]) {
+       int err;
+       int err_offset;
+       char *error_message;
+       pcre *pcre = pcre_compile2("pattern", PCRE_UTF8, &err, &error_message, 
&err_offset, NULL);
+       return 0;
+}
+EOF
+               pkgconfig libpcre LIBPCRE test_link PKGCONFIG_REQUIRES_PRIVATE 
&& \
+                       CONFIGFLAGS="${CONFIGFLAGS} -DPCRE_COMPAT"
+       } || \
                error "!! Can not find libpcre2. libpcre2 is required to 
compile libt3highlight."
 
        clean_c
@@ -46,7 +60,7 @@
                error "!! Can not find libt3config. libt3config is required to 
compile libt3highlight."
 
        PKGCONFIG_DESC="Syntax highlighting library"
-       PKGCONFIG_VERSION="0.4.6"
+       PKGCONFIG_VERSION="0.4.8"
        PKGCONFIG_URL="http://os.ghalkes.nl/t3/libt3highlight.html";
        PKGCONFIG_CFLAGS="-I\${includedir}/t3/highlight"
        PKGCONFIG_LIBS="-lt3highlight"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/configure 
new/libt3highlight-0.4.8/configure
--- old/libt3highlight-0.4.6/configure  2018-12-31 10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/configure  2019-05-10 09:35:30.000000000 +0200
@@ -234,7 +234,7 @@
        check_message "Checking for $1... "
        shift
 
-       if test_make "$@" .config.o >> config.log 2>&1 ; then
+       if test_make "CFLAGS=$CFLAGS" "$@" .config.o >> config.log 2>&1 ; then
                check_message_result "yes"
                true
        else
@@ -250,7 +250,7 @@
        check_message "Checking for $1... "
        shift
 
-       if test_make "$@" .config >> config.log 2>&1 ; then
+       if test_make "CFLAGS=$CFLAGS" "$@" .config >> config.log 2>&1 ; then
                check_message_result "yes"
                true
        else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/man/t3highlight.1 
new/libt3highlight-0.4.8/man/t3highlight.1
--- old/libt3highlight-0.4.6/man/t3highlight.1  2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/man/t3highlight.1  2019-05-10 09:35:30.000000000 
+0200
@@ -1,6 +1,6 @@
 .\" Generated by manscript from t3highlight.1.txt
-.TH "T3HIGHLIGHT" "1" "2013/03/21" "Version 0.4.6" "Soure highlighter"
-.hw /usr/share/doc/libt3key-0.4.6 http://os.ghalkes.nl/t3/libt3key.html
+.TH "T3HIGHLIGHT" "1" "2013/03/21" "Version 0.4.8" "Soure highlighter"
+.hw /usr/share/doc/libt3key-0.4.8 http://os.ghalkes.nl/t3/libt3key.html
 .SH NAME
 t3highlight \- create syntax highlighted document from source file.
 .SH SYNOPSIS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/mk/libt3highlight.in 
new/libt3highlight-0.4.8/mk/libt3highlight.in
--- old/libt3highlight-0.4.6/mk/libt3highlight.in       2018-12-31 
10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/mk/libt3highlight.in       2019-05-10 
09:35:30.000000000 +0200
@@ -52,7 +52,7 @@
 SILENTCCLT=@echo '[CCLT]' $< ;
 SILENTLDLT=@echo '[LDLT]' $@ ;
 
-OBJECTS=src/highlight.lo src/io.lo src/vector.lo src/analyse.lo src/utf8.lo 
src/match.lo src/highlight_shared.lo
+OBJECTS=src/highlight.lo src/io.lo src/vector.lo src/analyse.lo src/utf8.lo 
src/match.lo src/pcre_compat.lo src/highlight_shared.lo
 
 all: src/libt3highlight.la
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/analyse.c 
new/libt3highlight-0.4.8/src/analyse.c
--- old/libt3highlight-0.4.6/src/analyse.c      2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/analyse.c      2019-05-10 09:35:30.000000000 
+0200
@@ -12,7 +12,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <errno.h>
+#ifdef PCRE_COMPAT
+#include "pcre_compat.h"
+#else
 #include <pcre2.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/highlight.c 
new/libt3highlight-0.4.8/src/highlight.c
--- old/libt3highlight-0.4.6/src/highlight.c    2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/highlight.c    2019-05-10 09:35:30.000000000 
+0200
@@ -12,7 +12,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <errno.h>
+#ifdef PCRE_COMPAT
+#include "pcre_compat.h"
+#else
 #include <pcre2.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 
@@ -65,8 +69,10 @@
     _t3_highlight_set_error(
         error, (flags & T3_HIGHLIGHT_VERBOSE_ERROR) ? local_error.error : 
T3_ERR_INVALID_FORMAT,
         local_error.line_number, local_error.file_name, local_error.extra, 
flags);
-    free(local_error.file_name);
-    free(local_error.extra);
+    if (flags & T3_HIGHLIGHT_VERBOSE_ERROR) {
+      free(local_error.file_name);
+      free(local_error.extra);
+    }
     goto return_error;
   }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/highlight.h 
new/libt3highlight-0.4.8/src/highlight.h
--- old/libt3highlight-0.4.6/src/highlight.h    2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/highlight.h    2019-05-10 09:35:30.000000000 
+0200
@@ -38,7 +38,7 @@
     The value 0 is an invalid value which should be replaced by the script
     that builds the release package.
 */
-#define T3_HIGHLIGHT_VERSION 0x000406
+#define T3_HIGHLIGHT_VERSION 0x000408
 
 /** @name Error codes (libt3highlight specific) */
 /*@{*/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/internal.h 
new/libt3highlight-0.4.8/src/internal.h
--- old/libt3highlight-0.4.6/src/internal.h     2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/internal.h     2019-05-10 09:35:30.000000000 
+0200
@@ -14,7 +14,11 @@
 #ifndef INTERNAL_H
 #define INTERNAL_H
 
+#ifdef PCRE_COMPAT
+#include "pcre_compat.h"
+#else
 #include <pcre2.h>
+#endif
 
 #include "highlight_api.h"
 #include "vector.h"
@@ -91,7 +95,7 @@
 struct t3_highlight_match_t {
   const t3_highlight_t *highlight;
   VECTOR(state_mapping_t) mapping;
-  size_t start, match_start, end, last_progress;
+  PCRE2_SIZE start, match_start, end, last_progress;
   dst_idx_t state;
   int begin_attribute, match_attribute, last_progress_state;
   t3_bool utf8_checked;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/io.c 
new/libt3highlight-0.4.8/src/io.c
--- old/libt3highlight-0.4.6/src/io.c   2018-12-31 10:52:27.000000000 +0100
+++ new/libt3highlight-0.4.8/src/io.c   2019-05-10 09:35:30.000000000 +0200
@@ -12,7 +12,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <errno.h>
+#ifdef PCRE_COMPAT
+#include "pcre_compat.h"
+#else
 #include <pcre2.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -404,7 +408,7 @@
     pcre2_match_data_free_8(match_data);
     return t3_false;
   }
-  if (pcre2_match(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, match_data, 
NULL) > 0) {
+  if (pcre2_match_8(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, match_data, 
NULL) > 0) {
     goto pattern_succeeded;
   }
   pcre2_code_free_8(pcre);
@@ -415,7 +419,7 @@
     pcre2_match_data_free_8(match_data);
     return t3_false;
   }
-  if (pcre2_match(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, match_data, 
NULL) > 0) {
+  if (pcre2_match_8(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, match_data, 
NULL) > 0) {
     goto pattern_succeeded;
   }
   pcre2_code_free_8(pcre);
@@ -439,7 +443,7 @@
         continue;
       }
 
-      if (pcre2_match(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, match_data, 
NULL) < 0) {
+      if (pcre2_match_8(pcre, (PCRE2_SPTR8)line, line_length, 0, 0, 
match_data, NULL) < 0) {
         pcre2_code_free_8(pcre);
         continue;
       }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/match.c 
new/libt3highlight-0.4.8/src/match.c
--- old/libt3highlight-0.4.6/src/match.c        2018-12-31 10:52:27.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/match.c        2019-05-10 09:35:30.000000000 
+0200
@@ -12,7 +12,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <errno.h>
+#ifdef PCRE_COMPAT
+#include "pcre_compat.h"
+#else
 #include <pcre2.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 
@@ -169,8 +173,8 @@
       }
     }
 
-    if (pcre2_match(regex, (PCRE2_SPTR8)context->line, context->size, 
context->match->match_start,
-                    options, context->match_data, NULL) >= 0 &&
+    if (pcre2_match_8(regex, (PCRE2_SPTR8)context->line, context->size, 
context->match->match_start,
+                      options, context->match_data, NULL) >= 0 &&
         (context->best == NULL ||
          pcre2_get_ovector_pointer_8(context->match_data)[1] > 
context->best_end)) {
       const PCRE2_SIZE *ovector = 
pcre2_get_ovector_pointer_8(context->match_data);
@@ -241,7 +245,7 @@
     match->last_progress_state = match->state;
   }
 
-  for (match->match_start = match->end; match->match_start <= size;
+  for (match->match_start = match->end; match->match_start <= (PCRE2_SIZE)size;
        match->match_start +=
        (match->highlight->flags & T3_HIGHLIGHT_UTF8) ? 
step_utf8(line[match->match_start]) : 1) {
     match_internal(&context);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/pcre_compat.c 
new/libt3highlight-0.4.8/src/pcre_compat.c
--- old/libt3highlight-0.4.6/src/pcre_compat.c  1970-01-01 01:00:00.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/pcre_compat.c  2019-05-10 09:35:30.000000000 
+0200
@@ -0,0 +1,131 @@
+/* Copyright (C) 2019 G.P. Halkes
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 3, as
+   published by the Free Software Foundation.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "pcre_compat.h"
+
+#ifdef PCRE_COMPAT
+#include <string.h>
+
+static const char *last_error_message = NULL;
+static int last_error_code = 0;
+
+pcre2_code_8 *pcre2_compile_8(PCRE2_SPTR8 pattern, PCRE2_SIZE pattern_size, 
uint32_t options,
+                              int *errorcode, PCRE2_SIZE *erroroffset, void 
*ccontext) {
+  const char *error_message;
+  if (pattern_size != PCRE2_ZERO_TERMINATED) {
+    abort();
+  }
+  if (ccontext != NULL) {
+    abort();
+  }
+  pcre2_code_8 *result = malloc(sizeof(pcre2_code_8));
+  result->regex = NULL;
+  result->extra = NULL;
+
+  result->regex =
+      pcre_compile2((const char *)pattern, options, errorcode, &error_message, 
erroroffset, NULL);
+  if (result->regex == NULL) {
+    last_error_message = error_message;
+    last_error_code = *errorcode;
+    free(result);
+    return NULL;
+  }
+  return result;
+}
+
+int pcre2_pattern_info_8(const pcre2_code_8 *code, uint32_t what, void *where) 
{
+  uint32_t value;
+  int result;
+  if (what != PCRE2_INFO_MINLENGTH) {
+    return PCRE2_ERROR_BADOPTION;
+  }
+  result = pcre_fullinfo(code->regex, code->extra, what, &value);
+  if (result == 0) {
+    *(int *)where = value;
+  }
+  return result;
+}
+
+int pcre2_jit_compile_8(pcre2_code_8 *code, uint32_t options) {
+  const char *error_message;
+
+  (void)options;
+
+  code->extra = pcre_study(code->regex, 0, &error_message);
+  return 0;
+}
+
+pcre2_match_data_8 *pcre2_match_data_create_8(uint32_t ovecsize, void 
*gcontext) {
+  int *result;
+
+  (void)gcontext;
+
+  if (ovecsize == 0) {
+    ++ovecsize;
+  }
+  result = malloc(sizeof(int) * (1 + 2 * ovecsize));
+  *result = 2 * ovecsize;
+  return result;
+}
+
+void pcre2_match_data_free_8(pcre2_match_data_8 *match_data) { 
free(match_data); }
+
+PCRE2_SIZE *pcre2_get_ovector_pointer_8(pcre2_match_data_8 *match_data) { 
return match_data + 1; }
+uint32_t pcre2_get_ovector_count_8(pcre2_match_data_8 *match_data) { return 
match_data[0] / 2; }
+
+pcre2_match_data_8 *pcre2_match_data_create_from_pattern_8(const pcre2_code_8 
*code,
+                                                           void *gcontext) {
+  (void)code;
+  (void)gcontext;
+  return pcre2_match_data_create_8(15, NULL);
+}
+
+void pcre2_code_free_8(pcre2_code_8 *code) {
+  if (code == NULL) {
+    return;
+  }
+  pcre_free(code->regex);
+  pcre_free_study(code->extra);
+  free(code);
+}
+
+int pcre2_match_8(const pcre2_code_8 *code, PCRE2_SPTR8 subject, PCRE2_SIZE 
length,
+                  PCRE2_SIZE startoffset, uint32_t options, pcre2_match_data_8 
*match_data,
+                  void *mcontext) {
+  (void)mcontext;
+  return pcre_exec(code->regex, code->extra, (const char *)subject,
+                   length == PCRE2_ZERO_TERMINATED ? strlen((const char 
*)subject) : length,
+                   startoffset, options, match_data + 1, *match_data);
+}
+
+int pcre2_get_error_message_8(int errorcode, PCRE2_UCHAR8 *buffer, PCRE2_SIZE 
bufflen) {
+  char *copy_end;
+  if (errorcode == last_error_code) {
+    copy_end = strncpy((char *)buffer, last_error_message, bufflen);
+  } else {
+    copy_end = strncpy((char *)buffer, "unknown error", bufflen);
+  }
+  buffer[bufflen - 1] = 0;
+  if (copy_end < (char *)buffer + bufflen) {
+    return copy_end - (char *)buffer;
+  }
+  return PCRE2_ERROR_NOMEMORY;
+}
+
+int pcre2_substring_number_from_name_8(const pcre2_code_8 *code, PCRE2_SPTR8 
name) {
+  return pcre_get_stringnumber(code->regex, (const char *)name);
+}
+#else
+int _t3_highlight_no_empty_translation_unit;
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libt3highlight-0.4.6/src/pcre_compat.h 
new/libt3highlight-0.4.8/src/pcre_compat.h
--- old/libt3highlight-0.4.6/src/pcre_compat.h  1970-01-01 01:00:00.000000000 
+0100
+++ new/libt3highlight-0.4.8/src/pcre_compat.h  2019-05-10 09:35:30.000000000 
+0200
@@ -0,0 +1,92 @@
+/* Copyright (C) 2019 G.P. Halkes
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 3, as
+   published by the Free Software Foundation.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contains a partial implementation of the PCRE2 API using the PCRE 
API. Note that a few
+   short-cuts have been taken to allow this to work. For example, the general 
context has been
+   replaced by void* because it is not used anywhere. */
+
+#ifndef PCRE_COMPAT_H
+#define PCRE_COMPAT_H
+
+#include <t3highlight/highlight_api.h>
+
+#ifdef PCRE_COMPAT
+
+#include <pcre.h>
+#include <stdint.h>
+
+/* Although PCRE2_SIZE is size_t, in the PCRE API it is int. */
+#define PCRE2_SIZE int
+#define PCRE2_SPTR8 const unsigned char *
+#define PCRE2_ZERO_TERMINATED ((PCRE2_SIZE)-1)
+#define PCRE2_INFO_MINLENGTH PCRE_INFO_MINLENGTH
+#define PCRE2_UTF PCRE_UTF8
+#define PCRE2_ANCHORED PCRE_ANCHORED
+#define PCRE2_ERROR_NOMEMORY PCRE_ERROR_NOMEMORY
+#define PCRE2_UCHAR8 unsigned char
+#define PCRE2_JIT_COMPLETE 1
+
+#define PCRE2_NO_UTF_CHECK PCRE_NO_UTF8_CHECK
+#define PCRE2_NOTEMPTY PCRE_NOTEMPTY
+#define PCRE2_CASELESS PCRE_CASELESS
+
+#define PCRE2_ERROR_BADOPTION PCRE_ERROR_BADOPTION
+
+typedef struct {
+  pcre *regex;
+  pcre_extra *extra;
+} pcre2_code_8;
+
+typedef int pcre2_match_data_8;
+
+/* Redefine the symbol names to prevent potential symbol clashes with the 
actual pcre2 library. */
+#define pcre2_compile_8 t3_highlight_pcre2_compile
+#define pcre2_pattern_info_8 t3_highlight_pcre2_pattern_info
+#define pcre2_jit_compile_8 t3_highlight_pcre2_jit_compile
+#define pcre2_match_data_create_8 t3_highlight_pcre2_match_data_create
+#define pcre2_match_data_free_8 t3_highlight_pcre2_match_data_free
+#define pcre2_match_data_create_from_pattern_8 
t3_highlight_pcre2_match_data_create_from_pattern
+#define pcre2_code_free_8 t3_highlight_pcre2_code_free
+#define pcre2_get_ovector_pointer_8 t3_highlight_pcre2_get_ovector_pointer
+#define pcre2_get_ovector_count_8 t3_highlight_pcre2_get_ovector_count
+#define pcre2_match_8 t3_highlight_pcre2_match
+#define pcre2_get_error_message_8 t3_highlight_pcre2_get_error_message
+#define pcre2_substring_number_from_name_8 
t3_highlight_pcre2_substring_number_from_name
+
+T3_HIGHLIGHT_LOCAL pcre2_code_8 *pcre2_compile_8(PCRE2_SPTR8 pattern, 
PCRE2_SIZE pattern_size,
+                                                 uint32_t options, int 
*errorcode,
+                                                 PCRE2_SIZE *erroroffset, void 
*ccontext);
+
+T3_HIGHLIGHT_LOCAL int pcre2_pattern_info_8(const pcre2_code_8 *code, uint32_t 
what, void *where);
+T3_HIGHLIGHT_LOCAL int pcre2_jit_compile_8(pcre2_code_8 *code, uint32_t 
options);
+T3_HIGHLIGHT_LOCAL pcre2_match_data_8 *pcre2_match_data_create_8(uint32_t 
ovecsize, void *gcontext);
+T3_HIGHLIGHT_LOCAL void pcre2_match_data_free_8(pcre2_match_data_8 
*match_data);
+T3_HIGHLIGHT_LOCAL pcre2_match_data_8 *pcre2_match_data_create_from_pattern_8(
+    const pcre2_code_8 *code, void *gcontext);
+T3_HIGHLIGHT_LOCAL PCRE2_SIZE *pcre2_get_ovector_pointer_8(pcre2_match_data_8 
*match_data);
+T3_HIGHLIGHT_LOCAL uint32_t pcre2_get_ovector_count_8(pcre2_match_data_8 
*match_data);
+T3_HIGHLIGHT_LOCAL void pcre2_code_free_8(pcre2_code_8 *code);
+T3_HIGHLIGHT_LOCAL int pcre2_match_8(const pcre2_code_8 *code, PCRE2_SPTR8 
subject,
+                                     PCRE2_SIZE length, PCRE2_SIZE 
startoffset, uint32_t options,
+                                     pcre2_match_data_8 *match_data, void 
*mcontext);
+
+T3_HIGHLIGHT_LOCAL int pcre2_get_error_message_8(int errorcode, PCRE2_UCHAR8 
*buffer,
+                                                 PCRE2_SIZE bufflen);
+T3_HIGHLIGHT_LOCAL int pcre2_substring_number_from_name_8(const pcre2_code_8 
*code,
+                                                          PCRE2_SPTR8 name);
+#else
+T3_HIGHLIGHT_LOCAL extern int _t3_highlight_no_empty_translation_unit;
+#endif
+
+#endif  // PCRE_COMPAT_H


Reply via email to