View Single Post
Old 10-18-2025, 10:44 AM   #65
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,410
Karma: 6733754
Join Date: Nov 2009
Device: many
For the record in case anyone else runs into this problem.

Here is the limit in pcre2 that was exceeded and needs to be updated:

The entire selected text - which in my case with your test file was 37051 utf-16 chars long is used to create a regex search expression that is fully escaped and had a length of 48588 utf-16 chars.

Unfortunately that search regex is then "compiled" by pcre2 and then used in the search.

The limit on the size of the compiled search regex is set in pcre2 source in its config file here:

Code:
/* The value of LINK_SIZE determines the number of bytes used to store links
   as offsets within the compiled regex. The default is 2, which allows for
   compiled patterns up to 65535 code units long. This covers the vast
   majority of cases. However, PCRE2 can also be compiled to use 3 or 4 bytes
   instead. This allows for longer patterns in extreme cases. */
#ifndef LINK_SIZE
#define LINK_SIZE 2
#endif
And that 48588 char long escaped selected text search expression when compiled exceeded that limit.

If I change this value to say 4, then recompile both pcre2 that is in Sigil's 3rd party and Sigil itself pasting a block of text of that size now succeeds.

This limit is set in our own 3rdparty/cmake/pcre2.cmake file so we can up it easily, but it is a build time change not a run time change as far as I can tell. The default value of 2 is set in the PCRE2 config.h.generic that is used by the buildtime "configure".

I have no idea if Qt's internal pcre2 has increased its limit, or what linux distributions do?

Last edited by KevinH; 10-18-2025 at 10:49 AM.
KevinH is offline   Reply With Quote