Page 1 of 1

Strange bug in the Replace filter

Posted: Thu Dec 13, 2018 5:50 am
by dfhtextpipe
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

Re: Strange bug in the Replace filter

Posted: Mon Dec 24, 2018 7:01 am
by DataMystic Support
Hi David - I have tried this here with no issues (10.7.2). Can you please email me the filter and test file?

Re: Strange bug in the Replace filter

Posted: Thu Dec 27, 2018 4:05 am
by dfhtextpipe
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

Re: Strange bug in the Replace filter

Posted: Tue Mar 03, 2020 12:24 am
by dfhtextpipe
This bug seems to no longer occur in TextPipe 11.4

NB. I only tried it using the Trial Run area.

David

Re: Strange bug in the Replace filter

Posted: Wed Mar 04, 2020 4:32 pm
by DataMystic Support
Thanks David!