@zigc/lib 0.15.0-dev.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +1 -5
  2. package/build-web/fuzz.zig +6 -6
  3. package/build-web/time_report.zig +13 -14
  4. package/compiler/reduce/Walk.zig +9 -10
  5. package/compiler/reduce.zig +20 -19
  6. package/compiler/resinator/compile.zig +1 -1
  7. package/compiler_rt/arm.zig +1 -1
  8. package/init/build.zig +1 -1
  9. package/libc/freebsd/lib/csu/aarch64/crt.h +1 -0
  10. package/libc/freebsd/lib/csu/aarch64/crt1_c.c +33 -0
  11. package/libc/freebsd/lib/csu/aarch64/crt1_s.S +68 -0
  12. package/libc/freebsd/lib/csu/amd64/crt.h +30 -0
  13. package/libc/freebsd/lib/csu/amd64/crt1_c.c +30 -0
  14. package/libc/freebsd/lib/csu/amd64/crt1_s.S +89 -0
  15. package/libc/freebsd/lib/csu/arm/crt.h +1 -0
  16. package/libc/freebsd/lib/csu/arm/crt1_c.c +80 -0
  17. package/libc/freebsd/lib/csu/arm/crt1_s.S +77 -0
  18. package/libc/freebsd/lib/csu/common/crtbegin.c +95 -0
  19. package/libc/freebsd/lib/csu/common/crtbrand.S +55 -0
  20. package/libc/freebsd/lib/csu/common/crtend.c +65 -0
  21. package/libc/freebsd/lib/csu/common/csu_common.h +50 -0
  22. package/libc/freebsd/lib/csu/common/feature_note.S +47 -0
  23. package/libc/freebsd/lib/csu/common/ignore_init_note.S +48 -0
  24. package/libc/freebsd/lib/csu/common/notes.h +32 -0
  25. package/libc/freebsd/lib/csu/i386/crt.h +30 -0
  26. package/libc/freebsd/lib/csu/i386/crt1_c.c +30 -0
  27. package/libc/freebsd/lib/csu/i386/crt1_s.S +91 -0
  28. package/libc/freebsd/lib/csu/powerpc/crt.h +31 -0
  29. package/libc/freebsd/lib/csu/powerpc/crt1_c.c +89 -0
  30. package/libc/freebsd/lib/csu/powerpc/crtsavres.S +189 -0
  31. package/libc/freebsd/lib/csu/powerpc64/crt.h +31 -0
  32. package/libc/freebsd/lib/csu/powerpc64/crt1_c.c +83 -0
  33. package/libc/freebsd/lib/csu/riscv/crt.h +8 -0
  34. package/libc/freebsd/lib/csu/riscv/crt1_c.c +51 -0
  35. package/libc/freebsd/lib/csu/riscv/crt1_s.S +51 -0
  36. package/libc/freebsd/lib/libc/include/libc_private.h +450 -0
  37. package/libc/include/generic-glibc/arpa/inet.h +0 -3
  38. package/libc/netbsd/lib/csu/arch/aarch64/crt0.S +45 -0
  39. package/libc/netbsd/lib/csu/arch/earm/crt0.S +61 -0
  40. package/libc/netbsd/lib/csu/arch/i386/crt0.S +48 -0
  41. package/libc/netbsd/lib/csu/arch/m68k/crt0.S +47 -0
  42. package/libc/netbsd/lib/csu/arch/mips/crt0.S +59 -0
  43. package/libc/netbsd/lib/csu/arch/powerpc/crt0.S +56 -0
  44. package/libc/netbsd/lib/csu/arch/sparc/crt0.S +55 -0
  45. package/libc/netbsd/lib/csu/arch/sparc64/crt0.S +59 -0
  46. package/libc/netbsd/lib/csu/arch/x86_64/crt0.S +48 -0
  47. package/libc/netbsd/lib/csu/common/crt0-common.c +351 -0
  48. package/libc/netbsd/lib/csu/common/crtbegin.c +135 -0
  49. package/libc/netbsd/lib/csu/common/csu-common.h +38 -0
  50. package/libc/netbsd/lib/csu/common/sysident.S +89 -0
  51. package/libc/netbsd/lib/csu/common/sysident_assym.h +17 -0
  52. package/package.json +2 -2
  53. package/std/Build/Step/Compile.zig +1 -20
  54. package/std/Build/Step/TranslateC.zig +0 -6
  55. package/std/Build/WebServer.zig +1 -1
  56. package/std/Build.zig +1 -4
  57. package/std/Io/Reader/Limited.zig +0 -44
  58. package/std/Io/Reader.zig +28 -128
  59. package/std/Io/Writer.zig +6 -31
  60. package/std/Target.zig +0 -8
  61. package/std/Thread.zig +4 -3
  62. package/std/c.zig +26 -87
  63. package/std/crypto/aes_ocb.zig +3 -32
  64. package/std/crypto/tls/Client.zig +8 -19
  65. package/std/debug.zig +1 -1
  66. package/std/fs/Dir.zig +1 -2
  67. package/std/fs/File.zig +104 -105
  68. package/std/http/Client.zig +2 -3
  69. package/std/json/static.zig +3 -3
  70. package/std/math/big/int.zig +4 -3
  71. package/std/math/powi.zig +0 -1
  72. package/std/mem/Allocator.zig +1 -3
  73. package/std/mem.zig +1 -3
  74. package/std/net.zig +2 -3
  75. package/std/os/linux/bpf.zig +2 -2
  76. package/std/os/linux/powerpc.zig +12 -74
  77. package/std/os/linux/powerpc64.zig +12 -74
  78. package/std/os/linux.zig +2 -7
  79. package/std/os/uefi/protocol/service_binding.zig +1 -1
  80. package/std/os/uefi/tables.zig +1 -1
  81. package/std/pie.zig +1 -1
  82. package/std/posix.zig +4 -6
  83. package/std/process/Child.zig +1 -5
  84. package/std/process.zig +2 -16
  85. package/std/sort/pdq.zig +1 -48
  86. package/std/testing.zig +0 -60
  87. package/std/zig/llvm/BitcodeReader.zig +1 -5
  88. package/std/zig/system/linux.zig +4 -1
  89. package/std/zig/system.zig +2 -3
  90. package/std/zon/parse.zig +0 -1
  91. package/ubsan_rt.zig +3 -3
  92. package/libc/musl/src/fenv/loongarch64/fenv-sf.c +0 -3
@@ -0,0 +1,135 @@
1
+ /*-
2
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This code is derived from software contributed to The NetBSD Foundation
6
+ * by Matt Thomas of 3am Software Foundry.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ * 1. Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * 2. Redistributions in binary form must reproduce the above copyright
14
+ * notice, this list of conditions and the following disclaimer in the
15
+ * documentation and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
+ * POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+ #include <sys/cdefs.h>
30
+ __RCSID("$NetBSD: crtbegin.c,v 1.17 2018/12/28 18:17:11 christos Exp $");
31
+
32
+ /* zig patch: no crtbegin.h */
33
+
34
+ typedef void (*fptr_t)(void);
35
+
36
+ /* zig patch: remove gcj nonsense */
37
+
38
+ #if !defined(HAVE_INITFINI_ARRAY)
39
+ extern __dso_hidden const fptr_t __CTOR_LIST__start __asm("__CTOR_LIST__");
40
+
41
+ __dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = {
42
+ (fptr_t) -1,
43
+ };
44
+ __dso_hidden extern const fptr_t __CTOR_LIST_END__[];
45
+ #endif
46
+
47
+ #ifdef SHARED
48
+ __dso_hidden void *__dso_handle = &__dso_handle;
49
+
50
+ __weakref_visible void cxa_finalize(void *)
51
+ __weak_reference(__cxa_finalize);
52
+ #else
53
+ __dso_hidden void *__dso_handle;
54
+ #endif
55
+
56
+ #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
57
+ __dso_hidden const long __EH_FRAME_LIST__[0] __section(".eh_frame");
58
+
59
+ __weakref_visible void register_frame_info(const void *, const void *)
60
+ __weak_reference(__register_frame_info);
61
+ __weakref_visible void deregister_frame_info(const void *)
62
+ __weak_reference(__deregister_frame_info);
63
+
64
+ static long dwarf_eh_object[8];
65
+ #endif
66
+
67
+ static void __do_global_ctors_aux(void) __used;
68
+
69
+ /* zig patch: use .init_array */
70
+ __attribute__((constructor))
71
+ static void
72
+ __do_global_ctors_aux(void)
73
+ {
74
+ static unsigned char __initialized;
75
+
76
+ if (__initialized)
77
+ return;
78
+
79
+ __initialized = 1;
80
+
81
+ #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
82
+ if (register_frame_info)
83
+ register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object);
84
+ #endif
85
+
86
+ /* zig patch: remove gcj nonsense */
87
+
88
+ #if !defined(HAVE_INITFINI_ARRAY)
89
+ for (const fptr_t *p = __CTOR_LIST_END__; p > &__CTOR_LIST__start + 1; ) {
90
+ (*(*--p))();
91
+ }
92
+ #endif
93
+ }
94
+
95
+ #if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__)
96
+ #if !defined(HAVE_INITFINI_ARRAY)
97
+ extern __dso_hidden const fptr_t __DTOR_LIST__start __asm("__DTOR_LIST__");
98
+
99
+ __dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = {
100
+ (fptr_t) -1,
101
+ };
102
+ __dso_hidden extern const fptr_t __DTOR_LIST_END__[];
103
+ #endif
104
+
105
+ static void __do_global_dtors_aux(void) __used;
106
+
107
+ /* zig patch: use .fini_array */
108
+ __attribute__((destructor))
109
+ static void
110
+ __do_global_dtors_aux(void)
111
+ {
112
+ static unsigned char __finished;
113
+
114
+ if (__finished)
115
+ return;
116
+
117
+ __finished = 1;
118
+
119
+ #ifdef SHARED
120
+ if (cxa_finalize)
121
+ (*cxa_finalize)(__dso_handle);
122
+ #endif
123
+
124
+ #if !defined(HAVE_INITFINI_ARRAY)
125
+ for (const fptr_t *p = &__DTOR_LIST__start + 1; p < __DTOR_LIST_END__; ) {
126
+ (*(*p++))();
127
+ }
128
+ #endif
129
+
130
+ #if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__)
131
+ if (deregister_frame_info)
132
+ deregister_frame_info(__EH_FRAME_LIST__);
133
+ #endif
134
+ }
135
+ #endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */
@@ -0,0 +1,38 @@
1
+ /*-
2
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
15
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
18
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ * POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ /*
28
+ * For historical reasons the following symbols are defined both in libc
29
+ * and csu and need to be common
30
+ */
31
+ #if __has_attribute(__common__)
32
+ #define __common __attribute((__common__))
33
+ #else
34
+ #define __common
35
+ #endif
36
+ extern char *__progname __common;
37
+ extern char **environ __common;
38
+ extern struct ps_strings *__ps_strings __common;
@@ -0,0 +1,89 @@
1
+ /* $NetBSD: sysident.S,v 1.3 2014/05/14 14:59:14 joerg Exp $ */
2
+
3
+ /*
4
+ * Copyright (c) 1997 Christopher G. Demetriou
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions
9
+ * are met:
10
+ * 1. Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ * 3. All advertising materials mentioning features or use of this software
16
+ * must display the following acknowledgement:
17
+ * This product includes software developed for the
18
+ * NetBSD Project. See http://www.NetBSD.org/ for
19
+ * information about NetBSD.
20
+ * 4. The name of the author may not be used to endorse or promote products
21
+ * derived from this software without specific prior written permission.
22
+ *
23
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ *
34
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
35
+ */
36
+
37
+ /*
38
+ * Here we define the NetBSD OS Version in an ELF .note section, structured
39
+ * like:
40
+ *
41
+ * [NOTE HEADER]
42
+ * long name size
43
+ * long description size
44
+ * long note type
45
+ *
46
+ * [NOTE DATUM]
47
+ * string OS name
48
+ *
49
+ * OSVERSION notes also have:
50
+ * long OS version (__NetBSD_Version__ constant from param.h)
51
+ *
52
+ * The DATUM fields should be padded out such that their actual (not
53
+ * declared) sizes % 4 == 0.
54
+ *
55
+ * These are used by the kernel to determine if this binary is really a
56
+ * NetBSD binary, or some other OS's.
57
+ */
58
+
59
+ #include "sysident_assym.h"
60
+
61
+ .section ".note.netbsd.ident", "a"
62
+ .p2align 2
63
+
64
+ .long ELF_NOTE_NETBSD_NAMESZ
65
+ .long ELF_NOTE_NETBSD_DESCSZ
66
+ .long ELF_NOTE_TYPE_NETBSD_TAG
67
+ .ascii "NetBSD\0\0" /* ELF_NOTE_NETBSD_NAME */
68
+ .long __NetBSD_Version__
69
+
70
+ .section ".note.netbsd.pax", "a"
71
+ .p2align 2
72
+
73
+ .long ELF_NOTE_PAX_NAMESZ
74
+ .long ELF_NOTE_PAX_DESCSZ
75
+ .long ELF_NOTE_TYPE_PAX_TAG
76
+ .ascii "PaX\0" /* ELF_NOTE_PAX_NAME */
77
+ .long 0
78
+
79
+ #ifdef ELF_NOTE_MARCH_DESC
80
+ .section ".note.netbsd.march", "a"
81
+ .p2align 2
82
+
83
+ .long ELF_NOTE_MARCH_NAMESZ
84
+ .long ELF_NOTE_MARCH_DESCSZ
85
+ .long ELF_NOTE_TYPE_MARCH_TAG
86
+ .ascii "NetBSD\0\0"
87
+ .asciz ELF_NOTE_MARCH_DESC
88
+ .p2align 2
89
+ #endif
@@ -0,0 +1,17 @@
1
+ /* zig patch: manually expanded from sysident_assym.cf */
2
+
3
+ #define ELF_NOTE_NETBSD_NAMESZ 7
4
+ #define ELF_NOTE_NETBSD_DESCSZ 4
5
+ #define ELF_NOTE_TYPE_NETBSD_TAG 1
6
+ #define ELF_NOTE_PAX_NAMESZ 4
7
+ #define ELF_NOTE_PAX_DESCSZ 4
8
+ #define ELF_NOTE_TYPE_PAX_TAG 3
9
+
10
+ /* zig patch: ELF_NOTE_MARCH_DESC and ELF_NOTE_MARCH_DESCSZ defined by the compiler */
11
+ #ifdef ELF_NOTE_MARCH_DESC
12
+ #define ELF_NOTE_MARCH_NAMESZ 7
13
+ #define ELF_NOTE_TYPE_MARCH_TAG 5
14
+ #endif
15
+
16
+ #define ELF_NOTE_MCMODEL_NAMESZ 7
17
+ #define ELF_NOTE_TYPE_MCMODEL_TAG 6
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.15.0-dev.0",
3
+ "version": "0.15.1",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/ziex-dev/ziex.git"
7
+ "url": "git+https://github.com/ziex-dev/zigc.git"
8
8
  },
9
9
  "license": "MIT"
10
10
  }
@@ -1827,26 +1827,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1827
1827
  _ = try std.fmt.bufPrint(&args_hex_hash, "{x}", .{&args_hash});
1828
1828
 
1829
1829
  const args_file = "args" ++ fs.path.sep_str ++ args_hex_hash;
1830
- if (b.cache_root.handle.access(args_file, .{})) |_| {
1831
- // The args file is already present from a previous run.
1832
- } else |err| switch (err) {
1833
- error.FileNotFound => {
1834
- try b.cache_root.handle.makePath("tmp");
1835
- const rand_int = std.crypto.random.int(u64);
1836
- const tmp_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
1837
- try b.cache_root.handle.writeFile(.{ .sub_path = tmp_path, .data = args });
1838
- defer b.cache_root.handle.deleteFile(tmp_path) catch {
1839
- // It's fine if the temporary file can't be cleaned up.
1840
- };
1841
- b.cache_root.handle.rename(tmp_path, args_file) catch |rename_err| switch (rename_err) {
1842
- error.PathAlreadyExists => {
1843
- // The args file was created by another concurrent build process.
1844
- },
1845
- else => |other_err| return other_err,
1846
- };
1847
- },
1848
- else => |other_err| return other_err,
1849
- }
1830
+ try b.cache_root.handle.writeFile(.{ .sub_path = args_file, .data = args });
1850
1831
 
1851
1832
  const resolved_args_file = try mem.concat(arena, u8, &.{
1852
1833
  "@",
@@ -163,12 +163,6 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
163
163
  try argv_list.append("-fno-clang");
164
164
  }
165
165
 
166
- try argv_list.append("--cache-dir");
167
- try argv_list.append(b.cache_root.path orelse ".");
168
-
169
- try argv_list.append("--global-cache-dir");
170
- try argv_list.append(b.graph.global_cache_root.path orelse ".");
171
-
172
166
  try argv_list.append("--listen=-");
173
167
 
174
168
  if (!translate_c.target.query.isNative()) {
@@ -323,7 +323,7 @@ fn serveWebSocket(ws: *WebServer, sock: *http.Server.WebSocket) !noreturn {
323
323
  // Temporarily unlock, then re-lock after the message is sent.
324
324
  ws.time_report_mutex.unlock();
325
325
  defer ws.time_report_mutex.lock();
326
- try sock.writeMessage(owned_msg, .binary);
326
+ try sock.writeMessage(msg, .binary);
327
327
  }
328
328
  }
329
329
 
package/std/Build.zig CHANGED
@@ -2524,10 +2524,7 @@ pub const LazyPath = union(enum) {
2524
2524
  .up = gen.up,
2525
2525
  .sub_path = dupePathInner(allocator, gen.sub_path),
2526
2526
  } },
2527
- .dependency => |dep| .{ .dependency = .{
2528
- .dependency = dep.dependency,
2529
- .sub_path = dupePathInner(allocator, dep.sub_path),
2530
- } },
2527
+ .dependency => |dep| .{ .dependency = dep },
2531
2528
  };
2532
2529
  }
2533
2530
  };
@@ -27,7 +27,6 @@ pub fn init(reader: *Reader, limit: Limit, buffer: []u8) Limited {
27
27
 
28
28
  fn stream(r: *Reader, w: *Writer, limit: Limit) Reader.StreamError!usize {
29
29
  const l: *Limited = @fieldParentPtr("interface", r);
30
- if (l.remaining == .nothing) return error.EndOfStream;
31
30
  const combined_limit = limit.min(l.remaining);
32
31
  const n = try l.unlimited.stream(w, combined_limit);
33
32
  l.remaining = l.remaining.subtract(n).?;
@@ -52,51 +51,8 @@ test stream {
52
51
 
53
52
  fn discard(r: *Reader, limit: Limit) Reader.Error!usize {
54
53
  const l: *Limited = @fieldParentPtr("interface", r);
55
- if (l.remaining == .nothing) return error.EndOfStream;
56
54
  const combined_limit = limit.min(l.remaining);
57
55
  const n = try l.unlimited.discard(combined_limit);
58
56
  l.remaining = l.remaining.subtract(n).?;
59
57
  return n;
60
58
  }
61
-
62
- test "end of stream, read, hit limit exactly" {
63
- var f: Reader = .fixed("i'm dying");
64
- var l = f.limited(.limited(4), &.{});
65
- const r = &l.interface;
66
-
67
- var buf: [2]u8 = undefined;
68
- try r.readSliceAll(&buf);
69
- try r.readSliceAll(&buf);
70
- try std.testing.expectError(error.EndOfStream, l.interface.readSliceAll(&buf));
71
- }
72
-
73
- test "end of stream, read, hit limit after partial read" {
74
- var f: Reader = .fixed("i'm dying");
75
- var l = f.limited(.limited(5), &.{});
76
- const r = &l.interface;
77
-
78
- var buf: [2]u8 = undefined;
79
- try r.readSliceAll(&buf);
80
- try r.readSliceAll(&buf);
81
- try std.testing.expectError(error.EndOfStream, l.interface.readSliceAll(&buf));
82
- }
83
-
84
- test "end of stream, discard, hit limit exactly" {
85
- var f: Reader = .fixed("i'm dying");
86
- var l = f.limited(.limited(4), &.{});
87
- const r = &l.interface;
88
-
89
- try r.discardAll(2);
90
- try r.discardAll(2);
91
- try std.testing.expectError(error.EndOfStream, l.interface.discardAll(2));
92
- }
93
-
94
- test "end of stream, discard, hit limit after partial read" {
95
- var f: Reader = .fixed("i'm dying");
96
- var l = f.limited(.limited(5), &.{});
97
- const r = &l.interface;
98
-
99
- try r.discardAll(2);
100
- try r.discardAll(2);
101
- try std.testing.expectError(error.EndOfStream, l.interface.discardAll(2));
102
- }
package/std/Io/Reader.zig CHANGED
@@ -400,11 +400,10 @@ pub fn defaultReadVec(r: *Reader, data: [][]u8) Error!usize {
400
400
  .vtable = &.{ .drain = Writer.fixedDrain },
401
401
  };
402
402
  const limit: Limit = .limited(writer.buffer.len - writer.end);
403
- const n = r.vtable.stream(r, &writer, limit) catch |err| switch (err) {
403
+ r.end += r.vtable.stream(r, &writer, limit) catch |err| switch (err) {
404
404
  error.WriteFailed => unreachable,
405
405
  else => |e| return e,
406
406
  };
407
- r.end += n;
408
407
  return 0;
409
408
  }
410
409
 
@@ -449,6 +448,7 @@ pub fn readVecAll(r: *Reader, data: [][]u8) Error!void {
449
448
  /// is returned instead.
450
449
  ///
451
450
  /// See also:
451
+ /// * `peek`
452
452
  /// * `toss`
453
453
  pub fn peek(r: *Reader, n: usize) Error![]u8 {
454
454
  try r.fill(n);
@@ -699,7 +699,7 @@ pub const DelimiterError = error{
699
699
  };
700
700
 
701
701
  /// Returns a slice of the next bytes of buffered data from the stream until
702
- /// `sentinel` is found, advancing the seek position past the sentinel.
702
+ /// `sentinel` is found, advancing the seek position.
703
703
  ///
704
704
  /// Returned slice has a sentinel.
705
705
  ///
@@ -732,7 +732,7 @@ pub fn peekSentinel(r: *Reader, comptime sentinel: u8) DelimiterError![:sentinel
732
732
  }
733
733
 
734
734
  /// Returns a slice of the next bytes of buffered data from the stream until
735
- /// `delimiter` is found, advancing the seek position past the delimiter.
735
+ /// `delimiter` is found, advancing the seek position.
736
736
  ///
737
737
  /// Returned slice includes the delimiter as the last byte.
738
738
  ///
@@ -760,42 +760,31 @@ pub fn takeDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
760
760
  /// * `peekDelimiterExclusive`
761
761
  /// * `takeDelimiterInclusive`
762
762
  pub fn peekDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
763
- {
764
- const contents = r.buffer[0..r.end];
765
- const seek = r.seek;
766
- if (std.mem.indexOfScalarPos(u8, contents, seek, delimiter)) |end| {
767
- @branchHint(.likely);
768
- return contents[seek .. end + 1];
769
- }
763
+ const buffer = r.buffer[0..r.end];
764
+ const seek = r.seek;
765
+ if (std.mem.indexOfScalarPos(u8, buffer, seek, delimiter)) |end| {
766
+ @branchHint(.likely);
767
+ return buffer[seek .. end + 1];
770
768
  }
771
- while (true) {
772
- const content_len = r.end - r.seek;
773
- if (r.buffer.len - content_len == 0) break;
774
- try fillMore(r);
775
- const seek = r.seek;
776
- const contents = r.buffer[0..r.end];
777
- if (std.mem.indexOfScalarPos(u8, contents, seek + content_len, delimiter)) |end| {
778
- return contents[seek .. end + 1];
769
+ // TODO take a parameter for max search length rather than relying on buffer capacity
770
+ try rebase(r, r.buffer.len);
771
+ while (r.buffer.len - r.end != 0) {
772
+ const end_cap = r.buffer[r.end..];
773
+ var writer: Writer = .fixed(end_cap);
774
+ const n = r.vtable.stream(r, &writer, .limited(end_cap.len)) catch |err| switch (err) {
775
+ error.WriteFailed => unreachable,
776
+ else => |e| return e,
777
+ };
778
+ r.end += n;
779
+ if (std.mem.indexOfScalarPos(u8, end_cap[0..n], 0, delimiter)) |end| {
780
+ return r.buffer[0 .. r.end - n + end + 1];
779
781
  }
780
782
  }
781
- // It might or might not be end of stream. There is no more buffer space
782
- // left to disambiguate. If `StreamTooLong` was added to `RebaseError` then
783
- // this logic could be replaced by removing the exit condition from the
784
- // above while loop. That error code would represent when `buffer` capacity
785
- // is too small for an operation, replacing the current use of asserts.
786
- var failing_writer = Writer.failing;
787
- while (r.vtable.stream(r, &failing_writer, .limited(1))) |n| {
788
- assert(n == 0);
789
- } else |err| switch (err) {
790
- error.WriteFailed => return error.StreamTooLong,
791
- error.ReadFailed => |e| return e,
792
- error.EndOfStream => |e| return e,
793
- }
783
+ return error.StreamTooLong;
794
784
  }
795
785
 
796
786
  /// Returns a slice of the next bytes of buffered data from the stream until
797
- /// `delimiter` is found, advancing the seek position up to (but not past)
798
- /// the delimiter.
787
+ /// `delimiter` is found, advancing the seek position.
799
788
  ///
800
789
  /// Returned slice excludes the delimiter. End-of-stream is treated equivalent
801
790
  /// to a delimiter, unless it would result in a length 0 return value, in which
@@ -809,44 +798,20 @@ pub fn peekDelimiterInclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
809
798
  /// Invalidates previously returned values from `peek`.
810
799
  ///
811
800
  /// See also:
812
- /// * `takeDelimiter`
813
801
  /// * `takeDelimiterInclusive`
814
802
  /// * `peekDelimiterExclusive`
815
803
  pub fn takeDelimiterExclusive(r: *Reader, delimiter: u8) DelimiterError![]u8 {
816
- const result = try r.peekDelimiterExclusive(delimiter);
817
- r.toss(result.len);
818
- return result;
819
- }
820
-
821
- /// Returns a slice of the next bytes of buffered data from the stream until
822
- /// `delimiter` is found, advancing the seek position past the delimiter.
823
- ///
824
- /// Returned slice excludes the delimiter. End-of-stream is treated equivalent
825
- /// to a delimiter, unless it would result in a length 0 return value, in which
826
- /// case `null` is returned instead.
827
- ///
828
- /// If the delimiter is not found within a number of bytes matching the
829
- /// capacity of this `Reader`, `error.StreamTooLong` is returned. In
830
- /// such case, the stream state is unmodified as if this function was never
831
- /// called.
832
- ///
833
- /// Invalidates previously returned values from `peek`.
834
- ///
835
- /// See also:
836
- /// * `takeDelimiterInclusive`
837
- /// * `takeDelimiterExclusive`
838
- pub fn takeDelimiter(r: *Reader, delimiter: u8) error{ ReadFailed, StreamTooLong }!?[]u8 {
839
- const inclusive = r.peekDelimiterInclusive(delimiter) catch |err| switch (err) {
804
+ const result = r.peekDelimiterInclusive(delimiter) catch |err| switch (err) {
840
805
  error.EndOfStream => {
841
806
  const remaining = r.buffer[r.seek..r.end];
842
- if (remaining.len == 0) return null;
807
+ if (remaining.len == 0) return error.EndOfStream;
843
808
  r.toss(remaining.len);
844
809
  return remaining;
845
810
  },
846
811
  else => |e| return e,
847
812
  };
848
- r.toss(inclusive.len);
849
- return inclusive[0 .. inclusive.len - 1];
813
+ r.toss(result.len);
814
+ return result[0 .. result.len - 1];
850
815
  }
851
816
 
852
817
  /// Returns a slice of the next bytes of buffered data from the stream until
@@ -1369,9 +1334,6 @@ test peekSentinel {
1369
1334
  var r: Reader = .fixed("ab\nc");
1370
1335
  try testing.expectEqualStrings("ab", try r.peekSentinel('\n'));
1371
1336
  try testing.expectEqualStrings("ab", try r.peekSentinel('\n'));
1372
- r.toss(3);
1373
- try testing.expectError(error.EndOfStream, r.peekSentinel('\n'));
1374
- try testing.expectEqualStrings("c", try r.peek(1));
1375
1337
  }
1376
1338
 
1377
1339
  test takeDelimiterInclusive {
@@ -1386,52 +1348,22 @@ test peekDelimiterInclusive {
1386
1348
  try testing.expectEqualStrings("ab\n", try r.peekDelimiterInclusive('\n'));
1387
1349
  r.toss(3);
1388
1350
  try testing.expectError(error.EndOfStream, r.peekDelimiterInclusive('\n'));
1389
- try testing.expectEqualStrings("c", try r.peek(1));
1390
1351
  }
1391
1352
 
1392
1353
  test takeDelimiterExclusive {
1393
1354
  var r: Reader = .fixed("ab\nc");
1394
-
1395
1355
  try testing.expectEqualStrings("ab", try r.takeDelimiterExclusive('\n'));
1396
- try testing.expectEqualStrings("", try r.takeDelimiterExclusive('\n'));
1397
- try testing.expectEqualStrings("", try r.takeDelimiterExclusive('\n'));
1398
- try testing.expectEqualStrings("\n", try r.take(1));
1399
-
1400
1356
  try testing.expectEqualStrings("c", try r.takeDelimiterExclusive('\n'));
1401
1357
  try testing.expectError(error.EndOfStream, r.takeDelimiterExclusive('\n'));
1402
1358
  }
1403
1359
 
1404
1360
  test peekDelimiterExclusive {
1405
1361
  var r: Reader = .fixed("ab\nc");
1406
-
1407
1362
  try testing.expectEqualStrings("ab", try r.peekDelimiterExclusive('\n'));
1408
1363
  try testing.expectEqualStrings("ab", try r.peekDelimiterExclusive('\n'));
1409
- r.toss(2);
1410
- try testing.expectEqualStrings("", try r.peekDelimiterExclusive('\n'));
1411
- try testing.expectEqualStrings("\n", try r.take(1));
1412
-
1364
+ r.toss(3);
1413
1365
  try testing.expectEqualStrings("c", try r.peekDelimiterExclusive('\n'));
1414
1366
  try testing.expectEqualStrings("c", try r.peekDelimiterExclusive('\n'));
1415
- r.toss(1);
1416
- try testing.expectError(error.EndOfStream, r.peekDelimiterExclusive('\n'));
1417
- }
1418
-
1419
- test takeDelimiter {
1420
- var r: Reader = .fixed("ab\nc\n\nd");
1421
- try testing.expectEqualStrings("ab", (try r.takeDelimiter('\n')).?);
1422
- try testing.expectEqualStrings("c", (try r.takeDelimiter('\n')).?);
1423
- try testing.expectEqualStrings("", (try r.takeDelimiter('\n')).?);
1424
- try testing.expectEqualStrings("d", (try r.takeDelimiter('\n')).?);
1425
- try testing.expectEqual(null, try r.takeDelimiter('\n'));
1426
- try testing.expectEqual(null, try r.takeDelimiter('\n'));
1427
-
1428
- r = .fixed("ab\nc\n\nd\n"); // one trailing newline does not affect behavior
1429
- try testing.expectEqualStrings("ab", (try r.takeDelimiter('\n')).?);
1430
- try testing.expectEqualStrings("c", (try r.takeDelimiter('\n')).?);
1431
- try testing.expectEqualStrings("", (try r.takeDelimiter('\n')).?);
1432
- try testing.expectEqualStrings("d", (try r.takeDelimiter('\n')).?);
1433
- try testing.expectEqual(null, try r.takeDelimiter('\n'));
1434
- try testing.expectEqual(null, try r.takeDelimiter('\n'));
1435
1367
  }
1436
1368
 
1437
1369
  test streamDelimiter {
@@ -1601,18 +1533,6 @@ test "readSliceShort with smaller buffer than Reader" {
1601
1533
  try testing.expectEqualStrings(str, &buf);
1602
1534
  }
1603
1535
 
1604
- test "readSliceShort with indirect reader" {
1605
- var r: Reader = .fixed("HelloFren");
1606
- var ri_buf: [3]u8 = undefined;
1607
- var ri: std.testing.ReaderIndirect = .init(&r, &ri_buf);
1608
- var buf: [5]u8 = undefined;
1609
- try testing.expectEqual(5, try ri.interface.readSliceShort(&buf));
1610
- try testing.expectEqualStrings("Hello", buf[0..5]);
1611
- try testing.expectEqual(4, try ri.interface.readSliceShort(&buf));
1612
- try testing.expectEqualStrings("Fren", buf[0..4]);
1613
- try testing.expectEqual(0, try ri.interface.readSliceShort(&buf));
1614
- }
1615
-
1616
1536
  test readVec {
1617
1537
  var r: Reader = .fixed(std.ascii.letters);
1618
1538
  var flat_buffer: [52]u8 = undefined;
@@ -1722,26 +1642,6 @@ test "takeDelimiterInclusive when it rebases" {
1722
1642
  }
1723
1643
  }
1724
1644
 
1725
- test "takeDelimiterInclusive on an indirect reader when it rebases" {
1726
- const written_line = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
1727
- var buffer: [128]u8 = undefined;
1728
- var tr: std.testing.Reader = .init(&buffer, &.{
1729
- .{ .buffer = written_line[0..4] },
1730
- .{ .buffer = written_line[4..] },
1731
- .{ .buffer = written_line },
1732
- .{ .buffer = written_line },
1733
- .{ .buffer = written_line },
1734
- .{ .buffer = written_line },
1735
- .{ .buffer = written_line },
1736
- });
1737
- var indirect_buffer: [128]u8 = undefined;
1738
- var tri: std.testing.ReaderIndirect = .init(&tr.interface, &indirect_buffer);
1739
- const r = &tri.interface;
1740
- for (0..6) |_| {
1741
- try std.testing.expectEqualStrings(written_line, try r.takeDelimiterInclusive('\n'));
1742
- }
1743
- }
1744
-
1745
1645
  test "takeStruct and peekStruct packed" {
1746
1646
  var r: Reader = .fixed(&.{ 0b11110000, 0b00110011 });
1747
1647
  const S = packed struct(u16) { a: u2, b: u6, c: u7, d: u1 };