Commit graph

88 commits

Author SHA1 Message Date
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
Jonathan Marler
08e5daa7d5 Add std.unicode.fmtUtf16le 2021-07-15 20:37:16 +03:00
Andrew Kelley
125b85d737 move "unreachable code" error from stage1 to stage2
* AstGen: implement "unreachable code" error for blocks. This works at
   the statement level.
 * stage1: remove the "unreachable code" error implementation, which
   means removing the `is_gen` field from IrInstSrc. This is one small
   step towards a smaller memory footprint for stage1. The benefits
   won't be realized until a future commit because this flag took
   advantage of padding.

There may be a regression here with "union has no associated enum"
error, and there is a regression with the following code:

```zig
const a = noreturn;
```

A future commit will address these regressions.
2021-07-02 13:26:50 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Veikka Tuominen
fd77f2cfed std: update usage of std.testing 2021-05-08 15:15:30 +03:00
Andrew Kelley
df24ce52b1 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
xackus
a5007d819a std.meta: add isError 2021-04-11 16:26:29 +02:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Rageoholic
0369b65082
Switch to using unicode when parsing the command line on windows (#7241)
* Switch to using unicode when parsing the command line on windows

* Apply changes by LemonBoy and *hopefully* fix tests on MIPs

Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>

* Fix up next and skip

* Move comment to more relevant place

Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>
2020-11-30 13:47:01 -05:00
LemonBoy
53c1624074 std: Make utf8CountCodepoints much faster
Make the code easier for the optimizer to work with and introduce a fast
path for ASCII sequences.

Introduce a benchmark harness to start tracking the performance of ops
on utf8.
2020-11-05 16:10:34 +01:00
LemonBoy
44533f10fe std: Introduce std.unicode.utf8ValidCodepoint 2020-11-05 16:10:34 +01:00
LemonBoy
6c4efab106 std: Introduce std.unicode.utf8CountCodepoints 2020-11-05 16:10:33 +01:00
LemonBoy
76e9a4ae83 std: Fix std.unicode test cases for BE targets 2020-11-02 11:48:06 +01: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
Michael Rees
bd17a373cc Add std.unicode.Utf8Iterator.peek 2020-06-18 20:35:03 -04:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
Andrew Kelley
f614d94faa
update std lib to take advantage of slicing with comptime indexes 2020-03-19 14:48:47 -04:00
Jared Miller
cf38ce9701 Implement UTF-8 to UTF-16LE literal conversion 2020-03-07 19:21:28 -05:00
xackus
783e8ad031 remove @bytesToSlice, @sliceToBytes from std lib 2020-02-21 19:46:53 +01:00
Benjamin Feng
699c50a375 Switch a bunch of FBA to use testing.allocator 2020-02-12 17:17:56 -06:00
Andrew Kelley
3b622f4494
fix off-by-one error in std.unicode.utf8ToUtf16LeWithNull
and fix larger-than-one-byte sentinels when being freed

Thank you to João Pedro for identifying both problems and
providing example code to solve them.

closes #4413
2020-02-09 14:56:19 -05:00
Benjamin Feng
b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Benjamin Feng
aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng
4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
daurnimator
2662e50d27
std: sentinel terminated pointers for utf16 apis 2019-12-29 10:35:05 +11:00
daurnimator
edb5deb39c
std: unicode codepoints are 21 bits 2019-12-28 16:49:59 +11:00
daurnimator
ab6065407d
std: simplify utf8ToUtf16Le
Also faster, on my machine unicode/throughput_test.zig now gives e.g.
> original utf8ToUtf16Le: elapsed: 1048 ns (0 ms)
> new utf8ToUtf16Le: elapsed: 971 ns (0 ms)
2019-12-28 16:49:59 +11:00
daurnimator
5843a6e3bc
std: optimise utf8ByteSequenceLength
Also tested (but not as fast):
```zig
pub fn utf8ByteSequenceLength(first_byte: u8) !u3 {
    const len = @clz(u8, ~first_byte);
    if (len == 0) return 1;
    if (len < 4) return @intCast(u3, len);
    return error.Utf8InvalidStartByte;
}
```
2019-12-28 14:39:38 +11:00
daurnimator
a81c0ba2e7
std: fix unicode encoding of astral plane codepoints to utf16 2019-12-28 14:39:38 +11:00
Dmitry Atamanov
744133acb1 Fixes utf8ToUtf16Le (#3923) 2019-12-16 16:27:26 -05:00
Andrew Kelley
8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley
bf3ac66150
remove type coercion from array values to references
* Implements #3768. This is a sweeping breaking change that requires
   many (trivial) edits to Zig source code. Array values no longer
   coerced to slices; however one may use `&` to obtain a reference to
   an array value, which may then be coerced to a slice.

 * Adds `IrInstruction::dump`, for debugging purposes. It's useful to
   call to inspect the instruction when debugging Zig IR.

 * Fixes bugs with result location semantics. See the new behavior test
   cases, and compile error test cases.

 * Fixes bugs with `@typeInfo` not properly resolving const values.

 * Behavior tests are passing but std lib tests are not yet. There
   is more work to do before merging this branch.
2019-11-27 03:37:50 -05:00
Andrew Kelley
aa0daea541
update more of the std lib to use @as 2019-11-08 15:57:25 -05:00
Andrew Kelley
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -05:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00
Renamed from std/unicode.zig (Browse further)