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

"out of range" error for some SRFIs #6

Open
siiky opened this issue Nov 27, 2020 · 5 comments
Open

"out of range" error for some SRFIs #6

siiky opened this issue Nov 27, 2020 · 5 comments
Assignees

Comments

@siiky
Copy link

siiky commented Nov 27, 2020

chicken-doc fails with an "out of range" error when asking for some SRFIs' docs. These are the offending SRFIs:

SRFI-105
SRFI-130
SRFI-135
SRFI-178
SRFI-189
SRFI-196

$ chicken-doc srfi-189
path: (srfi-189)

Error: (u8vector-ref) out of range
#u8(255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 254 255 255 255 255 255 31 0 0 0 0 0 0 0 0 0 63 0 0 0 0 0 0 248 255 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 192 255 255 63 0 0 0 0 2 0 0 0 255 255 255 7 0 0 0 0 0 0 0 0 0 0 192 255 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

It seems u8vectors are not used directly in chicken-doc, so the problem may be in a dependency, but I have no other clue about that...


While looking for other SRFIs I noticed that SRFI-111 also fails, but with a different error (probably unrelated):

$ chicken-doc srfi-111
path: (srfi-111)

Error: (caar) bad argument type: ()
@ursetto ursetto self-assigned this Nov 30, 2020
@ursetto
Copy link
Owner

ursetto commented Nov 30, 2020

I'll take a look. This can happen when importing via chicken-doc-admin, if the source is badly formed, but shouldn't happen on display.

@ursetto
Copy link
Owner

ursetto commented Apr 17, 2021

I suspect this to be an issue external to chicken-doc-text, caused by the fmt egg and interaction with Unicode characters like U+2618 (☞). Some chars work fine (srfi-45 é) but others do not. The text engine relies heavily on wrapping, so perhaps the character width table is at fault.

Specifically, for chars between #x0300 and #x3029, it uses the low-non-spacing-chars table to determine char width. The table (a u8vector) exactly matches the u8vector-ref error.

@siiky
Copy link
Author

siiky commented Apr 17, 2021

With your pointers I went digging a bit, and I don't understand much of what's going on, but I found that indeed low-non-spacing-chars doesn't have enough elements (958):

; fmt-unicode-chicken.scm:95
((<= #x0300 ci #x3029)
 (let* ((i (- ci #x0300))
        (byte (quotient i 8))
        (off (remainder i 8)))
   (if (zero? (bitwise-and (u8vector-ref low-non-spacing-chars byte)
                           (arithmetic-shift 1 off)))
       1
       0)))
#;1> (quotient (- #x3029 #x0300) 8)
1445
#;2> (- (quotient (- #x3029 #x0300) 8) 958)
487

@ursetto
Copy link
Owner

ursetto commented Apr 17, 2021

Yeah, the table is only valid for 0x300-0x20ef, really it needs to be capped at that point. I'm trying to regenerate the table now and fix a couple other bugs.

@ursetto
Copy link
Owner

ursetto commented Apr 18, 2021

I have fixed the issue in fmt-unicode but need to talk to upstream before applying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants