Commit Graph

12 Commits

Author SHA1 Message Date
Allan Shortlidge 4728376a57 Revert "stdlib: Remove superfluous SwiftStdlib 6.3 availability checks"
This reverts commit 27d605c584.
2026-05-15 16:51:18 -07:00
Allan Shortlidge 27d605c584 stdlib: Remove superfluous SwiftStdlib 6.3 availability checks
Now that `SwiftStdlib 6.3` maps to real versions for Apple's operating systems
(https://github.com/swiftlang/swift/pull/87510), checks like

```
if #available(StdlibDeploymentTarget 6.3, *) { ... }
```

inside the implementation of the stdlib are no longer necessary to satisfy the
availability checker and instead cause warnings to be emitted.  Remove the now
superfluous checks.

This is a reattempt of https://github.com/swiftlang/swift/pull/87744. The
previous attempt was reverted because it turned out that there were some
configurations (outside of Swift CI) in which the stdlib was built with an
unnecessarily low deployment target. That has now been corrected, unblocking
this fix.
2026-05-12 08:34:31 -07:00
Doug Gregor 453277eb74 Mark the various with* functions as @safe
Functions like withUnsafeBufferPointer are, by themselves, safe to
call. It's only the operations on the unsafe pointers passed into the
closure that are the safety issue.

This was the intent spelled out in SE-0458 but was not fully realized
in the library.

Fixes rdar://174519372.
2026-04-16 22:37:54 -07:00
Andrew Trick a684d6b74c Revert "stdlib: Remove superfluous SwiftStdlib 6.3 availability checks" 2026-03-06 13:03:35 -08:00
Allan Shortlidge 82875ff67b stdlib: Remove superfluous availability checks. 2026-03-04 14:32:57 -08:00
Karoy Lorentey aacf5d4a6f [stdlib] Restore word breaking logic 2025-12-17 10:52:57 -08:00
Alejandro Alonso bc160533a0 Update stdlib Unicode data and processing for Unicode 17 2025-12-15 12:21:07 -08:00
Karoy Lorentey 3e18a07187 [stdlib] Fix implementation of Unicode text segmentation for word boundaries
Carefully overhaul our word breaking implementation to follow the recommendations of Unicode Annex #29. Start exposing the core primitives (as well as `String`-level interfaces), so that folks can prototype proper API for these concepts.

- Fix `_wordIndex(after:)` to always advance forward. It now requires its input index to be on a word boundary. Remove the `@_spi` attribute, exposing it as a (hidden, but) public entry point.
- The old SPIs `_wordIndex(before:)` and `_nearestWordIndex(atOrBelow:)` were irredemably broken; follow the Unicode recommendation for implementing random-access text segmentation and replace them both with a new public `_wordIndex(somewhereAtOrBefore:)` entry pont.
- Expose handcrafted low-level state machines for detecting word boundaries (_WordRecognizer`, `_RandomAccessWordRecognizer`), following the design of `_CharacterRecognizer`.
- Add tests to reliably validate that the two state machine flavors always produce consistent results.

rdar://155482680
2025-08-05 20:04:46 -07:00
Doug Gregor 22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
David Smith f1feba0e42 Eytzingerize word break data (#71731)
Switch word break property searching to Eytzinger binary search
2024-02-20 22:49:34 -08:00
Alejandro Alonso 3deacf8944 Fix backwards iteration of word breaking 2023-11-08 13:26:20 -08:00
Alejandro Alonso 95da55b182 [stdlib] Implement String.WordView (#42414)
* Implement String.WordView

* Add isWordAligned bit

* Hide WordView for now (also separate Index type)

add bidirectional conformance

Fix tests

* Address comments from Karoy and Michael

* Remove word view, use index methods

* Address Karoy's comments

aaa
2022-06-22 09:10:09 -07:00