Strange bug in the Replace filter

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

Post Reply
DFH
Posts: 871
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Strange bug in the Replace filter

Post by DFH » Thu Dec 13, 2018 5:50 am

My input USFM file has 66 books, with each book starting like this:

Code: Select all

\id GEN
\mt Genesisy
NB. The file has Unix style EOLs.

My filter to add a Running Header and Table of Contents markers is as follows:

Code: Select all

Perl pattern [^(\\mt )(.+)$] with [\\h $2\n\\toc1 $2\n\\toc2 $2\n\\toc3 $2\n$1$$2]
   [X] Match case
   [ ] Whole words only
   [ ] Case sensitive replace
   [ ] Prompt on replace
   [ ] Skip prompt if identical
   [ ] First only
   [ ] Extract matches
       Maximum text buffer size 4096
   [X] Maximum match (greedy)
   [ ] Allow comments
   [ ] '.' matches newline
   [X] UTF-8 Support
 
The output file becomes:

Code: Select all

\id GEN
\h Genesisy
\toc1 Genesisy
\toc Genesisy
\toc3 Genesisy
\mt Genesisy
Observe that the number 2 is missing from where it should be in \toc2

If I edit the filter to include an extra 2 - then the output becomes correct.

Code: Select all

Perl pattern [^(\\mt )(.+)$] with [\\h $2\n\\toc1 $2\n\\toc22 $2\n\\toc3 $2\n$1$$2]
   [X] Match case
   [ ] Whole words only
   [ ] Case sensitive replace
   [ ] Prompt on replace
   [ ] Skip prompt if identical
   [ ] First only
   [ ] Extract matches
       Maximum text buffer size 4096
   [X] Maximum match (greedy)
   [ ] Allow comments
   [ ] '.' matches newline
   [X] UTF-8 Support
 
The output is then:

Code: Select all

\id GEN
\h Genesisy
\toc1 Genesisy
\toc2 Genesisy
\toc3 Genesisy
\mt Genesisy
I can think of no logical explanation why the extra character 2 has to be used to prevent the omission.

Is there a subtle software bug in TextPipe 10.7.2 ?

Further evidence: If I replace the single 2 by any other character, the filter works as I should expect.

Best regards,

David

User avatar
DataMystic Support
Site Admin
Posts: 2328
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Strange bug in the Replace filter

Post by DataMystic Support » Mon Dec 24, 2018 7:01 am

Hi David - I have tried this here with no issues (10.7.2). Can you please email me the filter and test file?
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

DFH
Posts: 871
Joined: Sun Dec 09, 2007 2:49 am
Location: UK

Re: Strange bug in the Replace filter

Post by DFH » Thu Dec 27, 2018 4:05 am

Hi Simon,

It will take me a while to prepare an email with the attachments.

cf. I'll need to extract the dodgy sub-filter from a much more complex filter that I'm developing.

David

Post Reply