Skip to content

cast char to unsigned before isupper/islower in xpath and pattern lexers - #4964

Open
abdul7056 wants to merge 1 commit into
antlr:devfrom
abdul7056:xpath-pattern-ctype-cast
Open

cast char to unsigned before isupper/islower in xpath and pattern lexers#4964
abdul7056 wants to merge 1 commit into
antlr:devfrom
abdul7056:xpath-pattern-ctype-cast

Conversation

@abdul7056

Copy link
Copy Markdown

Two lexing helpers in the C++ runtime hand a raw char to isupper()/islower():

  • ParseTreePatternMatcher::tokenize branches on isupper/islower of tagChunk.getTag()[0]
  • the XPath ID lexer action does the same on getText()[0] (source in XPathLexer.g4, kept in sync)
  • a tag or xpath identifier whose first byte is non-ASCII (a UTF-8 lead byte such as 0xC3) makes that char negative, which is undefined for the ctype functions since the argument must be representable as unsigned char or EOF

Cast each byte to unsigned char before the call, matching the Java runtime's Character.isUpperCase/isLowerCase path.

Signed-off-by: obsidian_nomad <abdul@sproutxp.com>
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.

1 participant