8310 Commits

Author SHA1 Message Date
Andrew Kelley
2d9c4792ae std.fmt: clarify the use of "character"
Currently, std.fmt has a misguided, half-assed Unicode implementation
with an ambiguous definition of the word "character". This commit does
almost nothing to mitigate the problem, but it lets me close an open PR.

In the future I will revert 473cb1fd74d6d478bb3d5fda4707ce3f6e6e5bf6 as
well as 279607cae58f7be46335793df6a4a753d0a800aa, and redo the whole
std.fmt API, breaking everyone's code and unfortunately causing nearly
every Zig user to have a bad day. std.fmt will go back to only dealing
in bytes, with zero Unicode awareness whatsoever. I suggest a third
party package provide Unicode functionality as well as a more advanced
text formatting function for when Unicode awareness is needed. I have
always suggested this, and I sincerely apologize for merging pull
requests that compromised my stance on this matter.

Most applications should, instead, strive to make their code independent
of Unicode, dealing strictly in encoded UTF-8 bytes, and never attempt
operations such as: substring manipulation, capitalization, alignment,
word replacement, or column number calculations.

Exceptions to this include web browsers, GUI toolkits, and terminals. If
you're not making one of these, any dependency on Unicode is probably a
bug or worse, a poor design decision.

closes #18536
2024-01-21 20:31:13 -07:00
Andrew Kelley
ac29303321
Merge pull request #18634 from MrDmitry/bug/ConfigHeader_cmake_neighbors
std.Build.Step.ConfigHeader (cmake): fix offset calculation for multiple substitutions on a single line
2024-01-21 12:45:21 -08:00
Christiano Haesbaert
bf7ebfa67a Handle all errors on std.net.Ipv4address.resolveIP
The following test fails since NonCanonical is not handled

test "foo" {
    std.net.Ip4Address.resolveIp("1.1.1.1", 0) catch unreachable;
}

/usr/lib/zig/std/net.zig:240:60: error: switch must handle all possibilities
        if (parse(name, port)) |ip4| return ip4 else |err| switch (err) {
                                                           ^~~~~~
/usr/lib/zig/std/net.zig:240:60: note: unhandled error value: 'error.NonCanonical'
referenced by:
    test.foo: src/dhcp.zig:383:23
2024-01-21 11:20:03 +02:00
MrDmitry
2dfec13ef0 Fix last_index after variable substitution
Iterative passes should start at the end of the previous substitution
2024-01-21 03:16:09 -05:00
Andrew Kelley
10aff67502
Merge pull request #18596 from ypsvlq/mingw
mingw-w64: add missing CRT sources
2024-01-20 12:01:33 -08:00
Andrew Kelley
5c4cb60f4f
Merge pull request #18622 from ziglang/zig-mod-edge-case
build system: better handle modules that do not have a zig root source file
2024-01-20 03:22:02 -08:00
expikr
b729a3f008
std.math: make hypot infer type from argument (#17910)
using peer type resolution
2024-01-20 01:32:07 -05:00
hdert
314533c28b std/math/pow: Fix #18553, isOddInteger: Return false if float value is greater than 1 << 53 (see comment), add test cases 2024-01-19 22:00:04 -08:00
Andrew Kelley
2dea375450 std.Build.Compile: handle modules sans root source files
Uses the new `-M[name][=src]` CLI syntax to omit the source when the
module does not have a zig root source file.

Only some kinds of link objects imply that this should happen.
2024-01-19 22:28:07 -07:00
Andrew Kelley
480a2f7f02
Merge pull request #18293 from g-cassie/array-list-replace-range-assume
Add replaceRangeAssumeCapacity method to ArrayList
2024-01-19 21:10:09 -08:00
Elaine Gibson
398ab5fcfb mingw: update build logic 2024-01-20 00:24:39 +00:00
Meghan Denny
46d592e485 do not enforce function parameters to be marked comptime if only called at comptime 2024-01-19 15:31:18 -08:00
Andrew Kelley
827e30634f std.ArrayList: pedantic fixups to previous commit
* fix and clarify incorrect doc comments
* unify the pattern of calling unmanaged methods
2024-01-19 16:24:51 -07:00
Gordon Cassie
4ddd0b1a1b std.ArrayList: add replaceRangeAssumeCapacity method 2024-01-19 16:24:51 -07:00
Andrew Kelley
d7b6d637df
Merge pull request #18615 from ziglang/langref
miscellaneous documentation changes
2024-01-19 12:14:30 -08:00
Andrew Kelley
3c16e80372
Merge pull request #18611 from erikarvstedt/array-list-overflow
ArrayList: remove unneeded overflow checks
2024-01-19 12:10:00 -08:00
Andrew Kelley
ab82132749 zig build: add doc comments for functions related to options
closes #18204
2024-01-18 22:01:09 -07:00
Erik Arvstedt
c50ba2d101 std.ArrayList.replaceRange: remove unneded overflow checks
The code asserted that the range to be replaced is within bounds of
`self.items`.
This is now reflected in the doc comment.
The old, wrong doc comment was copied from the `insert*` fns.

With this assertion holding true, `start + len` is always within the
address space and `start + new_items.len` is, at this point, always
strictly within bounds of `self.items`.
2024-01-19 00:55:17 +01:00
Erik Arvstedt
0bb6967d14 std.ArrayList: remove + 1 overflow checks 2024-01-19 00:55:17 +01:00
Sebastien Marie
7d81c952d5 openbsd: add proper support for aarch64
define openbsd specific elements in std/dwarf/abi.zig regBytes()

work from Jasper Lievisse Adriaanse, with register values from sys/signal.h
and https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#dwarf-register-names
2024-01-18 15:45:42 -08:00
Nameless
a7dbc57a35 std.http.Client: read response messages with no length until eof 2024-01-18 15:43:58 -08:00
Andrew Kelley
22b9d8987d
Merge pull request #17499 from rootbeer/makepath-dangling-symlink
std.fs: tests for makePath and symlinks
2024-01-18 15:37:16 -08:00
Krzysztof Wolicki
14efbbfd89
std.Uri: change specifier for printing with scheme to semicolon ;
Fetch: print scheme when suggesting adding a ref to git URIs
2024-01-18 09:13:04 +02:00
Loris Cro
4ace1f5a7f Build: add namedWriteFiles to Build 2024-01-16 16:09:58 -08:00
Jay Petacat
fd43baa9ad byos: Ease GeneralPurposeAllocator integration
These changes enable me to use `GeneralPurposeAllocator` with my "Bring
Your Own OS" package. The previous checks for a freestanding target have
been expanded to `@hasDecl` checks.

- `root.os.heap.page_allocator` is used if it exists.
- `debug.isValidMemory` only calls `os.msync` if it's supported.
2024-01-16 15:05:38 -08:00
Andrew Kelley
a338c279f8
Merge pull request #15565 from xEgoist/spawnWindows
child_process: Add write and inheritable access to the null handle
2024-01-16 15:03:25 -08:00
melonedo
9b0da5ccef Fix TLS record overflow by limiting inner record length to 2^14
Per last paragraph of RFC 8446, Section 5.2, the length of the inner content of an encrypted record must not exceed 2^14 + 1, while that of the whole encrypted record must not exceed 2^14 + 256.
2024-01-16 14:58:56 -08:00
Pat Tullmann
ff5613873f std/fs/test.zig: Add statFile() tests of dangling symlink
Create a dangling symlink and check that statFile works with it.
2024-01-16 14:19:48 -08:00
Pat Tullmann
d35bdc8ee7 std/fs/test.zig: Try harder to clean up locking files 2024-01-16 14:19:48 -08:00
Pat Tullmann
c36962bb19 std/fs/test.zig: Factor out the symlink-creation wrappers
Because creation of a symlink can fail on Windows with an Access Denied
error (https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links)
any tests that need a symbolic link "skip" if they run into this problem.

This change factors out a "setupSymbolicLink()" routine to make this
clearer, a bit tighter, and easier to use in future tests.

I also collapsed the "symlink in parent directory" test into the existing
"Dir.readlink" test, because the latter uses the more comprehensive
testWithAllSupportedPathTypes wrapper.
2024-01-16 14:19:48 -08:00
Pat Tullmann
95a0e127b3 std/fs/test.zig: quote . and .. in test names
The test runner uses "." in its output between the test module and the
test name, so quote the leading '.' in these test names to make them
easier to read.
2024-01-16 13:49:00 -08:00
Purrie
c4a1b54ebe tls client interface consistency fix
Client for tls was using a function that wasn't declared on the
interface for it. The issue wasn't apparent because net stream
implemented that function.

I changed it to keep the interface promise of what's required to be
compatible with the tls client functionality.
2024-01-16 13:02:00 -08:00
Andrew Kelley
195eeed2d8 std: remove deprecated API 2024-01-16 04:20:05 -08:00
xEgoist
194ed30825 child_process: Use security attributes while creating handle.
As suggested by @matu3ba, it can be better to use Security Attributes
directly while creating the handle instead of creating the handle then
setting the handle to inherit. Doing so can prevent potentially leaking
to other parallel spawned processes which would inherit the opened `\Device\Null`
handle.

This change also allows windows.OpenFile to handle when bInheritHandle
is set.

Note that we are using the same `saAttr`, but since it's taken as a
pointer to a const in all calls, it's never mutated, and OpenFile never alters it.

This also saves 1 kernel call for setting the handle to inherit.
2024-01-16 01:25:14 -08:00
xEgoist
41bf816fa6 child_process: Add write access to the null handle
This commit allows write access to the `\\Device\\Null` Handle.
Without a write access, it's not possible for the child process to write
SdOut to Null. As a requirement `SetHandleInformation` was also changed
to mark the handle as iheritable (by adding it to Flags) by the spawned process.
This allows the child to access the NUL device that was opened.

This also makes the Windows part to behave similarly to `spawnPosix`.
2024-01-16 01:25:14 -08:00
Krzysztof Wolicki
7116b02210 Allow multiple options using the same enum type 2024-01-15 23:08:11 -08:00
Andrew Kelley
88ee323cd7
Merge pull request #18570 from gh-fork-dump/linux-6.7
Linux: Update syscall bits for 6.7
2024-01-15 23:04:02 -08:00
Andrew Kelley
d1ce8b8837
Merge pull request #18168 from cipharius/feature/zig-build-fossil-support
Adds support for Fossil SCM source tree archives as zig build dependencies
2024-01-15 23:02:50 -08:00
Andrew Kelley
f2721a4cbc std.ArrayList: pedantic rewordings of documentation and unit tests 2024-01-15 23:44:36 -07:00
notcancername
69461bcae4 std.array_list: Document and reduce illegal behavior in ArrayLists 2024-01-15 23:44:36 -07:00
cipharius
f25c499d12 Permits tar directory path without trailing slash 2024-01-15 18:31:32 +02:00
Stephen Gregoratto
3200fae9c5 Linux: Add syscall bindings, enhance documentation.
- Add syscall bindings/structures for the `futex2` family.
  The documentation is taken from the syscall definitions.
- Add documnentation for the `cachestat` bindings and structures.
  Taken from work I did in Cosmopolitian libc.
- Add binding for `map_shadow_stack`.
  No documentation for this one, since the kernel devs didn't bother to
  do it ¯\_(ツ)_/¯.
2024-01-15 20:05:03 +11:00
Stephen Gregoratto
cca021c211 Linux: Update syscalls for the 6.7 release
This release adds the rest of the futex2[1] syscalls, along with
shadow stack[2] support for more architectures.

[1]: https://lwn.net/Articles/940944/
[2]: https://lwn.net/Articles/926649/
2024-01-15 20:05:03 +11:00
Jakub Konka
3dddb881bf
Merge pull request #18560 from ziglang/elf-report-dupes
elf: report duplicate symbol definitions
2024-01-15 07:37:09 +01:00
Jakub Konka
852e7e24b5
Merge pull request #17917 from Jan200101/PR/each_lib_rpath_frontend
move rpath to frontend and remove native paths from it
2024-01-15 07:35:12 +01:00
Andrew Kelley
a5934edd48 std.os.linux.io_uring: fix compilation errors
Commit f0c42fbba15a31113dc989ab65c054047423afa3 was created before the
additional compile error for var used instead of const.
2024-01-14 19:20:41 -07:00
Andrew Kelley
f0c42fbba1
Merge pull request #18025 from ianic/io_uring_send_zc
io_uring: add send_zc and *_direct operations
2024-01-14 18:10:51 -08:00
expikr
ff23efe9fa Update pow.zig 2024-01-14 18:09:26 -08:00
expikr
0c70d9c714 use Peer Type Resolution for standalone complex fn
use peer type resolution

Update complex.zig

Revert "use peer type resolution"

This reverts commit 1bc681ca5b36d2b55b5efab5a5dbec7e8a17332e.

Revert "Update pow.zig"

This reverts commit 5487e8d3159f832b5a0bf29a06bd12575182464f.

Update pow.zig

Revert "Update pow.zig"

This reverts commit 521153d1ef004d627c785f2d3fe5e6497dc15073.

Update pow.zig
2024-01-14 18:09:17 -08:00
Tristan Ross
9fce1d1ab1
mem: add byteswap array support (#17959)
also make byteswap work with enums
2024-01-14 21:06:31 -05:00