Skip to content

expr updates - #753

Merged
jgarzik merged 11 commits into
mainfrom
updates
Nov 13, 2026
Merged

jgarzik merged 11 commits into
mainfrom
updates

Conversation

@jgarzik

@jgarzik jgarzik commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

No description provided.

jgarzik and others added 11 commits November 13, 2026 02:15
A comparison took the integer path only when both operands parsed into
an i128; a valid integer too large for it fell back to a string
comparison, so 2^127 > 2 was false and 0B = B was false for a 42-digit
B.  POSIX compares two integers as decimal integers, so operands that
satisfy the integer production are now compared by their value from
their digits, whatever their size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every pattern regcomp refused was reported as just "invalid regex", the
evaluator's errors being fixed strings.  They are now Strings, and the
error carries plib's text with regcomp's reason, as in "invalid regex
'\(': Unmatched ( or \(".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Syntax errors said only "unexpected operator", "unexpected trailing
argument" or "expected ')'".  They now name the argument, as in
"unexpected argument '3'" or "expected ')' but found '2'", and a group
left open at the end says "missing ')'".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
is_integer_text, the integer comparison and its sign handling each read
the production their own way, and the comparison copied both operands'
digits into new vectors.  integer_parts now gives the sign and digits of
an integer operand to both, and the comparison works on the slices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
expr's integers are i128, wider than the signed long XCU 1.1.2.1 names,
with "integer out of range" past that; comparisons work at any size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The expr entry said a result beyond the 128-bit range is reported as
"integer out of range"; that is the message for an operand, and a result
gives "integer overflow".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
integer_value checked the production and then parsed the text again
with Rust's i128 parser, a second idea of an integer, behind an
unreachable UTF-8 error.  It now accumulates the value from the sign and
digits integer_parts gives, with checked arithmetic, and
is_integer_text, left unused, is gone.  A test now pins the message for
a result that overflows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
token_text, which names an operator in a diagnostic, repeated
parse_token's table of operators in reverse, two lists to keep in step.
Both now use one table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Syntax errors quote the offending argument, which came out raw: an
escape sequence in it reached the terminal, and bytes that are not
UTF-8 became U+FFFD, misquoting it.  Control characters and such bytes
are now written as \xHH.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every control character is below U+0100, so the branch that escaped
one beyond it as \u{...} could never run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The escaping of an argument named in a diagnostic wrote a C1 control,
two bytes in UTF-8, as one \xHH, which reads as a different argument;
left a literal backslash alone, so a typed "\x1b" looked like an
escaped ESC; let bidi overrides and other format characters through to
reorder the terminal's line; and showed non-ASCII characters raw in any
locale, so in the C locale a byte such as 0x9B could still act as a
control.  Now a backslash is doubled, every byte of a control, format
character or invalid sequence is written as \xHH, and other non-ASCII
characters are written as themselves only in a UTF-8 locale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jgarzik jgarzik self-assigned this Nov 13, 2026
@jgarzik jgarzik changed the title Updates expr updates Nov 13, 2026
@jgarzik
jgarzik merged commit 8fec256 into main Nov 13, 2026
20 checks passed
@jgarzik
jgarzik deleted the updates branch November 13, 2026 08:48
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