Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/compiler/aro/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
_ = try p.expectToken(.semicolon);
if (decl_spec.ty.is(.@"enum") or
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
{
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler/aro/aro/pragmas/gcc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex

const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
return pp.comp.addDiagnostic(.{
.tag = .unknown_gcc_pragma,
.loc = directive_tok.loc,
}, pp.expansionSlice(start_idx + 1));
.tag = .unknown_gcc_pragma,
.loc = directive_tok.loc,
}, pp.expansionSlice(start_idx + 1));

switch (gcc_pragma) {
.warning, .@"error" => {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/resinator/lang.zig
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub fn parse(lang_tag: []const u8) error{InvalidLanguageTag}!Parsed {
// Special case for qps-ploca and qps-plocm
else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
(std.ascii.eqlIgnoreCase(part_str, "ploca") or
std.ascii.eqlIgnoreCase(part_str, "plocm")))
std.ascii.eqlIgnoreCase(part_str, "plocm")))
{
parsed.suffix = part_str;
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/count0bits.zig
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub const __clzsi2 = switch (builtin.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => impl: {
const use_thumb1 =
(builtin.cpu.arch.isThumb() or
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);

if (use_thumb1) {
Expand Down
52 changes: 26 additions & 26 deletions lib/compiler_rt/int.zig
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ fn test_one_divmoddi4(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {

const cases__divmoddi4 =
[_][4]i64{
[_]i64{ 0, 1, 0, 0 },
[_]i64{ 0, -1, 0, 0 },
[_]i64{ 2, 1, 2, 0 },
[_]i64{ 2, -1, -2, 0 },
[_]i64{ -2, 1, -2, 0 },
[_]i64{ -2, -1, 2, 0 },
[_]i64{ 7, 5, 1, 2 },
[_]i64{ -7, 5, -1, -2 },
[_]i64{ 19, 5, 3, 4 },
[_]i64{ 19, -5, -3, 4 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
};
[_]i64{ 0, 1, 0, 0 },
[_]i64{ 0, -1, 0, 0 },
[_]i64{ 2, 1, 2, 0 },
[_]i64{ 2, -1, -2, 0 },
[_]i64{ -2, 1, -2, 0 },
[_]i64{ -2, -1, 2, 0 },
[_]i64{ 7, 5, 1, 2 },
[_]i64{ -7, 5, -1, -2 },
[_]i64{ 19, 5, 3, 4 },
[_]i64{ 19, -5, -3, 4 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
};

test "test_divmoddi4" {
for (cases__divmoddi4) |case| {
Expand Down Expand Up @@ -215,19 +215,19 @@ pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {

const cases__divmodsi4 =
[_][4]i32{
[_]i32{ 0, 1, 0, 0 },
[_]i32{ 0, -1, 0, 0 },
[_]i32{ 2, 1, 2, 0 },
[_]i32{ 2, -1, -2, 0 },
[_]i32{ -2, 1, -2, 0 },
[_]i32{ -2, -1, 2, 0 },
[_]i32{ 7, 5, 1, 2 },
[_]i32{ -7, 5, -1, -2 },
[_]i32{ 19, 5, 3, 4 },
[_]i32{ 19, -5, -3, 4 },
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
};
[_]i32{ 0, 1, 0, 0 },
[_]i32{ 0, -1, 0, 0 },
[_]i32{ 2, 1, 2, 0 },
[_]i32{ 2, -1, -2, 0 },
[_]i32{ -2, 1, -2, 0 },
[_]i32{ -2, -1, 2, 0 },
[_]i32{ 7, 5, 1, 2 },
[_]i32{ -7, 5, -1, -2 },
[_]i32{ 19, 5, 3, 4 },
[_]i32{ 19, -5, -3, 4 },
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
};

fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
var r: i32 = undefined;
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/popcount.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
var x: UT = @bitCast(a);
x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
+ (x & (~@as(UT, 0) / 5));
+ (x & (~@as(UT, 0) / 5));
x += x >> 4;
x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
// 8 most significant bits of x + (x<<8) + (x<<16) + ..
Expand Down
2 changes: 1 addition & 1 deletion lib/docs/wasm/markdown/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
// or not of the same marker type.
const should_close_list = last_pending_block.tag == .list and
(block_start.tag != .list_item or
block_start.data.list_item.marker != last_pending_block.data.list.marker);
block_start.data.list_item.marker != last_pending_block.data.list.marker);
// The last block should also be closed if the new block is not a table
// row, which is the only allowed child of a table.
const should_close_table = last_pending_block.tag == .table and
Expand Down
2 changes: 1 addition & 1 deletion lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub const Os = struct {
pub fn parse(str: []const u8) !WindowsVersion {
return std.meta.stringToEnum(WindowsVersion, str) orelse
@enumFromInt(std.fmt.parseInt(u32, str, 0) catch
return error.InvalidOperatingSystemVersion);
return error.InvalidOperatingSystemVersion);
}

/// This function is defined to serialize a Zig source code representation of this
Expand Down
8 changes: 4 additions & 4 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9879,10 +9879,10 @@ pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8

pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
{} // android bionic and openbsd libc does not implement getcontext
else if (native_os == .linux and builtin.target.abi.isMusl())
linux.getcontext
else
private.getcontext;
else if (native_os == .linux and builtin.target.abi.isMusl())
linux.getcontext
else
private.getcontext;

pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
f64
Expand Down
14 changes: 7 additions & 7 deletions lib/std/crypto/tls/Client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
Expand Down Expand Up @@ -720,11 +720,11 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
);
const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
array(u24, u8, hmacExpandLabel(
P.Hmac,
&master_secret,
&.{ "client finished", &p.transcript_hash.peek() },
P.verify_data_length,
));
P.Hmac,
&master_secret,
&.{ "client finished", &p.transcript_hash.peek() },
P.verify_data_length,
));
p.transcript_hash.update(&client_verify_cleartext);
p.version = .{ .tls_1_2 = .{
.expected_server_verify_data = hmacExpandLabel(
Expand All @@ -745,7 +745,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, u8, nonce[P.fixed_iv_length..].* ++
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
P.AEAD.encrypt(
client_verify_msg[client_verify_msg.len - P.mac_length -
client_verify_cleartext.len ..][0..client_verify_cleartext.len],
Expand Down
18 changes: 9 additions & 9 deletions lib/std/debug/SelfInfo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,15 @@ pub const Module = switch (native_os) {
const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
const o_file_info = self.ofiles.getPtr(o_file_path) orelse
(self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
error.FileNotFound,
error.MissingDebugInfo,
error.InvalidDebugInfo,
=> return .{
.relocated_address = relocated_address,
.symbol = symbol,
},
else => return err,
});
error.FileNotFound,
error.MissingDebugInfo,
error.InvalidDebugInfo,
=> return .{
.relocated_address = relocated_address,
.symbol = symbol,
},
else => return err,
});

return .{
.relocated_address = relocated_address,
Expand Down
28 changes: 14 additions & 14 deletions lib/std/http/Client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -959,14 +959,14 @@ pub const Request = struct {

pub const WaitError = RequestError || SendError || TransferReadError ||
proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
error{ // TODO: file zig fmt issue for this bad indentation
TooManyHttpRedirects,
RedirectRequiresResend,
HttpRedirectLocationMissing,
HttpRedirectLocationInvalid,
CompressionInitializationFailed,
CompressionUnsupported,
};
error{
TooManyHttpRedirects,
RedirectRequiresResend,
HttpRedirectLocationMissing,
HttpRedirectLocationInvalid,
CompressionInitializationFailed,
CompressionUnsupported,
};

/// Waits for a response from the server and parses any headers that are sent.
/// This function will block until the final response is received.
Expand Down Expand Up @@ -1539,13 +1539,13 @@ pub fn connect(

pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
std.fmt.ParseIntError || Connection.WriteError ||
error{ // TODO: file a zig fmt issue for this bad indentation
UnsupportedUriScheme,
UriMissingHost,
error{
UnsupportedUriScheme,
UriMissingHost,

CertificateBundleLoadFailure,
UnsupportedTransferEncoding,
};
CertificateBundleLoadFailure,
UnsupportedTransferEncoding,
};

pub const RequestOptions = struct {
version: http.Version = .@"HTTP/1.1",
Expand Down
12 changes: 6 additions & 6 deletions lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2851,12 +2851,12 @@ pub fn renameatW(

rc =
windows.ntdll.NtSetInformationFile(
src_fd,
&io_status_block,
rename_info,
@intCast(struct_len), // already checked for error.NameTooLong
.FileRenameInformation,
);
src_fd,
&io_status_block,
rename_info,
@intCast(struct_len), // already checked for error.NameTooLong
.FileRenameInformation,
);
}

switch (rc) {
Expand Down
24 changes: 12 additions & 12 deletions lib/std/zig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -535,24 +535,20 @@ test isUnderscore {
try std.testing.expect(!isUnderscore("\\x5f"));
}

pub fn readSourceFileToEndAlloc(
allocator: Allocator,
input: std.fs.File,
size_hint: ?usize,
) ![:0]u8 {
pub fn readSourceFileToEndAlloc(gpa: Allocator, input: std.fs.File, size_hint: ?usize) ![:0]u8 {
const source_code = input.readToEndAllocOptions(
allocator,
gpa,
max_src_size,
size_hint,
@alignOf(u16),
@alignOf(u8),
0,
) catch |err| switch (err) {
error.ConnectionResetByPeer => unreachable,
error.ConnectionTimedOut => unreachable,
error.NotOpenForReading => unreachable,
else => |e| return e,
};
errdefer allocator.free(source_code);
errdefer gpa.free(source_code);

// Detect unsupported file types with their Byte Order Mark
const unsupported_boms = [_][]const u8{
Expand All @@ -568,15 +564,19 @@ pub fn readSourceFileToEndAlloc(

// If the file starts with a UTF-16 little endian BOM, translate it to UTF-8
if (std.mem.startsWith(u8, source_code, "\xff\xfe")) {
const source_code_utf16_le = std.mem.bytesAsSlice(u16, source_code);
const source_code_utf8 = std.unicode.utf16LeToUtf8AllocZ(allocator, source_code_utf16_le) catch |err| switch (err) {
if (source_code.len % 2 != 0) return error.InvalidEncoding;
// TODO: after wrangle-writer-buffering branch is merged,
// avoid this unnecessary allocation
const aligned_copy = try gpa.alloc(u16, source_code.len / 2);
defer gpa.free(aligned_copy);
@memcpy(std.mem.sliceAsBytes(aligned_copy), source_code);
const source_code_utf8 = std.unicode.utf16LeToUtf8AllocZ(gpa, aligned_copy) catch |err| switch (err) {
error.DanglingSurrogateHalf => error.UnsupportedEncoding,
error.ExpectedSecondSurrogateHalf => error.UnsupportedEncoding,
error.UnexpectedSecondSurrogateHalf => error.UnsupportedEncoding,
else => |e| return e,
};

allocator.free(source_code);
gpa.free(source_code);
return source_code_utf8;
}

Expand Down
Loading
Loading