Commit Graph

3705 Commits

Author SHA1 Message Date
Frank Denis
d1b1e542a0 crypto/pbkdf2: simplify the check for the max number of iterations 2021-03-16 18:55:58 +01:00
Lewis Gaul
6787f163eb
zig fmt: don't add trailing whitespace on switch case 2021-03-16 09:26:28 +01:00
LemonBoy
5ecf8bddae
zig fmt: Respect line breaks in struct default value decls
Bring this in line with how variable declarations are handled.

Open a new indentation level for the initialization expression to handle
nested expressions like blocks.

Closes #7618
2021-03-16 09:22:16 +01:00
Anders Conbere
f16f25047c
std: support optional getaddrinfo arguments 2021-03-16 01:10:32 +01:00
Lewis Gaul
aa1c780560 Add test for multi-line while cont expr with same-line then expr 2021-03-15 20:44:45 +01:00
Isaac Freund
48efa3bcb6 zig fmt: simplify and improve consistency of if/for/while handling
The main realization here was that getting rid of the early returns
in renderWhile() and rewriting the logic into a mostly unified execution
path took things from ~200 lines to ~100 lines and improved consistency
by deduplicating code.

Also add several test cases and fix a few issues along the way:

Fixes https://github.com/ziglang/zig/issues/6114
Fixes https://github.com/ziglang/zig/issues/8022
2021-03-15 14:55:34 +01:00
Lewis Gaul
b4db03d8bb zig fmt: fix extra newline before if nested in for
Add failing testcase to reproduce issue 8088

Tidy up renderWhile(), factoring out renderWhilePayload()

Ensure correct newline is used before 'then' token in while/for/if

Handle indents for 'if' inside 'for' or 'while'

Stop special-casing 'if' compared to 'for' and 'while'
2021-03-15 14:55:34 +01:00
LemonBoy
27d07c6c4d std: Replace testing fns for floating-point values
Beside handling NaNs and other non-numeric values better we finally
offer the same pair of testing predicates in math and testing.
2021-03-14 17:23:47 -04:00
Frank Denis
b98d7747fa Use a unified error set for std/crypto/*
This ensures that errors are used consistently across all operations.
2021-03-14 20:51:31 +01:00
LemonBoy
8ebb18d9da std: Use more common escape sequences in Progress
This should fix the badly-rendered progress message when run in
Terminal.app.
2021-03-12 19:31:59 -05:00
Isaac Freund
b83ef595a5 std/linux: sync io_uring library with liburing
liburing commit: 1bafb3ce5f

As stated in the liburing commit message, this fixes a regression,
reverting code that was added specutively to avoid a syscall in some
cases.
2021-03-12 22:22:06 +01:00
Andrew Kelley
f950489ed9
Merge pull request #8174 from LemonBoy/progress-line-wrap
std: Better handling of line-wrapping in Progress
2021-03-12 15:45:11 -05:00
Jakub Konka
a745e704f6 macos: add missing x86_64 libc headers 2021-03-12 18:05:50 +01:00
LemonBoy
b0724a350f Handle some weird edge cases of Win32 API
Sometimes the viewport srWindow may report an invalid rectangle where
the top row is below the bottom one.
2021-03-12 17:14:50 +01:00
LemonBoy
b5a50a26eb Fix many thinkos
Somehow I forgot to save after copy-pasting some code and changing it.
2021-03-12 15:08:48 +01:00
Sébastien Marie
89e522b935 make std.c.getErrno() return same type as _errno() aka c_int
adjust std.os.unexpectedErrno() to be correct for all std.os.system.errno (c_int, u12, usize, ...)
2021-03-12 15:04:36 +01:00
LemonBoy
3010bfb08a Fix Progress printing on Windows systems
The cursor must be restored after the line is printed, not before.
Take into account the visible viewport to correctly compute the terminal
size.
2021-03-12 10:15:38 +01:00
Andrew Kelley
e9a038c33b
Merge pull request #7934 from Vexu/stage2-cbe
Stage2 cbe: optionals and errors
2021-03-11 22:02:35 -05:00
Isaac Freund
a5cb4ab95e parser: disallow ptr modifiers on array types 2021-03-12 00:18:30 +01:00
LemonBoy
482424e2b1 std: Handle empty MultiArrayList in items()
Closes #8211
2021-03-12 00:17:35 +01:00
Andrew Kelley
4fc6f631e0
Merge pull request #8126 from xackus/translate_c_int_literal_promotion
translate-c: promote int literals to bigger types
2021-03-11 14:32:37 -05:00
Asherah Connor
24e5959840 elf: make EM non-exhaustive 2021-03-11 10:09:51 +11:00
Asherah Connor
c5eb15526d expose machine field in ELF header 2021-03-10 16:26:41 +11:00
Loris Cro
a033735c8d update to latest fetch-them-macos-headers 2021-03-09 22:43:16 +01:00
Loris Cro
767eb2d469 update to latest fetch-them-macos-headers 2021-03-09 22:15:01 +01:00
Isaac Freund
b988815bf0 parser: fix parsing/rendering of a[b.. :c] slicing
The modification to the grammar in the comment is in line with the
grammar in the zig-spec repo.

Note: checking if the previous token is a colon is insufficent to tell
if a block has a label, the identifier must be checked for as well. This
can be seen in sentinel terminated slicing: `foo[0..1:{}]`
2021-03-08 01:37:28 +01:00
Veikka Tuominen
0a7be71bc2
stage2 cbe: non pointer optionals 2021-03-08 00:33:56 +02:00
jacob gw
5d215cc76b stage2 Elf linker: fill in bswapAllFields
I moved it to std.elf since it could be used there and added test
2021-03-07 23:18:26 +02:00
LemonBoy
4fc2e92876 std: Better handling of line-wrapping in Progress
In order to update the printed progress string the code tried to move
the cursor N cells to the left, where N is the number of written bytes,
and then clear the remaining part of the line.
This strategy has two main issues:
 - Is only valid if the number of characters is equal to the number of
   written bytes,
 - Is only valid if the line doesn't get too long.

The second point is the main motivation for this change, when the line
becomes too long the terminal wraps it to a new physical line. This
means that moving the cursor to the left won't be enough anymore as once
the left border is reached it cannot move anymore.

The wrapped line is still stored by the terminal as a single line,
despite now taking more than a single one when displayed. If you try to
resize the terminal you'll notice how the contents are reflowed and are
essentially illegible.

Querying the cursor position on non-Windows systems (plot twist,
Microsoft suggests using VT escape sequences on newer systems) is
extremely cumbersome so let's do something different.

Before printing anything let's save the cursor position and clear the
screen below the cursor, this way we ensure there's absolutely no trace
of stale data on screen, and after the message is printed we simply
restore it.
2021-03-07 15:23:20 +01:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter (#8137)
* Implement fmtDuration using Formatter

Deprecate Duration, duration

* fmtDuration: Fixed ns remainder

* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491 std: Deprecate the B and Bi format specifiers
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
e47b754b28 std: Prevent null pointer deref in mem.len{,Z}
Closes #8140
2021-03-07 14:58:45 +02:00
Vincent Rischmann
272ae0ca0d fix parsing of assignment with 'inline for' and 'inline while' 2021-03-06 17:39:54 -08:00
Meghan
9f722f43ac
std/special: init-exe,lib make import(std) its own decl (#8160)
std/special: init-exe,lib make import(std) its own decl
2021-03-05 19:13:05 -08:00
Isaac Freund
ef3adbdb36 zig fmt: fix lastToken() for container_decl_arg 2021-03-05 21:33:27 +01:00
xackus
eee43a65ae add tests 2021-03-05 21:21:23 +01:00
Maciej Walczak
5f53b77c2b remove redundant cast
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2021-03-05 21:04:27 +01:00
xackus
679910ecec translate-c: promote int literals to bigger types 2021-03-05 21:04:27 +01:00
Veikka Tuominen
9cd038d73a std: fix memory leak in MultiArrayList 2021-03-05 10:52:40 -08:00
cryptocode
02737d535a Reject bare +/- input when parsing floats 2021-03-05 13:11:20 +01:00
Andrew Kelley
434fce2146 zig fmt: recovery: missing while rbrace
Previously, this test case resulted in zig fmt entering an endless loop.
2021-03-04 20:54:09 -07:00
Andrew Kelley
ffb2568a9f
Merge pull request #7763 from kivikakk/zig-elf-parse
std.elf: expose parsing decoupled from std.fs.File
2021-03-04 11:56:31 -08:00
daurnimator
34ca6b7b44 std: add io.Writer.writeStruct
We have readStruct, add writeStruct for symmetry
2021-03-03 22:45:45 +01:00
Veikka Tuominen
904f774563 translate-c: fix c tokenizer giving invalid tokens 2021-03-03 11:33:14 -08:00
Isaac Freund
3ad9cb8b47 zig fmt: allow and trim whitespace around zig fmt: (off|on)
Currently `//  zig fmt: off` does not work as there are two spaces
after the `//` instead of one. This can cause confusion, so allow
arbitrary whitespace before the `zig fmt: (off|on)` in the comment but
trim this whitespace to the canonical single space in the output.
2021-03-03 01:06:09 +01:00
Vincent Rischmann
3dd8396a55 os/linux: fix IO_Uring.timeout
According to the io_uring PDF (https://kernel.dk/io_uring.pdf) the
timeout struct must be 64 bits on both 32 and 64 bit architectures.
2021-03-02 14:13:11 +02:00
Andrew Kelley
f9c9b92175
Merge pull request #7946 from koachan/sparc64-framefixes
SPARCv9: Handle various stack frame related quirks.
2021-03-01 19:10:36 -08:00
Andrew Kelley
a20169a610 zig fmt the std lib 2021-03-01 20:04:28 -07:00
Martin Wickham
7613e51a57 Add some bit set variants 2021-03-01 18:52:15 -08:00
Isaac Freund
7b5b7bda87 parser: fix infinite loop on missing comma in param list 2021-03-01 16:09:57 -08:00