Commit bdf3680be1

Andrew Kelley <andrew@ziglang.org>
2019-11-25 19:51:09
zig fmt
1 parent 8a4c2d3
lib/std/debug/failing_allocator.zig
@@ -5,10 +5,10 @@ const mem = std.mem;
 /// memory conditions are handled correctly.
 ///
 /// To use this, first initialize it and get an allocator with
-/// 
+///
 /// `const failing_allocator = &FailingAllocator.init(<allocator>,
 ///                                                   <fail_index>).allocator;`
-/// 
+///
 /// Then use `failing_allocator` anywhere you would have used a
 /// different allocator.
 pub const FailingAllocator = struct {
lib/std/event/fs.zig
@@ -1266,7 +1266,7 @@ pub fn Watch(comptime V: type) type {
                             if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) {
                                 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
                                 // `ev.len` counts all bytes in `ev.name` including terminating null byte.
-                                const basename_with_null = basename_ptr[0 .. ev.len];
+                                const basename_with_null = basename_ptr[0..ev.len];
                                 const user_value = blk: {
                                     const held = self.os_data.table_lock.acquire();
                                     defer held.release();
lib/std/os/bits/linux.zig
@@ -1124,7 +1124,6 @@ pub const io_uring_params = extern struct {
 
 pub const IORING_FEAT_SINGLE_MMAP = 1 << 0;
 
-
 // io_uring_params.flags
 
 /// io_context is polled
lib/std/os/uefi/protocols/hii.zig
@@ -26,6 +26,7 @@ pub const HIIPackageHeader = packed struct {
 /// The header found at the start of each package list.
 pub const HIIPackageList = extern struct {
     package_list_guid: Guid,
+
     /// The size of the package list (in bytes), including the header.
     package_list_length: u32,
 
lib/std/os/uefi/tables/table_header.zig
@@ -1,6 +1,7 @@
 pub const TableHeader = extern struct {
     signature: u64,
     revision: u32,
+
     /// The size, in bytes, of the entire table including the TableHeader
     header_size: u32,
     crc32: u32,
lib/std/os/uefi/status.zig
@@ -5,82 +5,120 @@ pub const success: usize = 0;
 
 /// The image failed to load.
 pub const load_error: usize = high_bit | 1;
+
 /// A parameter was incorrect.
 pub const invalid_parameter: usize = high_bit | 2;
+
 /// The operation is not supported.
 pub const unsupported: usize = high_bit | 3;
+
 /// The buffer was not the proper size for the request.
 pub const bad_buffer_size: usize = high_bit | 4;
+
 /// The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.
 pub const buffer_too_small: usize = high_bit | 5;
+
 /// There is no data pending upon return.
 pub const not_ready: usize = high_bit | 6;
+
 /// The physical device reported an error while attempting the operation.
 pub const device_error: usize = high_bit | 7;
+
 /// The device cannot be written to.
 pub const write_protected: usize = high_bit | 8;
+
 /// A resource has run out.
 pub const out_of_resources: usize = high_bit | 9;
+
 /// An inconstancy was detected on the file system causing the operating to fail.
 pub const volume_corrupted: usize = high_bit | 10;
+
 /// There is no more space on the file system.
 pub const volume_full: usize = high_bit | 11;
+
 /// The device does not contain any medium to perform the operation.
 pub const no_media: usize = high_bit | 12;
+
 /// The medium in the device has changed since the last access.
 pub const media_changed: usize = high_bit | 13;
+
 /// The item was not found.
 pub const not_found: usize = high_bit | 14;
+
 /// Access was denied.
 pub const access_denied: usize = high_bit | 15;
+
 /// The server was not found or did not respond to the request.
 pub const no_response: usize = high_bit | 16;
+
 /// A mapping to a device does not exist.
 pub const no_mapping: usize = high_bit | 17;
+
 /// The timeout time expired.
 pub const timeout: usize = high_bit | 18;
+
 /// The protocol has not been started.
 pub const not_started: usize = high_bit | 19;
+
 /// The protocol has already been started.
 pub const already_started: usize = high_bit | 20;
+
 /// The operation was aborted.
 pub const aborted: usize = high_bit | 21;
+
 /// An ICMP error occurred during the network operation.
 pub const icmp_error: usize = high_bit | 22;
+
 /// A TFTP error occurred during the network operation.
 pub const tftp_error: usize = high_bit | 23;
+
 /// A protocol error occurred during the network operation.
 pub const protocol_error: usize = high_bit | 24;
+
 /// The function encountered an internal version that was incompatible with a version requested by the caller.
 pub const incompatible_version: usize = high_bit | 25;
+
 /// The function was not performed due to a security violation.
 pub const security_violation: usize = high_bit | 26;
+
 /// A CRC error was detected.
 pub const crc_error: usize = high_bit | 27;
+
 /// Beginning or end of media was reached
 pub const end_of_media: usize = high_bit | 28;
+
 /// The end of the file was reached.
 pub const end_of_file: usize = high_bit | 31;
+
 /// The language specified was invalid.
 pub const invalid_language: usize = high_bit | 32;
+
 /// The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.
 pub const compromised_data: usize = high_bit | 33;
+
 /// There is an address conflict address allocation
 pub const ip_address_conflict: usize = high_bit | 34;
+
 /// A HTTP error occurred during the network operation.
 pub const http_error: usize = high_bit | 35;
 
 /// The string contained one or more characters that the device could not render and were skipped.
 pub const warn_unknown_glyph: usize = 1;
+
 /// The handle was closed, but the file was not deleted.
 pub const warn_delete_failure: usize = 2;
+
 /// The handle was closed, but the data to the file was not flushed properly.
 pub const warn_write_failure: usize = 3;
+
 /// The resulting buffer was too small, and the data was truncated to the buffer size.
 pub const warn_buffer_too_small: usize = 4;
+
 /// The data has not been updated within the timeframe set by localpolicy for this type of data.
 pub const warn_stale_data: usize = 5;
+
 /// The resulting buffer contains UEFI-compliant file system.
 pub const warn_file_system: usize = 6;
+
 /// The operation will be processed across a system reset.
 pub const warn_reset_required: usize = 7;
lib/std/os/windows/ws2_32.zig
@@ -106,12 +106,7 @@ pub const WSAOVERLAPPED = extern struct {
     hEvent: ?WSAEVENT,
 };
 
-pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (
-    dwError: DWORD,
-    cbTransferred: DWORD,
-    lpOverlapped: *WSAOVERLAPPED,
-    dwFlags: DWORD
-) void;
+pub const WSAOVERLAPPED_COMPLETION_ROUTINE = extern fn (dwError: DWORD, cbTransferred: DWORD, lpOverlapped: *WSAOVERLAPPED, dwFlags: DWORD) void;
 
 pub const WSA_INVALID_HANDLE = 6;
 pub const WSA_NOT_ENOUGH_MEMORY = 8;
@@ -209,11 +204,12 @@ pub const WSA_QOS_ESDMODEOBJ = 11029;
 pub const WSA_QOS_ESHAPERATEOBJ = 11030;
 pub const WSA_QOS_RESERVED_PETYPE = 11031;
 
-
 /// no parameters
 const IOC_VOID = 0x80000000;
+
 /// copy out parameters
 const IOC_OUT = 0x40000000;
+
 /// copy in parameters
 const IOC_IN = 0x80000000;
 
lib/std/os/windows.zig
@@ -192,7 +192,7 @@ pub const FindFirstFileError = error{
 };
 
 pub fn FindFirstFile(dir_path: []const u8, find_file_data: *WIN32_FIND_DATAW) FindFirstFileError!HANDLE {
-    const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, [_]u16{ '\\', '*'});
+    const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, [_]u16{ '\\', '*' });
     const handle = kernel32.FindFirstFileW(&dir_path_w, find_file_data);
 
     if (handle == INVALID_HANDLE_VALUE) {
@@ -932,7 +932,7 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
     // TODO https://github.com/ziglang/zig/issues/2765
     var result: [PATH_MAX_WIDE:0]u16 = undefined;
 
-    const start_index = if (mem.startsWith(u16, s, [_]u16{'\\', '?'})) 0 else blk: {
+    const start_index = if (mem.startsWith(u16, s, [_]u16{ '\\', '?' })) 0 else blk: {
         const prefix = [_]u16{ '\\', '?', '?', '\\' };
         mem.copy(u16, result[0..], prefix);
         break :blk prefix.len;
@@ -942,7 +942,6 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
     mem.copy(u16, result[start_index..], s);
     result[end_index] = 0;
     return result;
-
 }
 
 pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16) ![PATH_MAX_WIDE + suffix.len:0]u16 {
lib/std/array_list.zig
@@ -58,7 +58,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
             return self.items[0..self.len];
         }
 
-        /// Safely access index i of the list. 
+        /// Safely access index i of the list.
         pub fn at(self: Self, i: usize) T {
             return self.toSliceConst()[i];
         }
lib/std/builtin.zig
@@ -144,6 +144,7 @@ pub const TypeInfo = union(enum) {
         alignment: comptime_int,
         child: type,
         is_allowzero: bool,
+
         /// The type of the sentinel is the element type of the pointer, which is
         /// the value of the `child` field in this struct. However there is no way
         /// to refer to that type here, so we use `var`.
@@ -164,6 +165,7 @@ pub const TypeInfo = union(enum) {
     pub const Array = struct {
         len: comptime_int,
         child: type,
+
         /// The type of the sentinel is the element type of the array, which is
         /// the value of the `child` field in this struct. However there is no way
         /// to refer to that type here, so we use `var`.
lib/std/child_process.zig
@@ -259,7 +259,7 @@ pub const ChildProcess = struct {
     }
 
     fn handleWaitResult(self: *ChildProcess, status: u32) void {
-        // TODO https://github.com/ziglang/zig/issues/3190 
+        // TODO https://github.com/ziglang/zig/issues/3190
         var term = self.cleanupAfterWait(status);
         self.term = term;
     }
lib/std/fifo.zig
@@ -148,7 +148,7 @@ pub fn LinearFifo(
             var start = self.head + offset;
             if (start >= self.buf.len) {
                 start -= self.buf.len;
-                return self.buf[start..self.count - offset];
+                return self.buf[start .. self.count - offset];
             } else {
                 const end = math.min(self.head + self.count, self.buf.len);
                 return self.buf[start..end];
lib/std/mutex.zig
@@ -74,7 +74,7 @@ else
             pub fn release(self: Held) void {
                 switch (@atomicRmw(State, &self.mutex.state, .Xchg, .Unlocked, .Release)) {
                     .Locked => {},
-                    .Sleeping => self.mutex.parker.unpark(@ptrCast(*const u32,  &self.mutex.state)),
+                    .Sleeping => self.mutex.parker.unpark(@ptrCast(*const u32, &self.mutex.state)),
                     .Unlocked => unreachable, // unlocking an unlocked mutex
                     else => unreachable, // should never be anything else
                 }
@@ -112,7 +112,7 @@ else
                 if (@atomicRmw(State, &self.state, .Xchg, .Sleeping, .Acquire) == .Unlocked)
                     return Held{ .mutex = self };
                 state = .Sleeping;
-                self.parker.park(@ptrCast(*const u32,  &self.state), @enumToInt(State.Sleeping));
+                self.parker.park(@ptrCast(*const u32, &self.state), @enumToInt(State.Sleeping));
             }
         }
     };
lib/std/net.zig
@@ -1362,7 +1362,7 @@ pub const StreamServer = struct {
 
     pub const Connection = struct {
         file: fs.File,
-        address: Address
+        address: Address,
     };
 
     /// If this function succeeds, the returned `Connection` is a caller-managed resource.
lib/std/os.zig
@@ -2753,8 +2753,8 @@ pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {
 
 /// Used to convert a slice to a null terminated slice on the stack.
 /// TODO https://github.com/ziglang/zig/issues/287
-pub fn toPosixPath(file_path: []const u8) ![PATH_MAX-1:0]u8 {
-    var path_with_null: [PATH_MAX-1:0]u8 = undefined;
+pub fn toPosixPath(file_path: []const u8) ![PATH_MAX - 1:0]u8 {
+    var path_with_null: [PATH_MAX - 1:0]u8 = undefined;
     // >= rather than > to make room for the null byte
     if (file_path.len >= PATH_MAX) return error.NameTooLong;
     mem.copy(u8, &path_with_null, file_path);