Hi, On Mon, 31 Jul 2023 04:44:14 +0100, Nick Morrott <knowledgejun...@gmail.com> wrote:
> On 2023/07/22 at 08:43, Stephen Kitt wrote: > >aOn Sat, 22 Jul 2023 16:14:06 +0200, Bastian Germann <b...@debian.org> > >wrote: > > > I suggest to remove the package. I do not think upstream will deal with > > > this. > > > > qxw’s usage of pcre seems simple enough, I’ll try to come up with a patch. > > In the meantime, I will look to spend some time understanding the > pcre3->pcre2 migration and patching qxw in the short term, if Stephen does > not have time to do so. It took me longer to get round to this than I hoped, but here is a patch for qxw. I’ve already forwarded it upstream. Regards, Stephen
Description: Port to pcre2 Author: Stephen Kitt <sk...@debian.org> Forwarded: q...@quinapalus.com --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ PKG_CONFIG ?= pkg-config CFLAGS := -Wall -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wno-deprecated-declarations `$(PKG_CONFIG) --cflags glib-2.0` `$(PKG_CONFIG) --cflags gtk+-2.0` -I/opt/local/include `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS` -Wpedantic -Wextra -Wno-unused-parameter # CFLAGS := -Wall -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security `$(PKG_CONFIG) --cflags glib-2.0` `$(PKG_CONFIG) --cflags gtk+-2.0` -I/opt/local/include -LFLAGS := -Wl,-Bsymbolic-functions -Wl,-z,relro -L/opt/local/lib `$(PKG_CONFIG) --libs glib-2.0` `$(PKG_CONFIG) --libs gtk+-2.0` -lm -ldl -lpcre -pthread -lgthread-2.0 `dpkg-buildflags --get LDFLAGS` +LFLAGS := -Wl,-Bsymbolic-functions -Wl,-z,relro -L/opt/local/lib `$(PKG_CONFIG) --libs glib-2.0` `$(PKG_CONFIG) --libs gtk+-2.0` -lm -ldl `pcre2-config --libs8` -pthread -lgthread-2.0 `dpkg-buildflags --get LDFLAGS` # -lrt as well? ifneq ($(filter deb,$(MAKECMDGOALS)),) CFLAGS:= $(CFLAGS) -g --- a/dicts.c +++ b/dicts.c @@ -23,7 +23,8 @@ */ -#include <pcre.h> +#define PCRE2_CODE_UNIT_WIDTH 8 +#include <pcre2.h> #include <glib.h> // required for string conversion functions #include <glib/gstdio.h> @@ -447,13 +448,13 @@ // Add a new dictionary word with UTF-8 citation form s0 // dictionary number dn, score f. Return 1 if added, 0 if not, -2 for out of memory -static int adddictword(char*s0,int dn,pcre*sre,pcre*are,float f) { +static int adddictword(char*s0,int dn,pcre2_code*sre,pcre2_code*are,float f) { int c,c0,i,l0,l1,l2; uchar t[MXLE+1],u; char s1[MXLE*16+1]; char s2[MXLE+1]; struct memblk*q; - int pcreov[120]; + pcre2_match_data * pcremd; l0=strlen(s0); utf8touchars(t,s0,MXLE+1); @@ -507,24 +508,28 @@ // s2 contains canonicalised form in internal character code, length l2 1<=l2<=MXLE dst_lines[dn]++; + pcremd = pcre2_match_data_create(120, NULL); if(sre) { - i=pcre_exec(sre,0,s0,l0,0,0,pcreov,120); + i=pcre2_match(sre,(PCRE2_SPTR)s0,l0,0,0,pcremd,NULL); DEB_DI if(i<-1) printf("PCRE error %d\n",i); if(i<0) { DEB_DV printf(" failed file filter\n"); + pcre2_match_data_free(pcremd); return 0; // failed match } } dst_lines_f[dn]++; if(are) { - i=pcre_exec(are,0,s1,l1,0,0,pcreov,120); + i=pcre2_match(are,(PCRE2_SPTR)s1,l1,0,0,pcremd,NULL); DEB_DI if(i<-1) printf("PCRE error %d\n",i); if(i<0) { DEB_DV printf(" failed answer filter\n"); + pcre2_match_data_free(pcremd); return 0; // failed match } } dst_lines_fa[dn]++; + pcre2_match_data_free(pcremd); if(memblkp==NULL||memblkl+2+l0+1+l2+1>MEMBLK) { // allocate more memory if needed (this always happens on first pass round loop) q=(struct memblk*)malloc(sizeof(struct memblk)); @@ -574,7 +579,7 @@ } // Attempt to load a .TSD file. Return number of words >=0 on success, <0 on error. -static int loadtsd(FILE*fp,int format,int dn,pcre*sre,pcre*are) { +static int loadtsd(FILE*fp,int format,int dn,pcre2_code*sre,pcre2_code*are) { int c,i,j,l,m,ml,n,u,nw; int hoff[MXLE+1]; // file offsets into Huffman coded block int dcount[MXLE+1]; // number of words of each length @@ -683,9 +688,10 @@ float f; int mode,owd,rc; - pcre*sre,*are; - const char*pcreerr; - int pcreerroff; + pcre2_code*sre,*are; + int pcreerr; + PCRE2_SIZE pcreerroff; + PCRE2_UCHAR pcreerrmsg[256]; char sfilter[SLEN+1]; char afilter[SLEN+1]; GError *error = NULL; @@ -709,18 +715,20 @@ strcpy(sfilter,dsfilters[dn]); if(!strcmp(sfilter,"")) sre=0; else { - sre=pcre_compile(sfilter,PCRE_CASELESS|PCRE_UTF8|PCRE_UCP,&pcreerr,&pcreerroff,0); - if(pcreerr) { - sprintf(t,"Dictionary %d\nBad file filter syntax: %.100s",dn+1,pcreerr); + sre=pcre2_compile((PCRE2_SPTR)sfilter,PCRE2_ZERO_TERMINATED,PCRE2_CASELESS|PCRE2_UTF|PCRE2_UCP,&pcreerr,&pcreerroff,0); + if(sre == NULL) { + pcre2_get_error_message(pcreerr, pcreerrmsg, sizeof pcreerrmsg); + sprintf(t,"Dictionary %d\nBad file filter syntax: %s",dn+1,pcreerrmsg); if(!sil) reperr(t); } } strcpy(afilter,dafilters[dn]); if(!strcmp(afilter,"")) are=0; else { - are=pcre_compile(afilter,PCRE_CASELESS|PCRE_UTF8|PCRE_UCP,&pcreerr,&pcreerroff,0); - if(pcreerr) { - sprintf(t,"Dictionary %d\nBad answer filter syntax: %.100s",dn+1,pcreerr); + are=pcre2_compile((PCRE2_SPTR)afilter,PCRE2_ZERO_TERMINATED,PCRE2_CASELESS|PCRE2_UTF|PCRE2_UCP,&pcreerr,&pcreerroff,0); + if(are == NULL) { + pcre2_get_error_message(pcreerr, pcreerrmsg, sizeof pcreerrmsg); + sprintf(t,"Dictionary %d\nBad answer filter syntax: %s",dn+1,pcreerrmsg); if(!sil) reperr(t); } } @@ -834,8 +842,8 @@ exit: if(sp) g_free(sp),sp=0; - if(sre) pcre_free(sre); - if(are) pcre_free(are); + if(sre) pcre2_code_free(sre); + if(are) pcre2_code_free(are); g_clear_error(&error); if(!owd) if(fp) fclose(fp); if(rc<0) return rc;
pgp3XvMEfSxkT.pgp
Description: OpenPGP digital signature