Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange TOC generation #562

Closed
desb42 opened this issue Aug 31, 2019 · 1 comment
Closed

Strange TOC generation #562

desb42 opened this issue Aug 31, 2019 · 1 comment

Comments

@desb42
Copy link
Collaborator

desb42 commented Aug 31, 2019

Using the shell script to build from commit 9bc0c2c, I tried to load the page en.wikipedia.org/wiki/Towson_University_buildings_and_structures (from wikitext) and get
toc_diff
I believe the red ellipse should have the save text as the blue ellipse

Not sure how that's happening

@gnosygnu
Copy link
Owner

gnosygnu commented Sep 3, 2019

So, this was a weird bug. It's probably been in there for years. The problem was that there was a byte array trim function which sometimes reused the same byte array.

More details are below. As always, thanks for the detailed report!


First, here is the simplest reproduction step

__TOC__
==0123456789012345==
==1234567890123456==

This would print 1234567890123456 twice.

Here is the problem:

  • The TOC calls a function called bfr.To_bry_and_clear_and_trim for each item which in turn calls Bry_.Trim
  • This function has logic that trims whitespace from the front and back of the byte array
    • However, if there is no whitespace, as an optimization, it returns back the same byte array
  • Due to how the bfr gets initialized, this bug only surfaces when strings are 16 length

The commit fixes the above by selectively skipping over the optimization. A few other files are changed because a new variable was added to the public

@gnosygnu gnosygnu moved this from Triage to Done in A <div> in D Sep 3, 2019
@gnosygnu gnosygnu closed this as completed Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
A <div> in D
  
Done
Development

No branches or pull requests

2 participants