Bug#999977: qxw: depends on obsolete pcre3 library

2023-09-04 Thread Nick Morrott
On Mon, 4 Sept 2023 at 07:32, Stephen Kitt  wrote:
>
> 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.

Dear Stephen and Bastian,

Thank you both for the pcre2 patch and the upload of qxw.

I got back from vacation yesterday and receiving the commit and upload
notifications this morning was a very unexpected gift!

Many thanks,
Nick



Bug#999977: qxw: depends on obsolete pcre3 library

2023-09-04 Thread Stephen Kitt
Hi,

On Mon, 31 Jul 2023 04:44:14 +0100, Nick Morrott 
wrote:

> On 2023/07/22 at 08:43, Stephen Kitt wrote:
> >aOn Sat, 22 Jul 2023 16:14:06 +0200, Bastian Germann 
> >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 
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 
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include 
 #include// required for string conversion functions
 #include 
 
@@ -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,,,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,,,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,"")) 

Bug#999977: qxw: depends on obsolete pcre3 library

2023-07-30 Thread Nick Morrott
On 2023/07/22 at 08:43, Stephen Kitt wrote:
>aOn Sat, 22 Jul 2023 16:14:06 +0200, Bastian Germann  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.
> 
> Regards,
> 
> Stephen

Bastian/Stephen,

In my last contact with upstream I discussed the use of the obsolete pcre3
library. The development team told me that a new GTK3/Qt GUI is under
development which will resolve the pcre3 issue in addition to the
proposed UI improvements.

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.

I'd like to keep qxw in the archive, given the time spent getting it
reintroduced in time for bookworm following the RFP.

Thanks,
Nick



Bug#999977: qxw: depends on obsolete pcre3 library

2023-07-22 Thread Stephen Kitt
On Sat, 22 Jul 2023 16:14:06 +0200, Bastian Germann  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.

Regards,

Stephen


pgpj3AFhwSrrc.pgp
Description: OpenPGP digital signature


Bug#999977: qxw: depends on obsolete pcre3 library

2023-07-22 Thread Bastian Germann
I suggest to remove the package. I do not think upstream will deal with 
this.