Commit Graph

257 Commits

Author SHA1 Message Date
Andrew Kelley faab6d5cbf fix hello world 2025-07-01 16:35:26 -07:00
Jacob Young 1501734747 io: fix compile errors 2025-07-01 16:35:26 -07:00
Jacob Young d76c8d0bd2 Dwarf: cleanup and port to new std.io.BufferedReader API 2025-07-01 16:35:26 -07:00
Andrew Kelley 9dc0b4a98f back to the anyerror!usize vtable 2025-07-01 16:35:26 -07:00
Andrew Kelley 6ac7931bec std: hacking around with buffered reader / writer semantics
I think I'm going to back out these vtable changes in the next commit
2025-07-01 16:35:26 -07:00
Andrew Kelley 890a02c345 std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface
2025-07-01 16:35:26 -07:00
Andrew Kelley 6c48aad991 update some more std lib API to new Reader/Writer
std.compress needs an audit, I see some problems
2025-07-01 16:35:26 -07:00
Andrew Kelley 57e1fc29d2 reader interface vecs and bufferedwriter arraylist 2025-07-01 16:35:26 -07:00
Andrew Kelley 5aa8573f2b redo reader 2025-07-01 16:35:26 -07:00
Andrew Kelley 2fb6ce2f92 update some more compiler code 2025-07-01 16:35:26 -07:00
Andrew Kelley d87b59f5a5 std.fmt.format: support base 64 encoding 2025-07-01 16:35:26 -07:00
Andrew Kelley bf00eb3006 more of the compiler updated to new Writer API 2025-07-01 16:35:26 -07:00
Andrew Kelley 09af68de80 fix duration formatting 2025-07-01 16:35:26 -07:00
Andrew Kelley 051c7af49a get std lib json tests passing 2025-07-01 16:35:26 -07:00
Andrew Kelley 7569494b45 fix byte formatted printing 2025-07-01 16:35:26 -07:00
Andrew Kelley bb1dffcf32 much of the compiler upgraded to new API 2025-07-01 16:35:26 -07:00
Andrew Kelley f3be721785 build runner compiling 2025-07-01 16:35:26 -07:00
Andrew Kelley 716b4489be update more of the std lib to new API 2025-07-01 16:35:26 -07:00
Andrew Kelley e60adb97d0 AllocatingWriter passing unit test 2025-07-01 16:35:26 -07:00
Andrew Kelley fced9467e8 std ArrayList unit tests passing 2025-07-01 16:35:26 -07:00
Andrew Kelley 221b194f28 std.io.BufferedWriter: implement hex string printing 2025-07-01 16:35:26 -07:00
Andrew Kelley ff3581ca2d update some of the build system to new API 2025-07-01 16:35:25 -07:00
Andrew Kelley 1d0495678d fixes
writeFile should be split into two
2025-07-01 16:35:25 -07:00
Andrew Kelley 35824e4822 writeSplat 2025-07-01 16:35:25 -07:00
Andrew Kelley b26aceba7d thinking about splat being the only function 2025-07-01 16:35:25 -07:00
Andrew Kelley 5356f3a307 migrate some std lib 2025-07-01 16:35:25 -07:00
Andrew Kelley c2fc6b0b6c ArrayListWriter 2025-07-01 16:35:25 -07:00
Andrew Kelley 00c6c836a6 std: start reworking std.io
hello world is compiling
2025-07-01 16:35:25 -07:00
Andrew Kelley f32a5d349d std: eradicate u29 and embrace std.mem.Alignment 2025-04-13 02:20:32 -04:00
Pat Tullmann 14c046fc07 lib/std: PermissionDenied/AccessDenied cleanup and fallout
This PR consistently maps .ACCES into AccessDenied and .PERM into
PermissionDenied.  AccessDenied is returned if the file mode bit
(user/group/other rwx bits) disallow access (errno was `EACCES`).
PermissionDenied is returned if something else denies access (errno was
`EPERM`) (immutable bit, SELinux, capabilities, etc).  This somewhat
subtle distinction is a POSIX thing.

Most of the change is updating std.posix Error Sets to contain both
errors, and then propagating the pair up through caller Error Sets.

Fixes #16782
2025-03-24 16:20:45 +01:00
Pat Tullmann eace31c6b3 std/lib: {fs,io,posix} test clean up
* use `tmp.dir.realpathAlloc()` to get full path into tmpDir instances
* use `testing.allocator` where that simplifies things (vs. manual ArenaAllocator for 1 or 2 allocs)
* Trust `TmpDir.cleanup()` to clean up contained files and sub-trees
* Remove some unnecessary absolute paths (enabling WASI to run the tests)
* Drop some no-longer necessary `[_][]const u8` casts
* Add scopes to reduce `var` usage in favor of `const`
2025-03-09 07:41:06 +01:00
John Benediktsson 1c07eacc7f std.process: adding hasNonEmptyEnvVar() and using for NO_COLOR 2025-02-06 15:00:48 +01:00
mlugg d00e05f186 all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
tgschultz ba569bb8e9 Rewrite bit_reader and bit_writer to take advantage of current zig semantics and enhance readability (#21689)
Co-authored-by: Tanner Schultz <tgschultz@tgschultz-dl.tail7ba92.ts.net>
2024-10-13 18:44:42 -07:00
Alex Rønne Petersen 2db3c77060 std.io.Reader: Fix test erroneously using undefined. 2024-09-26 17:04:36 +02:00
Lucas Santos b19d0fb0fd Improve efficiency of buffered_reader. (#21256)
The previous implementation of buffered_reader always reads from the
unbuffered reader into the internal buffer, and then dumps the data onto
the destination. This is inefficient, as sometimes it's possible to read
directly into the destination. The previous strategy generates more
memory copies and unbuffered reads than necessary.
2024-09-23 17:20:27 -07:00
mlugg 0fe3fd01dd std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Andrew Kelley 5058beb179 implement std.testing.fuzzInput
for the -fno-fuzz case. The other case will take more work in libfuzzer.
2024-07-25 18:52:20 -07:00
Ryan Liptak 337f09e932 Add File.getOrEnableAnsiEscapeSupport and use it
On Windows, the console mode flag `ENABLE_VIRTUAL_TERMINAL_PROCESSING` determines whether or not ANSI escape codes are parsed/acted on. On the newer Windows Terminal, this flag is set by default, but on the older Windows Console, it is not set by default, but *can* be enabled (since Windows 10 RS1 from June 2016).

The new `File.getOrEnableAnsiEscapeSupport` function will get the current status of ANSI escape code support, but will also attempt to enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on Windows if necessary which will provide better/more consistent results for things like `std.Progress` and `std.io.tty`.

This type of change was not done previously due to a mistaken assumption (on my part) that the console mode would persist after the run of a program. However, it turns out that the console mode is always reset to the default for each program run in a console session.
2024-06-02 16:46:21 -07:00
Carl Åstholm d74180c373 Replace YES_COLOR with CLICOLOR_FORCE
Instead of introducing YES_COLOR, a completely new standard, into the mix
it might make more sense to instead tag along with the CLICOLOR_FORCE env var,
which dates back to at least 2000 with FreeBSD 4.1.1 and which is
supported by tools like CMake.

<https://bixense.com/clicolors/>
2024-06-02 17:35:34 -04:00
Jacob Young d77f5e7aaa Progress: fix compile errors on windows
Works for `zig build-exe`, IPC still not implemented yet.
2024-05-27 20:56:48 -07:00
Veikka Tuominen c4e3a49898 define an error set for std.io.tty.Config.setColor 2024-05-10 10:29:16 +03:00
Jonathan Marler a96b78c170 add std.zip and support zip files in build.zig.zon
fixes #17408

Helpful reviewers/testers include Joshe Wolfe, Auguste Rame, Andrew
Kelley and Jacob Young.

Co-authored-by: Joel Gustafson <joelg@mit.edu>
2024-05-03 16:58:53 -04:00
Igor Anić e831313b10 std.io: remove BufferedTee
Introduced in  #19032 as a fix for #18967.
Not needed any more after #19253.
2024-03-20 21:05:35 -07:00
Andrew Kelley cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Andrew Kelley bc5b094695 remove std.io.PeekStream
See #16114. This functionality should be added to bufferedReader
instead.
2024-03-14 07:48:47 -07:00
Tristan Ross 099f3c4039 std.builtin: make container layout fields lowercase 2024-03-11 07:09:07 -07:00
Andrew Kelley b7ba0b69b1 std.io.Writer: add writeFile method 2024-03-10 17:51:06 -07:00
Ryan Liptak 16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
Follow up to #19079, which made test names fully qualified.

This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:

"priority_queue.test.std.PriorityQueue: shrinkAndFree"

and the same test's name after the changes in this commit:

"priority_queue.test.shrinkAndFree"
2024-02-26 15:18:31 -08:00
Andrew Kelley d943ce5dc7 std.io.Reader: add discard function
Reads the stream until the end, ignoring all the data.
Returns the number of bytes discarded.
2024-02-23 02:37:11 -07:00