Skip to content

fix7/locale2: locale defaults, UTF-8 POSIX classes, strict ERE intervals (#1621, #1622, #1658) - #1752

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix7/slice-locale2
Oct 26, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix7/slice-locale2

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Integration slice for the fix7/locale2 family: three locale/conditional fixes, cherry-picked onto current master with zero conflicts.

Each fix carries its own issue-numbered regression file (tests/issue1621_*, tests/issue1622_*, tests/issue1658_*), expectations written against the GNU bash 5.3.20 oracle.

Verification (integrated tree): full build + 3 new regression files + lib suite (failure set identical to this tree's baseline: only ownership_unary_operators_check_existing_file) + 13 red-line/sibling pins incl. #1533 C-locale byte pins and #1531 locale watchers, all green; p1621_all_diff.sh oracle-vs-rubash diff shows only the expected re[] ascii/word divergence tracked separately in #1717; diffcorpus 306 failure set ⊆ {ms10}.

Fixes #1621
Fixes #1622
Fixes #1658

GNU bash resolves the locale at startup with setlocale(LC_ALL, "")
(locale.c set_default_locale, called from shell.c), so with no locale
variable set - or all of them empty - the C locale is in effect and
character semantics are byte semantics. rubash's is_utf8() kept a
default UTF-8 model for the empty-name case, a leftover of the locale
port that #1464's explicit-locale fixes never reached: ${#é} counted
1 char instead of 2 bytes and printf %q / ${v@Q} emitted raw UTF-8
instead of $'\303\251'.

Flip the empty-name branch of locale::is_utf8() to false; every
consumer (length view, quoting escapes, case mapping, =~ granularity)
already decides through that one point. With the default corrected,
the =~ byte-mode predicate drops its one-surface compensation clause
(|| locale_name().is_empty(), from #1061) and is the plain negation.

Regression: tests/issue1622_no_locale_default_regressions.rs
(env-clear unset case, LANG= case, C.UTF-8 control).
Expectations verified against GNU bash 5.3.20.
…s (rubash#1621)

Under LC_ALL=C.UTF-8, GNU resolves POSIX character classes through
wctype/iswctype (lib/glob/smatch.c for the pattern matcher, regcomp's
tables for =~), so É matches [[:upper:]] and é matches
[[:lower:]]/[[:alpha:]] on all four surfaces ([[ ]], case, pattern
removal, =~). rubash classified with an ASCII-only table everywhere,
so multibyte characters never matched any class.

The class tables now live in src/locale.rs as the single decision
point next to is_utf8(): utf8_posix_class_matches() implements the
glibc C.UTF-8 tables as measured against the GNU oracle (digit/xdigit
stay ASCII-only; alpha adds non-ASCII Nd digits; NBSP and U+202F are
not space; U+3000 is space/blank but not graph; U+2028/U+2029 are
space and cntrl; Cf chars are print/graph/punct). NON_ASCII_ND_RANGES
(63 ranges) backs both the predicate form and the regex-text form.

- pattern.rs posix_class_matches(): byte-carrier mapping unchanged;
  under is_utf8() it delegates to the new table. The single-byte
  ASCII table is byte-for-byte untouched (#1533 pins).
- =~ (conditional.rs): translate_posix_bracket_classes() takes a
  unicode_classes flag (text mode only); [:class:] spans expand to
  Unicode constructs (\\p{Uppercase}, \\p{Alphabetic}+Nd ranges,
  De Morgan negated classes for print/graph/punct, ledger char sets
  for space/blank). Byte mode passes classes through unchanged.

Regression: tests/issue1621_posix_class_utf8_regressions.rs (four
surfaces + measured edge rules under C.UTF-8, LC_ALL=C control).
Expectations verified against GNU bash 5.3.20.
[[ a =~ a{,2} ]] silently matched as if the interval were {0,2}:
translate_posix_ere_quantifiers rewrote {,m}/{,} to {0,...} and the
repetition-error scan documented {,5} as a valid interval. POSIX ERE
requires the leading number, and the GNU oracle this was filed
against rejects the pattern at runtime with status 2 and
'invalid repetition count(s)'. (glibc regcomp accepts {,n} as an
extension - the strict reading is the filed expectation; this commit
is self-contained and reverts cleanly if the glibc reading is ever
preferred.)

- Compile gate: posix_ere_has_empty_min_interval() (skips escapes
  and bracket expressions, mirrors the bad-interval scan) makes the
  pattern fail compilation, i.e. status 2.
- regexp_repetition_error(): an empty minimum after an atom reports
  'invalid repetition count(s)'; with no preceding atom it stays
  'Invalid preceding regular expression'.
- The {0,...} rewrite in translate_posix_ere_quantifiers is gone,
  and the stale doc comments are corrected.

Regression: tests/issue1658_ere_empty_min_interval_regressions.rs
(rc=2 + diagnostic wording; {0,2}/{2,}/escaped-literal controls).
@caomengxuan666 caomengxuan666 changed the title WIP: fix7/slice-locale2 fix7/locale2: locale defaults, UTF-8 POSIX classes, strict ERE intervals (#1621, #1622, #1658) Oct 26, 2026
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 26, 2026 07:48
@caomengxuan666
caomengxuan666 merged commit de54270 into master Oct 26, 2026
7 of 10 checks passed
@caomengxuan666
caomengxuan666 deleted the fix7/slice-locale2 branch October 30, 2026 01: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

1 participant