Skip to content

Scan bytes as unsigned char in the implicit type matcher - #62

Merged
hsbt merged 1 commit into
masterfrom
implicit-utf8-bool
Jul 28, 2026
Merged

Scan bytes as unsigned char in the implicit type matcher#62
hsbt merged 1 commit into
masterfrom
implicit-utf8-bool

Conversation

@hsbt

@hsbt hsbt commented Jul 28, 2026

Copy link
Copy Markdown
Member

Syck.load("Noémie") returns false and Syck.load("Yeså") returns true. The re2c scanner in implicit.c reads bytes as signed char, so any byte >= 0x80 compares as negative and satisfies the end-of-token check (yych <= 0x00). A UTF-8 continuation byte then terminates the token early, and Noémie matches the No boolean rule. Changing YYCTYPE to unsigned char makes only a real NUL end a token. All relational comparisons in implicit.c are these end-of-token checks, so the other implicit types are unaffected. implicit.re is not shipped in this repository, but YYCTYPE belongs to its hand-written prologue, so the generated state machine is untouched.

Fixes #22

The re2c scanner in implicit.c read bytes as signed char, so any byte
>= 0x80 satisfied the end-of-token check (yych <= 0x00) and a UTF-8
string like "Noémie" matched the "No" boolean rule.

#22

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hsbt
hsbt merged commit 140bab0 into master Jul 28, 2026
48 checks passed
@hsbt
hsbt deleted the implicit-utf8-bool branch July 28, 2026 06:42
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

Successfully merging this pull request may close these issues.

Syck does not like Noémie. aka: Issues with UTF8 strings interpreted as Boolean values

1 participant