authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-30 16:09:11-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-30 16:09:11-04:00
logea58f4a5a95662637d2142727a0452542bcdb196
treed72b41fea06f8526e899014fd10c2bf9d1a4d759
parentb082cd4580890190218f876bf28816b4878ae85c

run zig fmt on the codebase


48 files changed, 140 insertions(+), 140 deletions(-)

src-self-hosted/main.zig+2-2
......@@ -41,7 +41,7 @@ const usage =
4141
4242const Command = struct {
4343 name: []const u8,
44 exec: fn(&Allocator, []const []const u8) error!void,
44 exec: fn (&Allocator, []const []const u8) error!void,
4545};
4646
4747pub fn main() !void {
......@@ -862,7 +862,7 @@ fn cmdRun(allocator: &Allocator, args: []const []const u8) !void {
862862 for (args) |argv, i| {
863863 if (mem.eql(u8, argv, "--")) {
864864 compile_args = args[0..i];
865 runtime_args = args[i + 1..];
865 runtime_args = args[i + 1 ..];
866866 break;
867867 }
868868 }
std/array_list.zig+3-3
......@@ -71,7 +71,7 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
7171 try l.ensureCapacity(l.len + 1);
7272 l.len += 1;
7373
74 mem.copy(T, l.items[n + 1..l.len], l.items[n..l.len - 1]);
74 mem.copy(T, l.items[n + 1 .. l.len], l.items[n .. l.len - 1]);
7575 l.items[n] = item.*;
7676 }
7777
......@@ -79,8 +79,8 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
7979 try l.ensureCapacity(l.len + items.len);
8080 l.len += items.len;
8181
82 mem.copy(T, l.items[n + items.len..l.len], l.items[n..l.len - items.len]);
83 mem.copy(T, l.items[n..n + items.len], items);
82 mem.copy(T, l.items[n + items.len .. l.len], l.items[n .. l.len - items.len]);
83 mem.copy(T, l.items[n .. n + items.len], items);
8484 }
8585
8686 pub fn append(l: &Self, item: &const T) !void {
std/base64.zig+1-1
......@@ -450,7 +450,7 @@ fn testError(encoded: []const u8, expected_err: error) !void {
450450fn testOutputTooSmallError(encoded: []const u8) !void {
451451 const standard_decoder_ignore_space = Base64DecoderWithIgnore.init(standard_alphabet_chars, standard_pad_char, " ");
452452 var buffer: [0x100]u8 = undefined;
453 var decoded = buffer[0..calcDecodedSizeExactUnsafe(encoded, standard_pad_char) - 1];
453 var decoded = buffer[0 .. calcDecodedSizeExactUnsafe(encoded, standard_pad_char) - 1];
454454 if (standard_decoder_ignore_space.decode(decoded, encoded)) |_| {
455455 return error.ExpectedError;
456456 } else |err| if (err != error.OutputTooSmall) return err;
std/build.zig+2-2
......@@ -1912,12 +1912,12 @@ pub const RemoveDirStep = struct {
19121912
19131913pub const Step = struct {
19141914 name: []const u8,
1915 makeFn: fn(self: &Step) error!void,
1915 makeFn: fn (self: &Step) error!void,
19161916 dependencies: ArrayList(&Step),
19171917 loop_flag: bool,
19181918 done_flag: bool,
19191919
1920 pub fn init(name: []const u8, allocator: &Allocator, makeFn: fn(&Step) error!void) Step {
1920 pub fn init(name: []const u8, allocator: &Allocator, makeFn: fn (&Step) error!void) Step {
19211921 return Step{
19221922 .name = name,
19231923 .makeFn = makeFn,
std/c/darwin.zig+1-1
......@@ -60,7 +60,7 @@ pub const sigset_t = u32;
6060
6161/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
6262pub const Sigaction = extern struct {
63 handler: extern fn(c_int) void,
63 handler: extern fn (c_int) void,
6464 sa_mask: sigset_t,
6565 sa_flags: c_int,
6666};
std/c/index.zig+1-1
......@@ -52,7 +52,7 @@ pub extern "c" fn realloc(&c_void, usize) ?&c_void;
5252pub extern "c" fn free(&c_void) void;
5353pub extern "c" fn posix_memalign(memptr: &&c_void, alignment: usize, size: usize) c_int;
5454
55pub extern "pthread" fn pthread_create(noalias newthread: &pthread_t, noalias attr: ?&const pthread_attr_t, start_routine: extern fn(?&c_void) ?&c_void, noalias arg: ?&c_void) c_int;
55pub extern "pthread" fn pthread_create(noalias newthread: &pthread_t, noalias attr: ?&const pthread_attr_t, start_routine: extern fn (?&c_void) ?&c_void, noalias arg: ?&c_void) c_int;
5656pub extern "pthread" fn pthread_attr_init(attr: &pthread_attr_t) c_int;
5757pub extern "pthread" fn pthread_attr_setstack(attr: &pthread_attr_t, stackaddr: &c_void, stacksize: usize) c_int;
5858pub extern "pthread" fn pthread_attr_destroy(attr: &pthread_attr_t) c_int;
std/crypto/blake2.zig+8-8
......@@ -105,7 +105,7 @@ fn Blake2s(comptime out_len: usize) type {
105105 // Full middle blocks.
106106 while (off + 64 <= b.len) : (off += 64) {
107107 d.t += 64;
108 d.round(b[off..off + 64], false);
108 d.round(b[off .. off + 64], false);
109109 }
110110
111111 // Copy any remainder for next pass.
......@@ -120,10 +120,10 @@ fn Blake2s(comptime out_len: usize) type {
120120 d.t += d.buf_len;
121121 d.round(d.buf[0..], true);
122122
123 const rr = d.h[0..out_len / 32];
123 const rr = d.h[0 .. out_len / 32];
124124
125125 for (rr) |s, j| {
126 mem.writeInt(out[4 * j..4 * j + 4], s, builtin.Endian.Little);
126 mem.writeInt(out[4 * j .. 4 * j + 4], s, builtin.Endian.Little);
127127 }
128128 }
129129
......@@ -134,7 +134,7 @@ fn Blake2s(comptime out_len: usize) type {
134134 var v: [16]u32 = undefined;
135135
136136 for (m) |*r, i| {
137 r.* = mem.readIntLE(u32, b[4 * i..4 * i + 4]);
137 r.* = mem.readIntLE(u32, b[4 * i .. 4 * i + 4]);
138138 }
139139
140140 var k: usize = 0;
......@@ -340,7 +340,7 @@ fn Blake2b(comptime out_len: usize) type {
340340 // Full middle blocks.
341341 while (off + 128 <= b.len) : (off += 128) {
342342 d.t += 128;
343 d.round(b[off..off + 128], false);
343 d.round(b[off .. off + 128], false);
344344 }
345345
346346 // Copy any remainder for next pass.
......@@ -353,10 +353,10 @@ fn Blake2b(comptime out_len: usize) type {
353353 d.t += d.buf_len;
354354 d.round(d.buf[0..], true);
355355
356 const rr = d.h[0..out_len / 64];
356 const rr = d.h[0 .. out_len / 64];
357357
358358 for (rr) |s, j| {
359 mem.writeInt(out[8 * j..8 * j + 8], s, builtin.Endian.Little);
359 mem.writeInt(out[8 * j .. 8 * j + 8], s, builtin.Endian.Little);
360360 }
361361 }
362362
......@@ -367,7 +367,7 @@ fn Blake2b(comptime out_len: usize) type {
367367 var v: [16]u64 = undefined;
368368
369369 for (m) |*r, i| {
370 r.* = mem.readIntLE(u64, b[8 * i..8 * i + 8]);
370 r.* = mem.readIntLE(u64, b[8 * i .. 8 * i + 8]);
371371 }
372372
373373 var k: usize = 0;
std/crypto/md5.zig+2-2
......@@ -73,7 +73,7 @@ pub const Md5 = struct {
7373
7474 // Full middle blocks.
7575 while (off + 64 <= b.len) : (off += 64) {
76 d.round(b[off..off + 64]);
76 d.round(b[off .. off + 64]);
7777 }
7878
7979 // Copy any remainder for next pass.
......@@ -112,7 +112,7 @@ pub const Md5 = struct {
112112 d.round(d.buf[0..]);
113113
114114 for (d.s) |s, j| {
115 mem.writeInt(out[4 * j..4 * j + 4], s, builtin.Endian.Little);
115 mem.writeInt(out[4 * j .. 4 * j + 4], s, builtin.Endian.Little);
116116 }
117117 }
118118
std/crypto/sha1.zig+2-2
......@@ -73,7 +73,7 @@ pub const Sha1 = struct {
7373
7474 // Full middle blocks.
7575 while (off + 64 <= b.len) : (off += 64) {
76 d.round(b[off..off + 64]);
76 d.round(b[off .. off + 64]);
7777 }
7878
7979 // Copy any remainder for next pass.
......@@ -111,7 +111,7 @@ pub const Sha1 = struct {
111111 d.round(d.buf[0..]);
112112
113113 for (d.s) |s, j| {
114 mem.writeInt(out[4 * j..4 * j + 4], s, builtin.Endian.Big);
114 mem.writeInt(out[4 * j .. 4 * j + 4], s, builtin.Endian.Big);
115115 }
116116 }
117117
std/crypto/sha2.zig+6-6
......@@ -126,7 +126,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
126126
127127 // Full middle blocks.
128128 while (off + 64 <= b.len) : (off += 64) {
129 d.round(b[off..off + 64]);
129 d.round(b[off .. off + 64]);
130130 }
131131
132132 // Copy any remainder for next pass.
......@@ -164,10 +164,10 @@ fn Sha2_32(comptime params: Sha2Params32) type {
164164 d.round(d.buf[0..]);
165165
166166 // May truncate for possible 224 output
167 const rr = d.s[0..params.out_len / 32];
167 const rr = d.s[0 .. params.out_len / 32];
168168
169169 for (rr) |s, j| {
170 mem.writeInt(out[4 * j..4 * j + 4], s, builtin.Endian.Big);
170 mem.writeInt(out[4 * j .. 4 * j + 4], s, builtin.Endian.Big);
171171 }
172172 }
173173
......@@ -467,7 +467,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
467467
468468 // Full middle blocks.
469469 while (off + 128 <= b.len) : (off += 128) {
470 d.round(b[off..off + 128]);
470 d.round(b[off .. off + 128]);
471471 }
472472
473473 // Copy any remainder for next pass.
......@@ -505,10 +505,10 @@ fn Sha2_64(comptime params: Sha2Params64) type {
505505 d.round(d.buf[0..]);
506506
507507 // May truncate for possible 384 output
508 const rr = d.s[0..params.out_len / 64];
508 const rr = d.s[0 .. params.out_len / 64];
509509
510510 for (rr) |s, j| {
511 mem.writeInt(out[8 * j..8 * j + 8], s, builtin.Endian.Big);
511 mem.writeInt(out[8 * j .. 8 * j + 8], s, builtin.Endian.Big);
512512 }
513513 }
514514
std/crypto/sha3.zig+4-4
......@@ -46,7 +46,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
4646
4747 // absorb
4848 while (len >= rate) {
49 for (d.s[offset..offset + rate]) |*r, i|
49 for (d.s[offset .. offset + rate]) |*r, i|
5050 r.* ^= b[ip..][i];
5151
5252 keccak_f(1600, d.s[0..]);
......@@ -57,7 +57,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
5757 offset = 0;
5858 }
5959
60 for (d.s[offset..offset + len]) |*r, i|
60 for (d.s[offset .. offset + len]) |*r, i|
6161 r.* ^= b[ip..][i];
6262
6363 d.offset = offset + len;
......@@ -193,7 +193,7 @@ fn keccak_f(comptime F: usize, d: []u8) void {
193193 var c = []const u64{0} ** 5;
194194
195195 for (s) |*r, i| {
196 r.* = mem.readIntLE(u64, d[8 * i..8 * i + 8]);
196 r.* = mem.readIntLE(u64, d[8 * i .. 8 * i + 8]);
197197 }
198198
199199 comptime var x: usize = 0;
......@@ -240,7 +240,7 @@ fn keccak_f(comptime F: usize, d: []u8) void {
240240 }
241241
242242 for (s) |r, i| {
243 mem.writeInt(d[8 * i..8 * i + 8], r, builtin.Endian.Little);
243 mem.writeInt(d[8 * i .. 8 * i + 8], r, builtin.Endian.Little);
244244 }
245245}
246246
std/crypto/test.zig+1-1
......@@ -14,7 +14,7 @@ pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, inpu
1414pub fn assertEqual(comptime expected: []const u8, input: []const u8) void {
1515 var expected_bytes: [expected.len / 2]u8 = undefined;
1616 for (expected_bytes) |*r, i| {
17 r.* = fmt.parseInt(u8, expected[2 * i..2 * i + 2], 16) catch unreachable;
17 r.* = fmt.parseInt(u8, expected[2 * i .. 2 * i + 2], 16) catch unreachable;
1818 }
1919
2020 debug.assert(mem.eql(u8, expected_bytes, input));
std/event.zig+2-2
......@@ -6,7 +6,7 @@ const mem = std.mem;
66const posix = std.os.posix;
77
88pub const TcpServer = struct {
9 handleRequestFn: async<&mem.Allocator> fn(&TcpServer, &const std.net.Address, &const std.os.File) void,
9 handleRequestFn: async<&mem.Allocator> fn (&TcpServer, &const std.net.Address, &const std.os.File) void,
1010
1111 loop: &Loop,
1212 sockfd: i32,
......@@ -32,7 +32,7 @@ pub const TcpServer = struct {
3232 };
3333 }
3434
35 pub fn listen(self: &TcpServer, address: &const std.net.Address, handleRequestFn: async<&mem.Allocator> fn(&TcpServer, &const std.net.Address, &const std.os.File) void) !void {
35 pub fn listen(self: &TcpServer, address: &const std.net.Address, handleRequestFn: async<&mem.Allocator> fn (&TcpServer, &const std.net.Address, &const std.os.File) void) !void {
3636 self.handleRequestFn = handleRequestFn;
3737
3838 try std.os.posixBind(self.sockfd, &address.os_addr);
std/fmt/errol/index.zig+2-2
......@@ -60,7 +60,7 @@ pub fn roundToPrecision(float_decimal: &FloatDecimal, precision: usize, mode: Ro
6060
6161 // Re-size the buffer to use the reserved leading byte.
6262 const one_before = @intToPtr(&u8, @ptrToInt(&float_decimal.digits[0]) - 1);
63 float_decimal.digits = one_before[0..float_decimal.digits.len + 1];
63 float_decimal.digits = one_before[0 .. float_decimal.digits.len + 1];
6464 float_decimal.digits[0] = '1';
6565 return;
6666 }
......@@ -84,7 +84,7 @@ pub fn errol3(value: f64, buffer: []u8) FloatDecimal {
8484 const i = tableLowerBound(bits);
8585 if (i < enum3.len and enum3[i] == bits) {
8686 const data = enum3_data[i];
87 const digits = buffer[1..data.str.len + 1];
87 const digits = buffer[1 .. data.str.len + 1];
8888 mem.copy(u8, digits, data.str);
8989 return FloatDecimal{
9090 .digits = digits,
std/fmt/index.zig+13-13
......@@ -11,7 +11,7 @@ const max_int_digits = 65;
1111/// Renders fmt string with args, calling output with slices of bytes.
1212/// If `output` returns an error, the error is returned from `format` and
1313/// `output` is not called again.
14pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void, comptime fmt: []const u8, args: ...) Errors!void {
14pub fn format(context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void, comptime fmt: []const u8, args: ...) Errors!void {
1515 const State = enum {
1616 Start,
1717 OpenBrace,
......@@ -268,7 +268,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
268268 }
269269}
270270
271pub fn formatValue(value: var, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
271pub fn formatValue(value: var, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
272272 const T = @typeOf(value);
273273 switch (@typeId(T)) {
274274 builtin.TypeId.Int => {
......@@ -317,11 +317,11 @@ pub fn formatValue(value: var, context: var, comptime Errors: type, output: fn(@
317317 }
318318}
319319
320pub fn formatAsciiChar(c: u8, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
320pub fn formatAsciiChar(c: u8, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
321321 return output(context, (&c)[0..1]);
322322}
323323
324pub fn formatBuf(buf: []const u8, width: usize, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
324pub fn formatBuf(buf: []const u8, width: usize, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
325325 try output(context, buf);
326326
327327 var leftover_padding = if (width > buf.len) (width - buf.len) else return;
......@@ -334,7 +334,7 @@ pub fn formatBuf(buf: []const u8, width: usize, context: var, comptime Errors: t
334334// Print a float in scientific notation to the specified precision. Null uses full precision.
335335// It should be the case that every full precision, printed value can be re-parsed back to the
336336// same type unambiguously.
337pub fn formatFloatScientific(value: var, maybe_precision: ?usize, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
337pub fn formatFloatScientific(value: var, maybe_precision: ?usize, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
338338 var x = f64(value);
339339
340340 // Errol doesn't handle these special cases.
......@@ -423,7 +423,7 @@ pub fn formatFloatScientific(value: var, maybe_precision: ?usize, context: var,
423423
424424// Print a float of the format x.yyyyy where the number of y is specified by the precision argument.
425425// By default floats are printed at full precision (no rounding).
426pub fn formatFloatDecimal(value: var, maybe_precision: ?usize, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
426pub fn formatFloatDecimal(value: var, maybe_precision: ?usize, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
427427 var x = f64(value);
428428
429429 // Errol doesn't handle these special cases.
......@@ -512,7 +512,7 @@ pub fn formatFloatDecimal(value: var, maybe_precision: ?usize, context: var, com
512512 // Remaining fractional portion, zero-padding if insufficient.
513513 debug.assert(precision >= printed);
514514 if (num_digits_whole_no_pad + precision - printed < float_decimal.digits.len) {
515 try output(context, float_decimal.digits[num_digits_whole_no_pad..num_digits_whole_no_pad + precision - printed]);
515 try output(context, float_decimal.digits[num_digits_whole_no_pad .. num_digits_whole_no_pad + precision - printed]);
516516 return;
517517 } else {
518518 try output(context, float_decimal.digits[num_digits_whole_no_pad..]);
......@@ -568,7 +568,7 @@ pub fn formatBytes(
568568 comptime radix: usize,
569569 context: var,
570570 comptime Errors: type,
571 output: fn(@typeOf(context), []const u8) Errors!void,
571 output: fn (@typeOf(context), []const u8) Errors!void,
572572) Errors!void {
573573 if (value == 0) {
574574 return output(context, "0B");
......@@ -604,7 +604,7 @@ pub fn formatInt(
604604 width: usize,
605605 context: var,
606606 comptime Errors: type,
607 output: fn(@typeOf(context), []const u8) Errors!void,
607 output: fn (@typeOf(context), []const u8) Errors!void,
608608) Errors!void {
609609 if (@typeOf(value).is_signed) {
610610 return formatIntSigned(value, base, uppercase, width, context, Errors, output);
......@@ -613,7 +613,7 @@ pub fn formatInt(
613613 }
614614}
615615
616fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
616fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
617617 const uint = @IntType(false, @typeOf(value).bit_count);
618618 if (value < 0) {
619619 const minus_sign: u8 = '-';
......@@ -632,7 +632,7 @@ fn formatIntSigned(value: var, base: u8, uppercase: bool, width: usize, context:
632632 }
633633}
634634
635fn formatIntUnsigned(value: var, base: u8, uppercase: bool, width: usize, context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8) Errors!void) Errors!void {
635fn formatIntUnsigned(value: var, base: u8, uppercase: bool, width: usize, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void {
636636 // max_int_digits accounts for the minus sign. when printing an unsigned
637637 // number we don't need to do that.
638638 var buf: [max_int_digits - 1]u8 = undefined;
......@@ -661,7 +661,7 @@ fn formatIntUnsigned(value: var, base: u8, uppercase: bool, width: usize, contex
661661 mem.set(u8, buf[0..index], '0');
662662 return output(context, buf);
663663 } else {
664 const padded_buf = buf[index - padding..];
664 const padded_buf = buf[index - padding ..];
665665 mem.set(u8, padded_buf[0..padding], '0');
666666 return output(context, padded_buf);
667667 }
......@@ -760,7 +760,7 @@ fn bufPrintWrite(context: &BufPrintContext, bytes: []const u8) !void {
760760pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) ![]u8 {
761761 var context = BufPrintContext{ .remaining = buf };
762762 try format(&context, error{BufferTooSmall}, bufPrintWrite, fmt, args);
763 return buf[0..buf.len - context.remaining.len];
763 return buf[0 .. buf.len - context.remaining.len];
764764}
765765
766766pub fn allocPrint(allocator: &mem.Allocator, comptime fmt: []const u8, args: ...) ![]u8 {
std/hash/crc.zig+1-1
......@@ -61,7 +61,7 @@ pub fn Crc32WithPoly(comptime poly: u32) type {
6161 pub fn update(self: &Self, input: []const u8) void {
6262 var i: usize = 0;
6363 while (i + 8 <= input.len) : (i += 8) {
64 const p = input[i..i + 8];
64 const p = input[i .. i + 8];
6565
6666 // Unrolling this way gives ~50Mb/s increase
6767 self.crc ^= (u32(p[0]) << 0);
std/hash/siphash.zig+1-1
......@@ -76,7 +76,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
7676
7777 // Full middle blocks.
7878 while (off + 8 <= b.len) : (off += 8) {
79 d.round(b[off..off + 8]);
79 d.round(b[off .. off + 8]);
8080 }
8181
8282 // Remainder for next pass.
std/hash_map.zig+1-1
......@@ -9,7 +9,7 @@ const builtin = @import("builtin");
99const want_modification_safety = builtin.mode != builtin.Mode.ReleaseFast;
1010const debug_u32 = if (want_modification_safety) u32 else void;
1111
12pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn(key: K) u32, comptime eql: fn(a: K, b: K) bool) type {
12pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u32, comptime eql: fn (a: K, b: K) bool) type {
1313 return struct {
1414 entries: []Entry,
1515 size: usize,
std/io.zig+3-3
......@@ -82,7 +82,7 @@ pub fn InStream(comptime ReadError: type) type {
8282 /// Return the number of bytes read. If the number read is smaller than buf.len, it
8383 /// means the stream reached the end. Reaching the end of a stream is not an error
8484 /// condition.
85 readFn: fn(self: &Self, buffer: []u8) Error!usize,
85 readFn: fn (self: &Self, buffer: []u8) Error!usize,
8686
8787 /// Replaces `buffer` contents by reading from the stream until it is finished.
8888 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and
......@@ -208,7 +208,7 @@ pub fn OutStream(comptime WriteError: type) type {
208208 const Self = this;
209209 pub const Error = WriteError;
210210
211 writeFn: fn(self: &Self, bytes: []const u8) Error!void,
211 writeFn: fn (self: &Self, bytes: []const u8) Error!void,
212212
213213 pub fn print(self: &Self, comptime format: []const u8, args: ...) !void {
214214 return std.fmt.format(self, Error, self.writeFn, format, args);
......@@ -369,7 +369,7 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr
369369 while (src_index < bytes.len) {
370370 const dest_space_left = self.buffer.len - self.index;
371371 const copy_amt = math.min(dest_space_left, bytes.len - src_index);
372 mem.copy(u8, self.buffer[self.index..], bytes[src_index..src_index + copy_amt]);
372 mem.copy(u8, self.buffer[self.index..], bytes[src_index .. src_index + copy_amt]);
373373 self.index += copy_amt;
374374 assert(self.index <= self.buffer.len);
375375 if (self.index == self.buffer.len) {
std/io_test.zig+2-2
......@@ -41,8 +41,8 @@ test "write a file, read it, then delete it" {
4141 defer allocator.free(contents);
4242
4343 assert(mem.eql(u8, contents[0.."begin".len], "begin"));
44 assert(mem.eql(u8, contents["begin".len..contents.len - "end".len], data));
45 assert(mem.eql(u8, contents[contents.len - "end".len..], "end"));
44 assert(mem.eql(u8, contents["begin".len .. contents.len - "end".len], data));
45 assert(mem.eql(u8, contents[contents.len - "end".len ..], "end"));
4646 }
4747 try os.deleteFile(allocator, tmp_file_name);
4848}
std/json.zig+1-1
......@@ -77,7 +77,7 @@ pub const Token = struct {
7777
7878 // Slice into the underlying input string.
7979 pub fn slice(self: &const Token, input: []const u8, i: usize) []const u8 {
80 return input[i + self.offset - self.count..i + self.offset];
80 return input[i + self.offset - self.count .. i + self.offset];
8181 }
8282};
8383
std/mem.zig+6-6
......@@ -13,7 +13,7 @@ pub const Allocator = struct {
1313 /// The returned newly allocated memory is undefined.
1414 /// `alignment` is guaranteed to be >= 1
1515 /// `alignment` is guaranteed to be a power of 2
16 allocFn: fn(self: &Allocator, byte_count: usize, alignment: u29) Error![]u8,
16 allocFn: fn (self: &Allocator, byte_count: usize, alignment: u29) Error![]u8,
1717
1818 /// If `new_byte_count > old_mem.len`:
1919 /// * `old_mem.len` is the same as what was returned from allocFn or reallocFn.
......@@ -26,10 +26,10 @@ pub const Allocator = struct {
2626 /// The returned newly allocated memory is undefined.
2727 /// `alignment` is guaranteed to be >= 1
2828 /// `alignment` is guaranteed to be a power of 2
29 reallocFn: fn(self: &Allocator, old_mem: []u8, new_byte_count: usize, alignment: u29) Error![]u8,
29 reallocFn: fn (self: &Allocator, old_mem: []u8, new_byte_count: usize, alignment: u29) Error![]u8,
3030
3131 /// Guaranteed: `old_mem.len` is the same as what was returned from `allocFn` or `reallocFn`
32 freeFn: fn(self: &Allocator, old_mem: []u8) void,
32 freeFn: fn (self: &Allocator, old_mem: []u8) void,
3333
3434 fn create(self: &Allocator, comptime T: type) !&T {
3535 if (@sizeOf(T) == 0) return &{};
......@@ -282,7 +282,7 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us
282282
283283 var i: usize = haystack.len - needle.len;
284284 while (true) : (i -= 1) {
285 if (mem.eql(T, haystack[i..i + needle.len], needle)) return i;
285 if (mem.eql(T, haystack[i .. i + needle.len], needle)) return i;
286286 if (i == 0) return null;
287287 }
288288}
......@@ -294,7 +294,7 @@ pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, nee
294294 var i: usize = start_index;
295295 const end = haystack.len - needle.len;
296296 while (i <= end) : (i += 1) {
297 if (eql(T, haystack[i..i + needle.len], needle)) return i;
297 if (eql(T, haystack[i .. i + needle.len], needle)) return i;
298298 }
299299 return null;
300300}
......@@ -444,7 +444,7 @@ test "mem.startsWith" {
444444}
445445
446446pub fn endsWith(comptime T: type, haystack: []const T, needle: []const T) bool {
447 return if (needle.len > haystack.len) false else eql(T, haystack[haystack.len - needle.len..], needle);
447 return if (needle.len > haystack.len) false else eql(T, haystack[haystack.len - needle.len ..], needle);
448448}
449449
450450test "mem.endsWith" {
std/os/darwin.zig+3-3
......@@ -437,7 +437,7 @@ pub fn sigaction(sig: u5, noalias act: &const Sigaction, noalias oact: ?&Sigacti
437437 assert(sig != SIGKILL);
438438 assert(sig != SIGSTOP);
439439 var cact = c.Sigaction{
440 .handler = @ptrCast(extern fn(c_int) void, act.handler),
440 .handler = @ptrCast(extern fn (c_int) void, act.handler),
441441 .sa_flags = @bitCast(c_int, act.flags),
442442 .sa_mask = act.mask,
443443 };
......@@ -448,7 +448,7 @@ pub fn sigaction(sig: u5, noalias act: &const Sigaction, noalias oact: ?&Sigacti
448448 }
449449 if (oact) |old| {
450450 old.* = Sigaction{
451 .handler = @ptrCast(extern fn(i32) void, coact.handler),
451 .handler = @ptrCast(extern fn (i32) void, coact.handler),
452452 .flags = @bitCast(u32, coact.sa_flags),
453453 .mask = coact.sa_mask,
454454 };
......@@ -468,7 +468,7 @@ pub const sockaddr = c.sockaddr;
468468
469469/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
470470pub const Sigaction = struct {
471 handler: extern fn(i32) void,
471 handler: extern fn (i32) void,
472472 mask: sigset_t,
473473 flags: u32,
474474};
std/os/index.zig+8-8
......@@ -399,7 +399,7 @@ pub fn createNullDelimitedEnvMap(allocator: &Allocator, env_map: &const BufMap)
399399
400400pub fn freeNullDelimitedEnvMap(allocator: &Allocator, envp_buf: []?&u8) void {
401401 for (envp_buf) |env| {
402 const env_buf = if (env) |ptr| ptr[0..cstr.len(ptr) + 1] else break;
402 const env_buf = if (env) |ptr| ptr[0 .. cstr.len(ptr) + 1] else break;
403403 allocator.free(env_buf);
404404 }
405405 allocator.free(envp_buf);
......@@ -449,7 +449,7 @@ pub fn posixExecve(argv: []const []const u8, env_map: &const BufMap, allocator:
449449 while (it.next()) |search_path| {
450450 mem.copy(u8, path_buf, search_path);
451451 path_buf[search_path.len] = '/';
452 mem.copy(u8, path_buf[search_path.len + 1..], exe_path);
452 mem.copy(u8, path_buf[search_path.len + 1 ..], exe_path);
453453 path_buf[search_path.len + exe_path.len + 1] = 0;
454454 err = posix.getErrno(posix.execve(path_buf.ptr, argv_buf.ptr, envp_buf.ptr));
455455 assert(err > 0);
......@@ -532,7 +532,7 @@ pub fn getEnvMap(allocator: &Allocator) !BufMap {
532532
533533 var end_i: usize = line_i;
534534 while (ptr[end_i] != 0) : (end_i += 1) {}
535 const value = ptr[line_i + 1..end_i];
535 const value = ptr[line_i + 1 .. end_i];
536536
537537 try result.set(key, value);
538538 }
......@@ -549,7 +549,7 @@ pub fn getEnvPosix(key: []const u8) ?[]const u8 {
549549
550550 var end_i: usize = line_i;
551551 while (ptr[end_i] != 0) : (end_i += 1) {}
552 const this_value = ptr[line_i + 1..end_i];
552 const this_value = ptr[line_i + 1 .. end_i];
553553
554554 return this_value;
555555 }
......@@ -691,7 +691,7 @@ pub fn symLinkPosix(allocator: &Allocator, existing_path: []const u8, new_path:
691691 mem.copy(u8, existing_buf, existing_path);
692692 existing_buf[existing_path.len] = 0;
693693
694 const new_buf = full_buf[existing_path.len + 1..];
694 const new_buf = full_buf[existing_path.len + 1 ..];
695695 mem.copy(u8, new_buf, new_path);
696696 new_buf[new_path.len] = 0;
697697
......@@ -735,7 +735,7 @@ pub fn atomicSymLink(allocator: &Allocator, existing_path: []const u8, new_path:
735735 tmp_path[dirname.len] = os.path.sep;
736736 while (true) {
737737 try getRandomBytes(rand_buf[0..]);
738 b64_fs_encoder.encode(tmp_path[dirname.len + 1..], rand_buf);
738 b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], rand_buf);
739739
740740 if (symLink(allocator, existing_path, tmp_path)) {
741741 return rename(allocator, tmp_path, new_path);
......@@ -914,7 +914,7 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8)
914914 mem.copy(u8, old_buf, old_path);
915915 old_buf[old_path.len] = 0;
916916
917 const new_buf = full_buf[old_path.len + 1..];
917 const new_buf = full_buf[old_path.len + 1 ..];
918918 mem.copy(u8, new_buf, new_path);
919919 new_buf[new_path.len] = 0;
920920
......@@ -1141,7 +1141,7 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!
11411141 const full_entry_path = full_entry_buf.toSlice();
11421142 mem.copy(u8, full_entry_path, full_path);
11431143 full_entry_path[full_path.len] = '/';
1144 mem.copy(u8, full_entry_path[full_path.len + 1..], entry.name);
1144 mem.copy(u8, full_entry_path[full_path.len + 1 ..], entry.name);
11451145
11461146 try deleteTree(allocator, full_entry_path);
11471147 }
std/os/linux/index.zig+7-7
......@@ -939,7 +939,7 @@ pub fn sigaction(sig: u6, noalias act: &const Sigaction, noalias oact: ?&Sigacti
939939 .handler = act.handler,
940940 .flags = act.flags | SA_RESTORER,
941941 .mask = undefined,
942 .restorer = @ptrCast(extern fn() void, restore_rt),
942 .restorer = @ptrCast(extern fn () void, restore_rt),
943943 };
944944 var ksa_old: k_sigaction = undefined;
945945 @memcpy(@ptrCast(&u8, &ksa.mask), @ptrCast(&const u8, &act.mask), 8);
......@@ -962,22 +962,22 @@ const all_mask = []usize{@maxValue(usize)};
962962const app_mask = []usize{0xfffffffc7fffffff};
963963
964964const k_sigaction = extern struct {
965 handler: extern fn(i32) void,
965 handler: extern fn (i32) void,
966966 flags: usize,
967 restorer: extern fn() void,
967 restorer: extern fn () void,
968968 mask: [2]u32,
969969};
970970
971971/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
972972pub const Sigaction = struct {
973 handler: extern fn(i32) void,
973 handler: extern fn (i32) void,
974974 mask: sigset_t,
975975 flags: u32,
976976};
977977
978pub const SIG_ERR = @intToPtr(extern fn(i32) void, @maxValue(usize));
979pub const SIG_DFL = @intToPtr(extern fn(i32) void, 0);
980pub const SIG_IGN = @intToPtr(extern fn(i32) void, 1);
978pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize));
979pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
980pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
981981pub const empty_sigset = []usize{0} ** sigset_t.len;
982982
983983pub fn raise(sig: i32) usize {
std/os/linux/x86_64.zig+1-1
......@@ -463,7 +463,7 @@ pub fn syscall6(
463463}
464464
465465/// This matches the libc clone function.
466pub extern fn clone(func: extern fn(arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: &i32, tls: usize, ctid: &i32) usize;
466pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: &i32, tls: usize, ctid: &i32) usize;
467467
468468pub nakedcc fn restore_rt() void {
469469 return asm volatile ("syscall"
std/os/path.zig+3-3
......@@ -793,7 +793,7 @@ pub fn basenamePosix(path: []const u8) []const u8 {
793793 start_index -= 1;
794794 }
795795
796 return path[start_index + 1..end_index];
796 return path[start_index + 1 .. end_index];
797797}
798798
799799pub fn basenameWindows(path: []const u8) []const u8 {
......@@ -825,7 +825,7 @@ pub fn basenameWindows(path: []const u8) []const u8 {
825825 start_index -= 1;
826826 }
827827
828 return path[start_index + 1..end_index];
828 return path[start_index + 1 .. end_index];
829829}
830830
831831test "os.path.basename" {
......@@ -999,7 +999,7 @@ pub fn relativePosix(allocator: &Allocator, from: []const u8, to: []const u8) ![
999999 }
10001000 if (to_rest.len == 0) {
10011001 // shave off the trailing slash
1002 return result[0..result_index - 1];
1002 return result[0 .. result_index - 1];
10031003 }
10041004
10051005 mem.copy(u8, result[result_index..], to_rest);
std/os/windows/index.zig+1-1
......@@ -369,7 +369,7 @@ pub const HEAP_CREATE_ENABLE_EXECUTE = 0x00040000;
369369pub const HEAP_GENERATE_EXCEPTIONS = 0x00000004;
370370pub const HEAP_NO_SERIALIZE = 0x00000001;
371371
372pub const PTHREAD_START_ROUTINE = extern fn(LPVOID) DWORD;
372pub const PTHREAD_START_ROUTINE = extern fn (LPVOID) DWORD;
373373pub const LPTHREAD_START_ROUTINE = PTHREAD_START_ROUTINE;
374374
375375test "import" {
std/os/windows/util.zig+1-1
......@@ -73,7 +73,7 @@ pub fn windowsIsCygwinPty(handle: windows.HANDLE) bool {
7373 }
7474
7575 const name_info = @ptrCast(&const windows.FILE_NAME_INFO, &name_info_bytes[0]);
76 const name_bytes = name_info_bytes[size..size + usize(name_info.FileNameLength)];
76 const name_bytes = name_info_bytes[size .. size + usize(name_info.FileNameLength)];
7777 const name_wide = ([]u16)(name_bytes);
7878 return mem.indexOf(u16, name_wide, []u16{ 'm', 's', 'y', 's', '-' }) != null or
7979 mem.indexOf(u16, name_wide, []u16{ '-', 'p', 't', 'y' }) != null;
std/os/zen.zig+1-1
......@@ -153,7 +153,7 @@ pub fn map(v_addr: usize, p_addr: usize, size: usize, writable: bool) bool {
153153 return syscall4(Syscall.map, v_addr, p_addr, size, usize(writable)) != 0;
154154}
155155
156pub fn createThread(function: fn() void) u16 {
156pub fn createThread(function: fn () void) u16 {
157157 return u16(syscall1(Syscall.createThread, @ptrToInt(function)));
158158}
159159
std/rand/index.zig+1-1
......@@ -28,7 +28,7 @@ pub const DefaultPrng = Xoroshiro128;
2828pub const DefaultCsprng = Isaac64;
2929
3030pub const Random = struct {
31 fillFn: fn(r: &Random, buf: []u8) void,
31 fillFn: fn (r: &Random, buf: []u8) void,
3232
3333 /// Read random bytes into the specified buffer until fill.
3434 pub fn bytes(r: &Random, buf: []u8) void {
std/rand/ziggurat.zig+5-5
......@@ -56,11 +56,11 @@ pub const ZigTable = struct {
5656 f: [257]f64,
5757
5858 // probability density function used as a fallback
59 pdf: fn(f64) f64,
59 pdf: fn (f64) f64,
6060 // whether the distribution is symmetric
6161 is_symmetric: bool,
6262 // fallback calculation in the case we are in the 0 block
63 zero_case: fn(&Random, f64) f64,
63 zero_case: fn (&Random, f64) f64,
6464};
6565
6666// zigNorInit
......@@ -68,9 +68,9 @@ fn ZigTableGen(
6868 comptime is_symmetric: bool,
6969 comptime r: f64,
7070 comptime v: f64,
71 comptime f: fn(f64) f64,
72 comptime f_inv: fn(f64) f64,
73 comptime zero_case: fn(&Random, f64) f64,
71 comptime f: fn (f64) f64,
72 comptime f_inv: fn (f64) f64,
73 comptime zero_case: fn (&Random, f64) f64,
7474) ZigTable {
7575 var tables: ZigTable = undefined;
7676
std/sort.zig+21-21
......@@ -5,7 +5,7 @@ const math = std.math;
55const builtin = @import("builtin");
66
77/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. O(1) memory (no allocator required).
8pub fn insertionSort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const T) bool) void {
8pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) void {
99 {
1010 var i: usize = 1;
1111 while (i < items.len) : (i += 1) {
......@@ -108,7 +108,7 @@ const Pull = struct {
108108
109109/// Stable in-place sort. O(n) best case, O(n*log(n)) worst case and average case. O(1) memory (no allocator required).
110110/// Currently implemented as block sort.
111pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const T) bool) void {
111pub fn sort(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) void {
112112 // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c
113113 var cache: [512]T = undefined;
114114
......@@ -257,7 +257,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
257257 // merge A2 and B2 into the cache
258258 if (lessThan(items[B2.end - 1], items[A2.start])) {
259259 // the two ranges are in reverse order, so copy them in reverse order into the cache
260 mem.copy(T, cache[A1.length() + B2.length()..], items[A2.start..A2.end]);
260 mem.copy(T, cache[A1.length() + B2.length() ..], items[A2.start..A2.end]);
261261 mem.copy(T, cache[A1.length()..], items[B2.start..B2.end]);
262262 } else if (lessThan(items[B2.start], items[A2.end - 1])) {
263263 // these two ranges weren't already in order, so merge them into the cache
......@@ -265,7 +265,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
265265 } else {
266266 // copy A2 and B2 into the cache in the same order
267267 mem.copy(T, cache[A1.length()..], items[A2.start..A2.end]);
268 mem.copy(T, cache[A1.length() + A2.length()..], items[B2.start..B2.end]);
268 mem.copy(T, cache[A1.length() + A2.length() ..], items[B2.start..B2.end]);
269269 }
270270 A2 = Range.init(A2.start, B2.end);
271271
......@@ -275,7 +275,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
275275
276276 if (lessThan(cache[B3.end - 1], cache[A3.start])) {
277277 // the two ranges are in reverse order, so copy them in reverse order into the items
278 mem.copy(T, items[A1.start + A2.length()..], cache[A3.start..A3.end]);
278 mem.copy(T, items[A1.start + A2.length() ..], cache[A3.start..A3.end]);
279279 mem.copy(T, items[A1.start..], cache[B3.start..B3.end]);
280280 } else if (lessThan(cache[B3.start], cache[A3.end - 1])) {
281281 // these two ranges weren't already in order, so merge them back into the items
......@@ -283,7 +283,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
283283 } else {
284284 // copy A3 and B3 into the items in the same order
285285 mem.copy(T, items[A1.start..], cache[A3.start..A3.end]);
286 mem.copy(T, items[A1.start + A1.length()..], cache[B3.start..B3.end]);
286 mem.copy(T, items[A1.start + A1.length() ..], cache[B3.start..B3.end]);
287287 }
288288 }
289289
......@@ -640,7 +640,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
640640 if (buffer2.length() > 0 or block_size <= cache.len) {
641641 // copy the previous A block into the cache or buffer2, since that's where we need it to be when we go to merge it anyway
642642 if (block_size <= cache.len) {
643 mem.copy(T, cache[0..], items[blockA.start..blockA.start + block_size]);
643 mem.copy(T, cache[0..], items[blockA.start .. blockA.start + block_size]);
644644 } else {
645645 blockSwap(T, items, blockA.start, buffer2.start, block_size);
646646 }
......@@ -651,7 +651,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
651651 blockSwap(T, items, B_split, blockA.start + block_size - B_remaining, B_remaining);
652652 } else {
653653 // we are unable to use the 'buffer2' trick to speed up the rotation operation since buffer2 doesn't exist, so perform a normal rotation
654 mem.rotate(T, items[B_split..blockA.start + block_size], blockA.start - B_split);
654 mem.rotate(T, items[B_split .. blockA.start + block_size], blockA.start - B_split);
655655 }
656656
657657 // update the range for the remaining A blocks, and the range remaining from the B block after it was split
......@@ -741,7 +741,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
741741}
742742
743743// merge operation without a buffer
744fn mergeInPlace(comptime T: type, items: []T, A_arg: &const Range, B_arg: &const Range, lessThan: fn(&const T, &const T) bool) void {
744fn mergeInPlace(comptime T: type, items: []T, A_arg: &const Range, B_arg: &const Range, lessThan: fn (&const T, &const T) bool) void {
745745 if (A_arg.length() == 0 or B_arg.length() == 0) return;
746746
747747 // this just repeatedly binary searches into B and rotates A into position.
......@@ -783,7 +783,7 @@ fn mergeInPlace(comptime T: type, items: []T, A_arg: &const Range, B_arg: &const
783783}
784784
785785// merge operation using an internal buffer
786fn mergeInternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn(&const T, &const T) bool, buffer: &const Range) void {
786fn mergeInternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, buffer: &const Range) void {
787787 // whenever we find a value to add to the final array, swap it with the value that's already in that spot
788788 // when this algorithm is finished, 'buffer' will contain its original contents, but in a different order
789789 var A_count: usize = 0;
......@@ -819,7 +819,7 @@ fn blockSwap(comptime T: type, items: []T, start1: usize, start2: usize, block_s
819819
820820// combine a linear search with a binary search to reduce the number of comparisons in situations
821821// where have some idea as to how many unique values there are and where the next value might be
822fn findFirstForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool, unique: usize) usize {
822fn findFirstForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
823823 if (range.length() == 0) return range.start;
824824 const skip = math.max(range.length() / unique, usize(1));
825825
......@@ -833,7 +833,7 @@ fn findFirstForward(comptime T: type, items: []T, value: &const T, range: &const
833833 return binaryFirst(T, items, value, Range.init(index - skip, index), lessThan);
834834}
835835
836fn findFirstBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool, unique: usize) usize {
836fn findFirstBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
837837 if (range.length() == 0) return range.start;
838838 const skip = math.max(range.length() / unique, usize(1));
839839
......@@ -847,7 +847,7 @@ fn findFirstBackward(comptime T: type, items: []T, value: &const T, range: &cons
847847 return binaryFirst(T, items, value, Range.init(index, index + skip), lessThan);
848848}
849849
850fn findLastForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool, unique: usize) usize {
850fn findLastForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
851851 if (range.length() == 0) return range.start;
852852 const skip = math.max(range.length() / unique, usize(1));
853853
......@@ -861,7 +861,7 @@ fn findLastForward(comptime T: type, items: []T, value: &const T, range: &const
861861 return binaryLast(T, items, value, Range.init(index - skip, index), lessThan);
862862}
863863
864fn findLastBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool, unique: usize) usize {
864fn findLastBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
865865 if (range.length() == 0) return range.start;
866866 const skip = math.max(range.length() / unique, usize(1));
867867
......@@ -875,7 +875,7 @@ fn findLastBackward(comptime T: type, items: []T, value: &const T, range: &const
875875 return binaryLast(T, items, value, Range.init(index, index + skip), lessThan);
876876}
877877
878fn binaryFirst(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool) usize {
878fn binaryFirst(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool) usize {
879879 var start = range.start;
880880 var end = range.end - 1;
881881 if (range.start >= range.end) return range.end;
......@@ -893,7 +893,7 @@ fn binaryFirst(comptime T: type, items: []T, value: &const T, range: &const Rang
893893 return start;
894894}
895895
896fn binaryLast(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn(&const T, &const T) bool) usize {
896fn binaryLast(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool) usize {
897897 var start = range.start;
898898 var end = range.end - 1;
899899 if (range.start >= range.end) return range.end;
......@@ -911,7 +911,7 @@ fn binaryLast(comptime T: type, items: []T, value: &const T, range: &const Range
911911 return start;
912912}
913913
914fn mergeInto(comptime T: type, from: []T, A: &const Range, B: &const Range, lessThan: fn(&const T, &const T) bool, into: []T) void {
914fn mergeInto(comptime T: type, from: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, into: []T) void {
915915 var A_index: usize = A.start;
916916 var B_index: usize = B.start;
917917 const A_last = A.end;
......@@ -941,7 +941,7 @@ fn mergeInto(comptime T: type, from: []T, A: &const Range, B: &const Range, less
941941 }
942942}
943943
944fn mergeExternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn(&const T, &const T) bool, cache: []T) void {
944fn mergeExternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, cache: []T) void {
945945 // A fits into the cache, so use that instead of the internal buffer
946946 var A_index: usize = 0;
947947 var B_index: usize = B.start;
......@@ -969,7 +969,7 @@ fn mergeExternal(comptime T: type, items: []T, A: &const Range, B: &const Range,
969969 mem.copy(T, items[insert_index..], cache[A_index..A_last]);
970970}
971971
972fn swap(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const T) bool, order: &[8]u8, x: usize, y: usize) void {
972fn swap(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool, order: &[8]u8, x: usize, y: usize) void {
973973 if (lessThan(items[y], items[x]) or ((order.*)[x] > (order.*)[y] and !lessThan(items[x], items[y]))) {
974974 mem.swap(T, &items[x], &items[y]);
975975 mem.swap(u8, &(order.*)[x], &(order.*)[y]);
......@@ -1345,7 +1345,7 @@ fn fuzzTest(rng: &std.rand.Random) void {
13451345 }
13461346}
13471347
1348pub fn min(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const T) bool) T {
1348pub fn min(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) T {
13491349 var i: usize = 0;
13501350 var smallest = items[0];
13511351 for (items[1..]) |item| {
......@@ -1356,7 +1356,7 @@ pub fn min(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const
13561356 return smallest;
13571357}
13581358
1359pub fn max(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &const T) bool) T {
1359pub fn max(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) T {
13601360 var i: usize = 0;
13611361 var biggest = items[0];
13621362 for (items[1..]) |item| {
std/special/build_runner.zig+1-1
......@@ -71,7 +71,7 @@ pub fn main() !void {
7171 }
7272 if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
7373 const option_name = option_contents[0..name_end];
74 const option_value = option_contents[name_end + 1..];
74 const option_value = option_contents[name_end + 1 ..];
7575 if (builder.addUserInputOption(option_name, option_value))
7676 return usageAndErr(&builder, false, try stderr_stream);
7777 } else {
std/unicode.zig+2-2
......@@ -151,7 +151,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool {
151151 return false;
152152 }
153153
154 if (utf8Decode(s[i..i + cp_len])) |_| {} else |_| {
154 if (utf8Decode(s[i .. i + cp_len])) |_| {} else |_| {
155155 return false;
156156 }
157157 i += cp_len;
......@@ -216,7 +216,7 @@ const Utf8Iterator = struct {
216216 const cp_len = utf8ByteSequenceLength(it.bytes[it.i]) catch unreachable;
217217
218218 it.i += cp_len;
219 return it.bytes[it.i - cp_len..it.i];
219 return it.bytes[it.i - cp_len .. it.i];
220220 }
221221
222222 pub fn nextCodepoint(it: &Utf8Iterator) ?u32 {
std/zig/tokenizer.zig+1-1
......@@ -1116,7 +1116,7 @@ pub const Tokenizer = struct {
11161116 if (self.index + length > self.buffer.len) {
11171117 return u3(self.buffer.len - self.index);
11181118 }
1119 const bytes = self.buffer[self.index..self.index + length];
1119 const bytes = self.buffer[self.index .. self.index + length];
11201120 switch (length) {
11211121 2 => {
11221122 const value = std.unicode.utf8Decode2(bytes) catch return length;
test/cases/align.zig+5-5
......@@ -18,8 +18,8 @@ fn noop4() align(4) void {}
1818
1919test "function alignment" {
2020 assert(derp() == 1234);
21 assert(@typeOf(noop1) == fn() align(1) void);
22 assert(@typeOf(noop4) == fn() align(4) void);
21 assert(@typeOf(noop1) == fn () align(1) void);
22 assert(@typeOf(noop4) == fn () align(4) void);
2323 noop1();
2424 noop4();
2525}
......@@ -127,7 +127,7 @@ test "implicitly decreasing fn alignment" {
127127 testImplicitlyDecreaseFnAlign(alignedBig, 5678);
128128}
129129
130fn testImplicitlyDecreaseFnAlign(ptr: fn() align(1) i32, answer: i32) void {
130fn testImplicitlyDecreaseFnAlign(ptr: fn () align(1) i32, answer: i32) void {
131131 assert(ptr() == answer);
132132}
133133
......@@ -141,10 +141,10 @@ fn alignedBig() align(16) i32 {
141141test "@alignCast functions" {
142142 assert(fnExpectsOnly1(simple4) == 0x19);
143143}
144fn fnExpectsOnly1(ptr: fn() align(1) i32) i32 {
144fn fnExpectsOnly1(ptr: fn () align(1) i32) i32 {
145145 return fnExpects4(@alignCast(4, ptr));
146146}
147fn fnExpects4(ptr: fn() align(4) i32) i32 {
147fn fnExpects4(ptr: fn () align(4) i32) i32 {
148148 return ptr();
149149}
150150fn simple4() align(4) i32 {
test/cases/bugs/920.zig+3-3
......@@ -7,12 +7,12 @@ const ZigTable = struct {
77 x: [257]f64,
88 f: [257]f64,
99
10 pdf: fn(f64) f64,
10 pdf: fn (f64) f64,
1111 is_symmetric: bool,
12 zero_case: fn(&Random, f64) f64,
12 zero_case: fn (&Random, f64) f64,
1313};
1414
15fn ZigTableGen(comptime is_symmetric: bool, comptime r: f64, comptime v: f64, comptime f: fn(f64) f64, comptime f_inv: fn(f64) f64, comptime zero_case: fn(&Random, f64) f64) ZigTable {
15fn ZigTableGen(comptime is_symmetric: bool, comptime r: f64, comptime v: f64, comptime f: fn (f64) f64, comptime f_inv: fn (f64) f64, comptime zero_case: fn (&Random, f64) f64) ZigTable {
1616 var tables: ZigTable = undefined;
1717
1818 tables.is_symmetric = is_symmetric;
test/cases/coroutines.zig+1-1
......@@ -154,7 +154,7 @@ test "async function with dot syntax" {
154154test "async fn pointer in a struct field" {
155155 var data: i32 = 1;
156156 const Foo = struct {
157 bar: async<&std.mem.Allocator> fn(&i32) void,
157 bar: async<&std.mem.Allocator> fn (&i32) void,
158158 };
159159 var foo = Foo{ .bar = simpleAsyncFn2 };
160160 const p = (async<std.debug.global_allocator> foo.bar(&data)) catch unreachable;
test/cases/error.zig+1-1
......@@ -193,7 +193,7 @@ fn entry() void {
193193 foo2(bar2);
194194}
195195
196fn foo2(f: fn() error!void) void {
196fn foo2(f: fn () error!void) void {
197197 const x = f();
198198}
199199
test/cases/eval.zig+1-1
......@@ -215,7 +215,7 @@ test "inlined block and runtime block phi" {
215215
216216const CmdFn = struct {
217217 name: []const u8,
218 func: fn(i32) i32,
218 func: fn (i32) i32,
219219};
220220
221221const cmd_fns = []CmdFn{
test/cases/fn.zig+1-1
......@@ -66,7 +66,7 @@ test "implicit cast function unreachable return" {
6666 wantsFnWithVoid(fnWithUnreachable);
6767}
6868
69fn wantsFnWithVoid(f: fn() void) void {}
69fn wantsFnWithVoid(f: fn () void) void {}
7070
7171fn fnWithUnreachable() noreturn {
7272 unreachable;
test/cases/fn_in_struct_in_comptime.zig+1-1
......@@ -1,6 +1,6 @@
11const assert = @import("std").debug.assert;
22
3fn get_foo() fn(&u8) usize {
3fn get_foo() fn (&u8) usize {
44 comptime {
55 return struct {
66 fn func(ptr: &u8) usize {
test/cases/generics.zig+1-1
......@@ -133,7 +133,7 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
133133 return getByte(@ptrCast(&const u8, &mem[0]));
134134}
135135
136const foos = []fn(var) bool{
136const foos = []fn (var) bool{
137137 foo1,
138138 foo2,
139139};
test/cases/misc.zig+1-1
......@@ -511,7 +511,7 @@ test "@typeId" {
511511 assert(@typeId(@typeOf(AUnionEnum.One)) == Tid.Enum);
512512 assert(@typeId(AUnionEnum) == Tid.Union);
513513 assert(@typeId(AUnion) == Tid.Union);
514 assert(@typeId(fn() void) == Tid.Fn);
514 assert(@typeId(fn () void) == Tid.Fn);
515515 assert(@typeId(@typeOf(builtin)) == Tid.Namespace);
516516 assert(@typeId(@typeOf(x: {
517517 break :x this;
test/cases/struct.zig+2-2
......@@ -105,7 +105,7 @@ test "fn call of struct field" {
105105}
106106
107107const Foo = struct {
108 ptr: fn() i32,
108 ptr: fn () i32,
109109};
110110
111111fn aFunc() i32 {
......@@ -302,7 +302,7 @@ test "packed array 24bits" {
302302
303303 var bytes = []u8{0} ** (@sizeOf(FooArray24Bits) + 1);
304304 bytes[bytes.len - 1] = 0xaa;
305 const ptr = &([]FooArray24Bits)(bytes[0..bytes.len - 1])[0];
305 const ptr = &([]FooArray24Bits)(bytes[0 .. bytes.len - 1])[0];
306306 assert(ptr.a == 0);
307307 assert(ptr.b[0].field == 0);
308308 assert(ptr.b[1].field == 0);
test/cases/type_info.zig+1-1
......@@ -196,7 +196,7 @@ fn testStruct() void {
196196 assert(!struct_info.Struct.defs[0].data.Fn.is_extern);
197197 assert(struct_info.Struct.defs[0].data.Fn.lib_name == null);
198198 assert(struct_info.Struct.defs[0].data.Fn.return_type == void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn(&const TestStruct) void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn (&const TestStruct) void);
200200}
201201
202202const TestStruct = packed struct {
test/cases/var_args.zig+1-1
......@@ -58,7 +58,7 @@ fn extraFn(extra: u32, args: ...) usize {
5858 return args.len;
5959}
6060
61const foos = []fn(...) bool{
61const foos = []fn (...) bool{
6262 foo1,
6363 foo2,
6464};