51 Commits

Author SHA1 Message Date
GasInfinity 3d8b0e3324 feat(std.ascii): add boundedOrderIgnoreCaseZ 2026-01-17 21:42:38 +01:00
GasInfinity e558e64ca0 feat(std.ascii): add isGraphical and isPunctuation 2026-01-09 02:27:31 +01:00
Adrià Arrufat 1a420a8dca std.ascii: rename indexOf functions to find
This aligns with the recent changes in std.mem.find
2025-12-05 14:31:27 +01:00
Jay Petacat 5a38dd28dc std: Skip element comparisons if mem.order args point to same memory
This optimization is used in `mem.eql`, but was missing from `order`,
`orderZ`, and `ascii.orderIgnoreCase`.
2025-10-31 18:34:33 -07:00
Andrew Kelley 150169f1e0 std.fmt: delete deprecated APIs
std.fmt.Formatter -> std.fmt.Alt
std.fmt.format -> std.Io.Writer.print
2025-08-31 12:49:18 -07:00
Andrew Kelley 79f267f6b9 std.Io: delete GenericReader
and delete deprecated alias std.io
2025-08-29 17:14:26 -07:00
Linus Groh eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Andrew Kelley 87f32bec26 std.io.Reader: finish implementing the unit tests 2025-07-07 22:43:52 -07:00
Andrew Kelley 0e37ff0d59 std.fmt: breaking API changes
added adapter to AnyWriter and GenericWriter to help bridge the gap
between old and new API

make std.testing.expectFmt work at compile-time

std.fmt no longer has a dependency on std.unicode. Formatted printing
was never properly unicode-aware. Now it no longer pretends to be.

Breakage/deprecations:
* std.fs.File.reader -> std.fs.File.deprecatedReader
* std.fs.File.writer -> std.fs.File.deprecatedWriter
* std.io.GenericReader -> std.io.Reader
* std.io.GenericWriter -> std.io.Writer
* std.io.AnyReader -> std.io.Reader
* std.io.AnyWriter -> std.io.Writer
* std.fmt.format -> std.fmt.deprecatedFormat
* std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape
* std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape
* std.fmt.fmtSliceHexLower -> {x}
* std.fmt.fmtSliceHexUpper -> {X}
* std.fmt.fmtIntSizeDec -> {B}
* std.fmt.fmtIntSizeBin -> {Bi}
* std.fmt.fmtDuration -> {D}
* std.fmt.fmtDurationSigned -> {D}
* {} -> {f} when there is a format method
* format method signature
  - anytype -> *std.io.Writer
  - inferred error set -> error{WriteFailed}
  - options -> (deleted)
* std.fmt.Formatted
  - now takes context type explicitly
  - no fmt string
2025-07-07 22:43:51 -07:00
Shun Sakai 227d2b15e4 docs(std.ascii): Remove redundant three slashes 2025-04-27 19:37:43 +02:00
Rohan Vashisht 88d57917b7 Updated ascii.zig's isWhitespace function to use switch instead of for loop. (#22094) 2024-11-29 12:26:23 -08:00
CrazyboyQCD 8ddce90e62 std.ascii: make toLower toUpper branchless (#21369)
Co-authored-by: WX\shixi <shixi1@cnwxsoft.com>
2024-09-13 17:22:19 -07:00
Michael Bradshaw 02b3d5b58a Rename isASCII to isAscii 2024-07-02 16:31:15 +02:00
Andrew Kelley 12191c8a22 std: promote tests to doctests
Now these show up as "example usage" in generated documentation.
2024-03-21 14:11:46 -07:00
r00ster91 2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Andrew Kelley aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
r00ster91 45650f7003 std.ascii: more tests 2022-12-09 21:57:17 +01:00
r00ster91 0162a0868c isHex, isAlphanumeric: prong reorder
On x86 interestingly I can see a reduction in codesize by 1 instruction with this.
While not necessarily faster, it might still reduce codesize a bit and this ordering is also more logical
because it follows ASCII table order. Rust's std uses this ordering too.
See https://zig.godbolt.org/z/PqodY8YqY for the difference.
2022-12-09 21:57:17 +01:00
r00ster91 19dbc5805c fix(perf): remove LUT
This makes it so that we no longer use a LUT (Look-Up Table):
* The code is much simpler and easier to understand now.
* Using a LUT means we rely on a warm cache.
  Relying on the cache like this results in inconsistent performance and in many cases codegen will be worse.
  Also as @topolarity once pointed out, in some cases while it seems like the code may branch, it actually doesn't:
  https://github.com/ziglang/zig/pull/11629#issuecomment-1213641429
* Other languages' standard libraries don't do this either.
  JFF I wanted to see what other languages codegen compared to us now:
  https://rust.godbolt.org/z/Te4ax9Edf, https://zig.godbolt.org/z/nTbYedWKv
  So we are pretty much on par or better than other languages now.
2022-12-09 21:57:17 +01:00
r00ster91 626e02a429 docs: minor improvements 2022-12-09 21:57:17 +01:00
r00ster91 6b7d9b34e8 api(std.ascii): remove deprecated decls 2022-12-09 21:57:17 +01:00
fn ⌃ ⌥ a70c86e661 Fix deprecation docs for isAlpha and isCntrl 2022-10-29 15:22:05 -04:00
Zhora Trush c66d3f6bf6 Enhance indexOfIgnoreCase with Boyer-Moore-Horspool algorithm 2022-10-28 20:29:41 -04:00
r00ster91 4ea3a9ba9f fix: comments 2022-08-17 20:08:13 +02:00
r00ster91 37880f2385 api: deprecate lowercase control_code consts 2022-08-17 20:07:58 +02:00
r00ster91 298062897d docs: fixes and improvements 2022-08-16 21:37:02 +02:00
r00ster91 ee97fbc199 api: deprecate isPunct too
See https://github.com/ziglang/zig/issues/8419#issuecomment-843719898
2022-08-14 22:04:13 +02:00
r00ster91 846dbf2745 docs: remove some hyphens 2022-08-14 21:49:21 +02:00
r00ster91 8890190857 fix: add missing 'o' 2022-08-14 21:46:26 +02:00
r00ster91 028134055c fix: remove outdated TODO
It was supposed to be removed: https://github.com/ziglang/zig/commit/490654c332f2d8eaf7edffa35ea0523800df998d#r47643278
2022-08-14 21:43:40 +02:00
r00ster91 9b79c6ae52 test: update and add more tests 2022-08-14 21:42:24 +02:00
r00ster91 d130d09e2b docs: add more docs
And improve some existing docs.
2022-08-14 21:39:53 +02:00
r00ster91 02893d80cf api: rename and deprecate a bunch of functions
`isAlNum` and `isAlpha`:
1. I think these names are a bit cryptic.
2. `isAlpha` is a bit ambiguous: is it alpha*numeric* or alpha*betic*?
   This is why I renamed `isAlpha` to `isAlphabetic`.
3. For consistency and because `isAlNum` looks weird, I renamed it to `isAlphanumeric`.

`isCntrl`:
1. It's cryptic and hard to find when you look for it.
2. We don't save a lot of space writing it this way.
3. It's closer to the name of the `control_code` struct.

`isSpace`:
1. The name is ambiguous and misleading.

`spaces`:
1. Ditto

`isXDigit`:
1. The name is extremely cryptic.
2. The function is very hard to find by its name.
2022-08-14 21:34:59 +02:00
r00ster91 d178df773a api: deprecate isBlank and isGraph.
I think `isBlank` and `isWhitespace` are quite confusable.
What `isBlank` does is so simple that you can just do the `c == ' ' or c == '\t'`
check yourself but in a lot of cases you don't even want that.
`std.ascii` can't really know what you think "blank" means.
That's why I think it's better to remove it.
And again, it seems ambiguous considering that we have `isWhitespace`.

Next, it also deprecates `isGraph`.
It's the same as `isPrint(c) and c != ' '`, which I find confusing.
When something is printable, you can say it also has a *graph*ical representation.
Removing `isGraph` solves this possible confusion.
2022-08-14 21:13:46 +02:00
r00ster91 93ca0c4a5e fix: off-by-one in isCntrl
0x1F (`control_code.us`) itself is also a control code.
2022-08-14 21:05:37 +02:00
r00ster91 aa0b93e875 feat: new control_code
It lowercases all constants and documents them.
2022-08-14 21:03:57 +02:00
Lee Cannon 85de022c56 allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Andrew Kelley d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
xackus 143688e266 add allocation free versions of lower/upper string
Co-authored-by: LemonBoy <thatlemon@gmail.com>
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2021-06-08 14:27:44 -04:00
Veikka Tuominen fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley 490654c332 std.ascii: add lessThanIgnoreCase and orderIgnoreCase
For sorting ascii strings, case insensitively.
2021-02-27 01:21:01 -07:00
Frank Denis 6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
LemonBoy fd8fa55129 std: Add a few helpers for matching ascii strings (#7300)
* startsWithIgnoreCase
* endsWithIgnoreCase
2020-12-04 15:27:28 -05:00
Isaac Freund 50ba018223 std/ascii: add spaces array
This may be combined with std.mem.trim to form a proper replacement for
the now deprecated std.fmt.trimWhitespace().
2020-11-02 13:20:58 -05:00
Andrew Kelley 4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Felix (xq) Queißner 7dc29fdee1 Creates std.ascii.control_code that contains the C0 control codes as named constants. 2020-05-16 12:46:44 -04:00
Greg Anders c6420820b0 Remove redundant ASCII functions
The `matchCase` variants are simply duplicates of the `eql` and
`indexOf` functions found in std.mem.
2020-05-12 08:38:15 -06:00
Greg Anders 9f496c0777 Add helper functions and docstrings to ascii.zig
* Add an upper case variant of `allocLowerString`
  * Add case-sensitive variants of `eqlIgnoreCase`, `indexOfIgnoreCase`,
    and `indexOfIgnoreCasePos`
  * Add and update docstrings on functions
2020-05-11 19:36:41 -06:00
Benjamin Feng 699c50a375 Switch a bunch of FBA to use testing.allocator 2020-02-12 17:17:56 -06:00
Andrew Kelley e0db54e89d update the codebase to use @as 2019-11-08 15:57:24 -05:00