Replace fmt with new fmtstream
This commit is contained in:
parent
ed7f30e1cd
commit
4aae55b4cc
@ -348,7 +348,7 @@ test "std.atomic.Queue dump" {
|
||||
fbs.reset();
|
||||
try queue.dumpToStream(fbs.outStream());
|
||||
|
||||
var expected = try std.fmtstream.bufPrint(expected_buffer[0..],
|
||||
var expected = try std.fmt.bufPrint(expected_buffer[0..],
|
||||
\\head: 0x{x}=1
|
||||
\\ (null)
|
||||
\\tail: 0x{x}=1
|
||||
@ -368,7 +368,7 @@ test "std.atomic.Queue dump" {
|
||||
fbs.reset();
|
||||
try queue.dumpToStream(fbs.outStream());
|
||||
|
||||
expected = try std.fmtstream.bufPrint(expected_buffer[0..],
|
||||
expected = try std.fmt.bufPrint(expected_buffer[0..],
|
||||
\\head: 0x{x}=1
|
||||
\\ 0x{x}=2
|
||||
\\ (null)
|
||||
|
@ -65,11 +65,11 @@ pub const Buffer = struct {
|
||||
}
|
||||
|
||||
pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: var) !Buffer {
|
||||
const size = std.fmtstream.count(format, args) catch |err| switch (err) {
|
||||
const size = std.fmt.count(format, args) catch |err| switch (err) {
|
||||
error.Overflow => return error.OutOfMemory,
|
||||
};
|
||||
var self = try Buffer.initSize(allocator, size);
|
||||
assert((std.fmtstream.bufPrint(self.list.items, format, args) catch unreachable).len == size);
|
||||
assert((std.fmt.bufPrint(self.list.items, format, args) catch unreachable).len == size);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -426,27 +426,27 @@ pub const Version = struct {
|
||||
pub fn parse(text: []const u8) !Version {
|
||||
var it = std.mem.separate(text, ".");
|
||||
return Version{
|
||||
.major = try std.fmtstream.parseInt(u32, it.next() orelse return error.InvalidVersion, 10),
|
||||
.minor = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10),
|
||||
.patch = try std.fmtstream.parseInt(u32, it.next() orelse "0", 10),
|
||||
.major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10),
|
||||
.minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10),
|
||||
.patch = try std.fmt.parseInt(u32, it.next() orelse "0", 10),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
self: Version,
|
||||
comptime fmt: []const u8,
|
||||
options: std.fmtstream.FormatOptions,
|
||||
options: std.fmt.FormatOptions,
|
||||
out_stream: var,
|
||||
) !void {
|
||||
if (fmt.len == 0) {
|
||||
if (self.patch == 0) {
|
||||
if (self.minor == 0) {
|
||||
return std.fmtstream.format(out_stream, "{}", .{self.major});
|
||||
return std.fmt.format(out_stream, "{}", .{self.major});
|
||||
} else {
|
||||
return std.fmtstream.format(out_stream, "{}.{}", .{ self.major, self.minor });
|
||||
return std.fmt.format(out_stream, "{}.{}", .{ self.major, self.minor });
|
||||
}
|
||||
} else {
|
||||
return std.fmtstream.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });
|
||||
return std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });
|
||||
}
|
||||
} else {
|
||||
@compileError("Unknown format string: '" ++ fmt ++ "'");
|
||||
|
509
lib/std/fmt.zig
509
lib/std/fmt.zig
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -349,7 +349,7 @@ pub const Headers = struct {
|
||||
pub fn format(
|
||||
self: Self,
|
||||
comptime fmt: []const u8,
|
||||
options: std.fmtstream.FormatOptions,
|
||||
options: std.fmt.FormatOptions,
|
||||
out_stream: var,
|
||||
) !void {
|
||||
for (self.toSlice()) |entry| {
|
||||
@ -591,5 +591,5 @@ test "Headers.format" {
|
||||
\\foo: bar
|
||||
\\cookie: somevalue
|
||||
\\
|
||||
, try std.fmtstream.bufPrint(buf[0..], "{}", .{h}));
|
||||
, try std.fmt.bufPrint(buf[0..], "{}", .{h}));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ pub fn OutStream(
|
||||
}
|
||||
|
||||
pub fn print(self: Self, comptime format: []const u8, args: var) Error!void {
|
||||
return std.fmtstream.format(self, format, args);
|
||||
return std.fmt.format(self, format, args);
|
||||
}
|
||||
|
||||
pub fn writeByte(self: Self, byte: u8) Error!void {
|
||||
|
@ -2257,10 +2257,10 @@ pub fn stringify(
|
||||
const T = @TypeOf(value);
|
||||
switch (@typeInfo(T)) {
|
||||
.Float, .ComptimeFloat => {
|
||||
return std.fmtstream.formatFloatScientific(value, std.fmtstream.FormatOptions{}, out_stream);
|
||||
return std.fmt.formatFloatScientific(value, std.fmt.FormatOptions{}, out_stream);
|
||||
},
|
||||
.Int, .ComptimeInt => {
|
||||
return std.fmtstream.formatIntValue(value, "", std.fmtstream.FormatOptions{}, out_stream);
|
||||
return std.fmt.formatIntValue(value, "", std.fmt.FormatOptions{}, out_stream);
|
||||
},
|
||||
.Bool => {
|
||||
return out_stream.writeAll(if (value) "true" else "false");
|
||||
@ -2350,16 +2350,16 @@ pub fn stringify(
|
||||
// then it may be represented as a six-character sequence: a reverse solidus, followed
|
||||
// by the lowercase letter u, followed by four hexadecimal digits that encode the character's code point.
|
||||
try out_stream.writeAll("\\u");
|
||||
try std.fmtstream.formatIntValue(codepoint, "x", std.fmtstream.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
try std.fmt.formatIntValue(codepoint, "x", std.fmt.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
} else {
|
||||
// To escape an extended character that is not in the Basic Multilingual Plane,
|
||||
// the character is represented as a 12-character sequence, encoding the UTF-16 surrogate pair.
|
||||
const high = @intCast(u16, (codepoint - 0x10000) >> 10) + 0xD800;
|
||||
const low = @intCast(u16, codepoint & 0x3FF) + 0xDC00;
|
||||
try out_stream.writeAll("\\u");
|
||||
try std.fmtstream.formatIntValue(high, "x", std.fmtstream.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
try std.fmt.formatIntValue(high, "x", std.fmt.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
try out_stream.writeAll("\\u");
|
||||
try std.fmtstream.formatIntValue(low, "x", std.fmtstream.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
try std.fmt.formatIntValue(low, "x", std.fmt.FormatOptions{ .width = 4, .fill = '0' }, out_stream);
|
||||
}
|
||||
i += ulen - 1;
|
||||
},
|
||||
|
@ -518,7 +518,7 @@ pub const Int = struct {
|
||||
pub fn format(
|
||||
self: Int,
|
||||
comptime fmt: []const u8,
|
||||
options: std.fmtstream.FormatOptions,
|
||||
options: std.fmt.FormatOptions,
|
||||
out_stream: var,
|
||||
) FmtError!void {
|
||||
self.assertWritable();
|
||||
|
@ -268,14 +268,14 @@ pub const Address = extern union {
|
||||
pub fn format(
|
||||
self: Address,
|
||||
comptime fmt: []const u8,
|
||||
options: std.fmtstream.FormatOptions,
|
||||
options: std.fmt.FormatOptions,
|
||||
out_stream: var,
|
||||
) !void {
|
||||
switch (self.any.family) {
|
||||
os.AF_INET => {
|
||||
const port = mem.bigToNative(u16, self.in.port);
|
||||
const bytes = @ptrCast(*const [4]u8, &self.in.addr);
|
||||
try std.fmtstream.format(out_stream, "{}.{}.{}.{}:{}", .{
|
||||
try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{
|
||||
bytes[0],
|
||||
bytes[1],
|
||||
bytes[2],
|
||||
@ -286,7 +286,7 @@ pub const Address = extern union {
|
||||
os.AF_INET6 => {
|
||||
const port = mem.bigToNative(u16, self.in6.port);
|
||||
if (mem.eql(u8, self.in6.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
|
||||
try std.fmtstream.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{
|
||||
try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{
|
||||
self.in6.addr[12],
|
||||
self.in6.addr[13],
|
||||
self.in6.addr[14],
|
||||
@ -317,19 +317,19 @@ pub const Address = extern union {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
try std.fmtstream.format(out_stream, "{x}", .{native_endian_parts[i]});
|
||||
try std.fmt.format(out_stream, "{x}", .{native_endian_parts[i]});
|
||||
if (i != native_endian_parts.len - 1) {
|
||||
try out_stream.writeAll(":");
|
||||
}
|
||||
}
|
||||
try std.fmtstream.format(out_stream, "]:{}", .{port});
|
||||
try std.fmt.format(out_stream, "]:{}", .{port});
|
||||
},
|
||||
os.AF_UNIX => {
|
||||
if (!has_unix_sockets) {
|
||||
unreachable;
|
||||
}
|
||||
|
||||
try std.fmtstream.format(out_stream, "{}", .{&self.un.path});
|
||||
try std.fmt.format(out_stream, "{}", .{&self.un.path});
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
@ -438,7 +438,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
|
||||
const name_c = try std.cstr.addNullByte(allocator, name);
|
||||
defer allocator.free(name_c);
|
||||
|
||||
const port_c = try std.fmtstream.allocPrint(allocator, "{}\x00", .{port});
|
||||
const port_c = try std.fmt.allocPrint(allocator, "{}\x00", .{port});
|
||||
defer allocator.free(port_c);
|
||||
|
||||
const hints = os.addrinfo{
|
||||
|
@ -29,7 +29,7 @@ test "parse and render IPv6 addresses" {
|
||||
};
|
||||
for (ips) |ip, i| {
|
||||
var addr = net.Address.parseIp6(ip, 0) catch unreachable;
|
||||
var newIp = std.fmtstream.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
|
||||
var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
|
||||
std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3]));
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ test "parse and render IPv4 addresses" {
|
||||
"127.0.0.1",
|
||||
}) |ip| {
|
||||
var addr = net.Address.parseIp4(ip, 0) catch unreachable;
|
||||
var newIp = std.fmtstream.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
|
||||
var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
|
||||
std.testing.expect(std.mem.eql(u8, ip, newIp[0 .. newIp.len - 2]));
|
||||
}
|
||||
|
||||
|
@ -3049,7 +3049,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
|
||||
defer close(fd);
|
||||
|
||||
var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
|
||||
const proc_path = std.fmtstream.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
|
||||
const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
|
||||
|
||||
return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ pub const Guid = extern struct {
|
||||
pub fn format(
|
||||
self: @This(),
|
||||
comptime f: []const u8,
|
||||
options: std.fmtstream.FormatOptions,
|
||||
options: std.fmt.FormatOptions,
|
||||
out_stream: var,
|
||||
) Errors!void {
|
||||
if (f.len == 0) {
|
||||
return std.fmtstream.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
|
||||
return std.fmt.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
|
||||
self.time_low,
|
||||
self.time_mid,
|
||||
self.time_high_and_version,
|
||||
|
@ -130,11 +130,11 @@ pub const Progress = struct {
|
||||
var end: usize = 0;
|
||||
if (self.columns_written > 0) {
|
||||
// restore cursor position
|
||||
end += (std.fmtstream.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
|
||||
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
|
||||
self.columns_written = 0;
|
||||
|
||||
// clear rest of line
|
||||
end += (std.fmtstream.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
|
||||
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
|
||||
}
|
||||
|
||||
if (!self.done) {
|
||||
@ -185,7 +185,7 @@ pub const Progress = struct {
|
||||
}
|
||||
|
||||
fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: var) void {
|
||||
if (std.fmtstream.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
|
||||
if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
|
||||
const amt = written.len;
|
||||
end.* += amt;
|
||||
self.columns_written += amt;
|
||||
|
@ -2,7 +2,7 @@ const root = @import("@build");
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const io = std.io;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const Builder = std.build.Builder;
|
||||
const mem = std.mem;
|
||||
const process = std.process;
|
||||
@ -153,7 +153,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
|
||||
const allocator = builder.allocator;
|
||||
for (builder.top_level_steps.toSliceConst()) |top_level_step| {
|
||||
const name = if (&top_level_step.step == builder.default_step)
|
||||
try fmtstream.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
|
||||
try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
|
||||
else
|
||||
top_level_step.step.name;
|
||||
try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });
|
||||
@ -175,7 +175,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
|
||||
try out_stream.print(" (none)\n", .{});
|
||||
} else {
|
||||
for (builder.available_options_list.toSliceConst()) |option| {
|
||||
const name = try fmtstream.allocPrint(allocator, " -D{}=[{}]", .{
|
||||
const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{
|
||||
option.name,
|
||||
Builder.typeIdName(option.type_id),
|
||||
});
|
||||
|
@ -38,7 +38,6 @@ pub const elf = @import("elf.zig");
|
||||
pub const event = @import("event.zig");
|
||||
pub const fifo = @import("fifo.zig");
|
||||
pub const fmt = @import("fmt.zig");
|
||||
pub const fmtstream = @import("fmtstream.zig");
|
||||
pub const fs = @import("fs.zig");
|
||||
pub const hash = @import("hash.zig");
|
||||
pub const hash_map = @import("hash_map.zig");
|
||||
|
@ -972,7 +972,7 @@ pub const Target = struct {
|
||||
}
|
||||
|
||||
pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![:0]u8 {
|
||||
return std.fmtstream.allocPrint0(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
|
||||
return std.fmt.allocPrint0(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
|
||||
}
|
||||
|
||||
pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![:0]u8 {
|
||||
@ -1158,7 +1158,7 @@ pub const Target = struct {
|
||||
var result: DynamicLinker = .{};
|
||||
const S = struct {
|
||||
fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker {
|
||||
r.max_byte = @intCast(u8, (std.fmtstream.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
|
||||
r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
|
||||
return r.*;
|
||||
}
|
||||
fn copy(r: *DynamicLinker, s: []const u8) DynamicLinker {
|
||||
|
@ -573,7 +573,7 @@ pub const CrossTarget = struct {
|
||||
.Dynamic => "",
|
||||
};
|
||||
|
||||
return std.fmtstream.allocPrint0(allocator, "{}-{}{}", .{ arch, os, static_suffix });
|
||||
return std.fmt.allocPrint0(allocator, "{}-{}{}", .{ arch, os, static_suffix });
|
||||
}
|
||||
|
||||
pub const Executor = union(enum) {
|
||||
|
@ -130,7 +130,7 @@ pub const NativePaths = struct {
|
||||
}
|
||||
|
||||
pub fn addIncludeDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
|
||||
const item = try std.fmtstream.allocPrint0(self.include_dirs.allocator, fmt, args);
|
||||
const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);
|
||||
errdefer self.include_dirs.allocator.free(item);
|
||||
try self.include_dirs.append(item);
|
||||
}
|
||||
@ -140,7 +140,7 @@ pub const NativePaths = struct {
|
||||
}
|
||||
|
||||
pub fn addLibDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
|
||||
const item = try std.fmtstream.allocPrint0(self.lib_dirs.allocator, fmt, args);
|
||||
const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);
|
||||
errdefer self.lib_dirs.allocator.free(item);
|
||||
try self.lib_dirs.append(item);
|
||||
}
|
||||
@ -150,7 +150,7 @@ pub const NativePaths = struct {
|
||||
}
|
||||
|
||||
pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
|
||||
const item = try std.fmtstream.allocPrint0(self.warnings.allocator, fmt, args);
|
||||
const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);
|
||||
errdefer self.warnings.allocator.free(item);
|
||||
try self.warnings.append(item);
|
||||
}
|
||||
|
@ -1051,7 +1051,7 @@ pub const Compilation = struct {
|
||||
}
|
||||
|
||||
fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: var) !void {
|
||||
const text = try std.fmtstream.allocPrint(self.gpa(), fmt, args);
|
||||
const text = try std.fmt.allocPrint(self.gpa(), fmt, args);
|
||||
errdefer self.gpa().free(text);
|
||||
|
||||
const msg = try Msg.createFromScope(self, tree_scope, span, text);
|
||||
@ -1061,7 +1061,7 @@ pub const Compilation = struct {
|
||||
}
|
||||
|
||||
fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: var) !void {
|
||||
const text = try std.fmtstream.allocPrint(self.gpa(), fmt, args);
|
||||
const text = try std.fmt.allocPrint(self.gpa(), fmt, args);
|
||||
errdefer self.gpa().free(text);
|
||||
|
||||
const msg = try Msg.createFromCli(self, realpath, text);
|
||||
@ -1154,7 +1154,7 @@ pub const Compilation = struct {
|
||||
const tmp_dir = try self.getTmpDir();
|
||||
const file_prefix = self.getRandomFileName();
|
||||
|
||||
const file_name = try std.fmtstream.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
|
||||
const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
|
||||
defer self.gpa().free(file_name);
|
||||
|
||||
const full_path = try fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
|
||||
|
@ -893,7 +893,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {
|
||||
|
||||
fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {
|
||||
var buf: [80]u8 = undefined;
|
||||
var text = try std.fmtstream.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
|
||||
var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
|
||||
try out.write(text);
|
||||
var i: usize = text.len;
|
||||
const end = 79;
|
||||
@ -979,13 +979,13 @@ fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {
|
||||
|
||||
fn printDecValue(out: var, value: u64, width: u8) !void {
|
||||
var buffer: [20]u8 = undefined;
|
||||
const len = std.fmtstream.formatIntBuf(buffer[0..], value, 10, false, width);
|
||||
const len = std.fmt.formatIntBuf(buffer[0..], value, 10, false, width);
|
||||
try out.write(buffer[0..len]);
|
||||
}
|
||||
|
||||
fn printHexValue(out: var, value: u64, width: u8) !void {
|
||||
var buffer: [16]u8 = undefined;
|
||||
const len = std.fmtstream.formatIntBuf(buffer[0..], value, 16, false, width);
|
||||
const len = std.fmt.formatIntBuf(buffer[0..], value, 16, false, width);
|
||||
try out.write(buffer[0..len]);
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
|
||||
const allocator = args.allocator;
|
||||
|
||||
const cc_exe = std.os.getenvZ("CC") orelse default_cc_exe;
|
||||
const arg1 = try std.fmtstream.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});
|
||||
const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});
|
||||
defer allocator.free(arg1);
|
||||
const argv = [_][]const u8{ cc_exe, arg1 };
|
||||
|
||||
|
@ -296,13 +296,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
|
||||
|
||||
const is_library = ctx.comp.kind == .Lib;
|
||||
|
||||
const out_arg = try std.fmtstream.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
|
||||
const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));
|
||||
|
||||
if (ctx.comp.haveLibC()) {
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));
|
||||
}
|
||||
|
||||
if (ctx.link_in_crt) {
|
||||
@ -310,20 +310,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
|
||||
const d_str = if (ctx.comp.build_mode == .Debug) "d" else "";
|
||||
|
||||
if (ctx.comp.is_static) {
|
||||
const cmt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
|
||||
const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr));
|
||||
} else {
|
||||
const msvcrt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
|
||||
const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr));
|
||||
}
|
||||
|
||||
const vcruntime_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
|
||||
const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
|
||||
lib_str,
|
||||
d_str,
|
||||
});
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr));
|
||||
|
||||
const crt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
|
||||
const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr));
|
||||
|
||||
// Visual C++ 2015 Conformance Changes
|
||||
@ -383,7 +383,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
|
||||
.IPhoneOS => try ctx.args.append("-iphoneos_version_min"),
|
||||
.IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"),
|
||||
}
|
||||
const ver_str = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
|
||||
const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
|
||||
platform.major,
|
||||
platform.minor,
|
||||
platform.micro,
|
||||
@ -445,7 +445,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
|
||||
try ctx.args.append("-lSystem");
|
||||
} else {
|
||||
if (mem.indexOfScalar(u8, lib.name, '/') == null) {
|
||||
const arg = try std.fmtstream.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
|
||||
const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
|
||||
try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));
|
||||
} else {
|
||||
const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name);
|
||||
|
@ -138,7 +138,7 @@ pub fn cmdTargets(
|
||||
for (available_glibcs) |glibc| {
|
||||
try jws.arrayElem();
|
||||
|
||||
const tmp = try std.fmtstream.allocPrint(allocator, "{}", .{glibc});
|
||||
const tmp = try std.fmt.allocPrint(allocator, "{}", .{glibc});
|
||||
defer allocator.free(tmp);
|
||||
try jws.emitString(tmp);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ pub const TestContext = struct {
|
||||
msg: []const u8,
|
||||
) !void {
|
||||
var file_index_buf: [20]u8 = undefined;
|
||||
const file_index = try std.fmtstream.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
|
||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||
@ -114,10 +114,10 @@ pub const TestContext = struct {
|
||||
expected_output: []const u8,
|
||||
) !void {
|
||||
var file_index_buf: [20]u8 = undefined;
|
||||
const file_index = try std.fmtstream.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
|
||||
|
||||
const output_file = try std.fmtstream.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
|
||||
const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
|
||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||
try std.fs.cwd().makePath(dirname);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ const Scope = struct {
|
||||
var proposed_name = name;
|
||||
while (scope.contains(proposed_name)) {
|
||||
scope.mangle_count += 1;
|
||||
proposed_name = try std.fmtstream.allocPrint(c.a(), "{}_{}", .{ name, scope.mangle_count });
|
||||
proposed_name = try std.fmt.allocPrint(c.a(), "{}_{}", .{ name, scope.mangle_count });
|
||||
}
|
||||
try scope.variables.push(.{ .name = name, .alias = proposed_name });
|
||||
return proposed_name;
|
||||
@ -246,7 +246,7 @@ pub const Context = struct {
|
||||
|
||||
const line = ZigClangSourceManager_getSpellingLineNumber(c.source_manager, spelling_loc);
|
||||
const column = ZigClangSourceManager_getSpellingColumnNumber(c.source_manager, spelling_loc);
|
||||
return std.fmtstream.allocPrint(c.a(), "{}:{}:{}", .{ filename, line, column });
|
||||
return std.fmt.allocPrint(c.a(), "{}:{}:{}", .{ filename, line, column });
|
||||
}
|
||||
};
|
||||
|
||||
@ -516,7 +516,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
|
||||
|
||||
const arg_name = blk: {
|
||||
const param_prefix = if (is_const) "" else "arg_";
|
||||
const bare_arg_name = try std.fmtstream.allocPrint(c.a(), "{}{}", .{ param_prefix, mangled_param_name });
|
||||
const bare_arg_name = try std.fmt.allocPrint(c.a(), "{}{}", .{ param_prefix, mangled_param_name });
|
||||
break :blk try block_scope.makeMangledName(c, bare_arg_name);
|
||||
};
|
||||
|
||||
@ -560,7 +560,7 @@ fn visitVarDecl(c: *Context, var_decl: *const ZigClangVarDecl) Error!void {
|
||||
|
||||
// TODO https://github.com/ziglang/zig/issues/3756
|
||||
// TODO https://github.com/ziglang/zig/issues/1802
|
||||
const checked_name = if (isZigPrimitiveType(var_name)) try std.fmtstream.allocPrint(c.a(), "{}_{}", .{var_name, c.getMangle()}) else var_name;
|
||||
const checked_name = if (isZigPrimitiveType(var_name)) try std.fmt.allocPrint(c.a(), "{}_{}", .{ var_name, c.getMangle() }) else var_name;
|
||||
const var_decl_loc = ZigClangVarDecl_getLocation(var_decl);
|
||||
|
||||
const qual_type = ZigClangVarDecl_getTypeSourceInfo_getType(var_decl);
|
||||
@ -620,7 +620,7 @@ fn visitVarDecl(c: *Context, var_decl: *const ZigClangVarDecl) Error!void {
|
||||
_ = try appendToken(rp.c, .LParen, "(");
|
||||
const expr = try transCreateNodeStringLiteral(
|
||||
rp.c,
|
||||
try std.fmtstream.allocPrint(rp.c.a(), "\"{}\"", .{str_ptr[0..str_len]}),
|
||||
try std.fmt.allocPrint(rp.c.a(), "\"{}\"", .{str_ptr[0..str_len]}),
|
||||
);
|
||||
_ = try appendToken(rp.c, .RParen, ")");
|
||||
|
||||
@ -677,7 +677,7 @@ fn transTypeDef(c: *Context, typedef_decl: *const ZigClangTypedefNameDecl, top_l
|
||||
|
||||
// TODO https://github.com/ziglang/zig/issues/3756
|
||||
// TODO https://github.com/ziglang/zig/issues/1802
|
||||
const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmtstream.allocPrint(c.a(), "{}_{}", .{typedef_name, c.getMangle()}) else typedef_name;
|
||||
const checked_name = if (isZigPrimitiveType(typedef_name)) try std.fmt.allocPrint(c.a(), "{}_{}", .{ typedef_name, c.getMangle() }) else typedef_name;
|
||||
|
||||
if (mem.eql(u8, checked_name, "uint8_t"))
|
||||
return transTypeDefAsBuiltin(c, typedef_decl, "u8")
|
||||
@ -738,7 +738,7 @@ fn transRecordDecl(c: *Context, record_decl: *const ZigClangRecordDecl) Error!?*
|
||||
// Record declarations such as `struct {...} x` have no name but they're not
|
||||
// anonymous hence here isAnonymousStructOrUnion is not needed
|
||||
if (bare_name.len == 0) {
|
||||
bare_name = try std.fmtstream.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
bare_name = try std.fmt.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
is_unnamed = true;
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ fn transRecordDecl(c: *Context, record_decl: *const ZigClangRecordDecl) Error!?*
|
||||
return null;
|
||||
}
|
||||
|
||||
const name = try std.fmtstream.allocPrint(c.a(), "{}_{}", .{ container_kind_name, bare_name });
|
||||
const name = try std.fmt.allocPrint(c.a(), "{}_{}", .{ container_kind_name, bare_name });
|
||||
_ = try c.decl_table.put(@ptrToInt(ZigClangRecordDecl_getCanonicalDecl(record_decl)), name);
|
||||
|
||||
const node = try transCreateNodeVarDecl(c, !is_unnamed, true, name);
|
||||
@ -812,7 +812,7 @@ fn transRecordDecl(c: *Context, record_decl: *const ZigClangRecordDecl) Error!?*
|
||||
var is_anon = false;
|
||||
var raw_name = try c.str(ZigClangNamedDecl_getName_bytes_begin(@ptrCast(*const ZigClangNamedDecl, field_decl)));
|
||||
if (ZigClangFieldDecl_isAnonymousStructOrUnion(field_decl)) {
|
||||
raw_name = try std.fmtstream.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
raw_name = try std.fmt.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
is_anon = true;
|
||||
}
|
||||
const field_name = try appendIdentifier(c, raw_name);
|
||||
@ -882,11 +882,11 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No
|
||||
var bare_name = try c.str(ZigClangNamedDecl_getName_bytes_begin(@ptrCast(*const ZigClangNamedDecl, enum_decl)));
|
||||
var is_unnamed = false;
|
||||
if (bare_name.len == 0) {
|
||||
bare_name = try std.fmtstream.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
bare_name = try std.fmt.allocPrint(c.a(), "unnamed_{}", .{c.getMangle()});
|
||||
is_unnamed = true;
|
||||
}
|
||||
|
||||
const name = try std.fmtstream.allocPrint(c.a(), "enum_{}", .{bare_name});
|
||||
const name = try std.fmt.allocPrint(c.a(), "enum_{}", .{bare_name});
|
||||
_ = try c.decl_table.put(@ptrToInt(ZigClangEnumDecl_getCanonicalDecl(enum_decl)), name);
|
||||
const node = try transCreateNodeVarDecl(c, !is_unnamed, true, name);
|
||||
node.eq_token = try appendToken(c, .Equal, "=");
|
||||
@ -1754,9 +1754,9 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 {
|
||||
// Handle the remaining escapes Zig doesn't support by turning them
|
||||
// into their respective hex representation
|
||||
if (std.ascii.isCntrl(c))
|
||||
return std.fmtstream.bufPrint(char_buf[0..], "\\x{x:0<2}", .{c}) catch unreachable
|
||||
return std.fmt.bufPrint(char_buf[0..], "\\x{x:0<2}", .{c}) catch unreachable
|
||||
else
|
||||
return std.fmtstream.bufPrint(char_buf[0..], "{c}", .{c}) catch unreachable;
|
||||
return std.fmt.bufPrint(char_buf[0..], "{c}", .{c}) catch unreachable;
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -2436,7 +2436,7 @@ fn transCase(
|
||||
) TransError!*ast.Node {
|
||||
const block_scope = scope.findBlockScope(rp.c) catch unreachable;
|
||||
const switch_scope = scope.getSwitch();
|
||||
const label = try std.fmtstream.allocPrint(rp.c.a(), "__case_{}", .{switch_scope.cases.len - @boolToInt(switch_scope.has_default)});
|
||||
const label = try std.fmt.allocPrint(rp.c.a(), "__case_{}", .{switch_scope.cases.len - @boolToInt(switch_scope.has_default)});
|
||||
_ = try appendToken(rp.c, .Semicolon, ";");
|
||||
|
||||
const expr = if (ZigClangCaseStmt_getRHS(stmt)) |rhs| blk: {
|
||||
@ -4607,7 +4607,7 @@ fn finishTransFnProto(
|
||||
_ = try appendToken(rp.c, .LParen, "(");
|
||||
const expr = try transCreateNodeStringLiteral(
|
||||
rp.c,
|
||||
try std.fmtstream.allocPrint(rp.c.a(), "\"{}\"", .{str_ptr[0..str_len]}),
|
||||
try std.fmt.allocPrint(rp.c.a(), "\"{}\"", .{str_ptr[0..str_len]}),
|
||||
);
|
||||
_ = try appendToken(rp.c, .RParen, ")");
|
||||
|
||||
@ -4866,7 +4866,7 @@ fn transPreprocessorEntities(c: *Context, unit: *ZigClangASTUnit) Error!void {
|
||||
const name = try c.str(raw_name);
|
||||
// TODO https://github.com/ziglang/zig/issues/3756
|
||||
// TODO https://github.com/ziglang/zig/issues/1802
|
||||
const mangled_name = if (isZigPrimitiveType(name)) try std.fmtstream.allocPrint(c.a(), "{}_{}", .{name, c.getMangle()}) else name;
|
||||
const mangled_name = if (isZigPrimitiveType(name)) try std.fmt.allocPrint(c.a(), "{}_{}", .{ name, c.getMangle() }) else name;
|
||||
if (scope.containsNow(mangled_name)) {
|
||||
continue;
|
||||
}
|
||||
@ -5151,11 +5151,11 @@ fn parseCNumLit(c: *Context, tok: *CToken, source: []const u8, source_loc: ZigCl
|
||||
switch (lit_bytes[1]) {
|
||||
'0'...'7' => {
|
||||
// Octal
|
||||
lit_bytes = try std.fmtstream.allocPrint(c.a(), "0o{}", .{lit_bytes});
|
||||
lit_bytes = try std.fmt.allocPrint(c.a(), "0o{}", .{lit_bytes});
|
||||
},
|
||||
'X' => {
|
||||
// Hexadecimal with capital X, valid in C but not in Zig
|
||||
lit_bytes = try std.fmtstream.allocPrint(c.a(), "0x{}", .{lit_bytes[2..]});
|
||||
lit_bytes = try std.fmt.allocPrint(c.a(), "0x{}", .{lit_bytes[2..]});
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
@ -5186,7 +5186,7 @@ fn parseCNumLit(c: *Context, tok: *CToken, source: []const u8, source_loc: ZigCl
|
||||
return &cast_node.base;
|
||||
} else if (tok.id == .FloatLiteral) {
|
||||
if (lit_bytes[0] == '.')
|
||||
lit_bytes = try std.fmtstream.allocPrint(c.a(), "0{}", .{lit_bytes});
|
||||
lit_bytes = try std.fmt.allocPrint(c.a(), "0{}", .{lit_bytes});
|
||||
if (tok.id.FloatLiteral == .None) {
|
||||
return transCreateNodeFloat(c, lit_bytes);
|
||||
}
|
||||
@ -5319,7 +5319,7 @@ fn zigifyEscapeSequences(ctx: *Context, source_bytes: []const u8, name: []const
|
||||
num += c - 'A' + 10;
|
||||
},
|
||||
else => {
|
||||
i += std.fmtstream.formatIntBuf(bytes[i..], num, 16, false, std.fmtstream.FormatOptions{ .fill = '0', .width = 2 });
|
||||
i += std.fmt.formatIntBuf(bytes[i..], num, 16, false, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
|
||||
num = 0;
|
||||
if (c == '\\')
|
||||
state = .Escape
|
||||
@ -5345,7 +5345,7 @@ fn zigifyEscapeSequences(ctx: *Context, source_bytes: []const u8, name: []const
|
||||
};
|
||||
num += c - '0';
|
||||
} else {
|
||||
i += std.fmtstream.formatIntBuf(bytes[i..], num, 16, false, std.fmtstream.FormatOptions{ .fill = '0', .width = 2 });
|
||||
i += std.fmt.formatIntBuf(bytes[i..], num, 16, false, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
|
||||
num = 0;
|
||||
count = 0;
|
||||
if (c == '\\')
|
||||
@ -5359,7 +5359,7 @@ fn zigifyEscapeSequences(ctx: *Context, source_bytes: []const u8, name: []const
|
||||
}
|
||||
}
|
||||
if (state == .Hex or state == .Octal)
|
||||
i += std.fmtstream.formatIntBuf(bytes[i..], num, 16, false, std.fmtstream.FormatOptions{ .fill = '0', .width = 2 });
|
||||
i += std.fmt.formatIntBuf(bytes[i..], num, 16, false, std.fmt.FormatOptions{ .fill = '0', .width = 2 });
|
||||
return bytes[0..i];
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ pub const Type = struct {
|
||||
errdefer comp.gpa().destroy(self);
|
||||
|
||||
const u_or_i = "ui"[@boolToInt(key.is_signed)];
|
||||
const name = try std.fmtstream.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });
|
||||
const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });
|
||||
errdefer comp.gpa().free(name);
|
||||
|
||||
self.base.init(comp, .Int, name);
|
||||
@ -764,13 +764,13 @@ pub const Type = struct {
|
||||
.Non => "",
|
||||
};
|
||||
const name = switch (self.key.alignment) {
|
||||
.Abi => try std.fmtstream.allocPrint(comp.gpa(), "{}{}{}{}", .{
|
||||
.Abi => try std.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{
|
||||
size_str,
|
||||
mut_str,
|
||||
vol_str,
|
||||
self.key.child_type.name,
|
||||
}),
|
||||
.Override => |alignment| try std.fmtstream.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{
|
||||
.Override => |alignment| try std.fmt.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{
|
||||
size_str,
|
||||
alignment,
|
||||
mut_str,
|
||||
@ -845,7 +845,7 @@ pub const Type = struct {
|
||||
};
|
||||
errdefer comp.gpa().destroy(self);
|
||||
|
||||
const name = try std.fmtstream.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });
|
||||
const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });
|
||||
errdefer comp.gpa().free(name);
|
||||
|
||||
self.base.init(comp, .Array, name);
|
||||
|
@ -4,7 +4,7 @@ const std = @import("std");
|
||||
const builtin = std.builtin;
|
||||
const build = std.build;
|
||||
const ArrayList = std.ArrayList;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const mem = std.mem;
|
||||
const fs = std.fs;
|
||||
const warn = std.debug.warn;
|
||||
@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {
|
||||
|
||||
switch (case.special) {
|
||||
Special.Asm => {
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "assemble-and-link {}", .{
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{
|
||||
case.name,
|
||||
}) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {
|
||||
},
|
||||
Special.None => {
|
||||
for (self.modes) |mode| {
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
"compare-output",
|
||||
case.name,
|
||||
@tagName(mode),
|
||||
@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
|
||||
}
|
||||
},
|
||||
Special.RuntimeSafety => {
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
const std = @import("std");
|
||||
const build = std.build;
|
||||
const ArrayList = std.ArrayList;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const mem = std.mem;
|
||||
const fs = std.fs;
|
||||
const warn = std.debug.warn;
|
||||
@ -76,7 +76,7 @@ pub const RunTranslatedCContext = struct {
|
||||
pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
|
||||
const b = self.b;
|
||||
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
const std = @import("std");
|
||||
const build = std.build;
|
||||
const ArrayList = std.ArrayList;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const mem = std.mem;
|
||||
const fs = std.fs;
|
||||
const warn = std.debug.warn;
|
||||
@ -99,7 +99,7 @@ pub const TranslateCContext = struct {
|
||||
const b = self.b;
|
||||
|
||||
const translate_c_cmd = "translate-c";
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
const expect = @import("std").testing.expect;
|
||||
const mem = @import("std").mem;
|
||||
const fmtstream = @import("std").fmtstream;
|
||||
const fmt = @import("std").fmt;
|
||||
|
||||
const ET = union(enum) {
|
||||
SINT: i32,
|
||||
@ -8,8 +8,8 @@ const ET = union(enum) {
|
||||
|
||||
pub fn print(a: *const ET, buf: []u8) anyerror!usize {
|
||||
return switch (a.*) {
|
||||
ET.SINT => |x| fmtstream.formatIntBuf(buf, x, 10, false, fmtstream.FormatOptions{}),
|
||||
ET.UINT => |x| fmtstream.formatIntBuf(buf, x, 10, false, fmtstream.FormatOptions{}),
|
||||
ET.SINT => |x| fmt.formatIntBuf(buf, x, 10, false, fmt.FormatOptions{}),
|
||||
ET.UINT => |x| fmt.formatIntBuf(buf, x, 10, false, fmt.FormatOptions{}),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ const Buffer = std.Buffer;
|
||||
const io = std.io;
|
||||
const fs = std.fs;
|
||||
const mem = std.mem;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const ArrayList = std.ArrayList;
|
||||
const Mode = builtin.Mode;
|
||||
const LibExeObjStep = build.LibExeObjStep;
|
||||
@ -484,7 +484,7 @@ pub const StackTracesContext = struct {
|
||||
const expect_for_mode = expect[@enumToInt(mode)];
|
||||
if (expect_for_mode.len == 0) continue;
|
||||
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
"stack-trace",
|
||||
name,
|
||||
@tagName(mode),
|
||||
@ -943,7 +943,7 @@ pub const CompileErrorContext = struct {
|
||||
pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
|
||||
const b = self.b;
|
||||
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "compile-error {}", .{
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", .{
|
||||
case.name,
|
||||
}) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
@ -1009,7 +1009,7 @@ pub const StandaloneContext = struct {
|
||||
const b = self.b;
|
||||
|
||||
for (self.modes) |mode| {
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "build {} ({})", .{
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", .{
|
||||
root_src,
|
||||
@tagName(mode),
|
||||
}) catch unreachable;
|
||||
@ -1152,7 +1152,7 @@ pub const GenHContext = struct {
|
||||
const b = self.b;
|
||||
|
||||
const mode = builtin.Mode.Debug;
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
|
||||
if (self.test_filter) |filter| {
|
||||
if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ pub fn main() !void {
|
||||
std.debug.warn("unrecognized C ABI: {}\n", .{abi_name});
|
||||
usageAndExit(args[0]);
|
||||
};
|
||||
const generic_name = try std.fmtstream.allocPrint(allocator, "generic-{}", .{abi_name});
|
||||
const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", .{abi_name});
|
||||
|
||||
// TODO compiler crashed when I wrote this the canonical way
|
||||
var libc_targets: []const LibCTarget = undefined;
|
||||
@ -440,7 +440,7 @@ pub fn main() !void {
|
||||
.specific => |a| @tagName(a),
|
||||
else => @tagName(dest_target.arch),
|
||||
};
|
||||
const out_subpath = try std.fmtstream.allocPrint(allocator, "{}-{}-{}", .{
|
||||
const out_subpath = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{
|
||||
arch_name,
|
||||
@tagName(dest_target.os),
|
||||
@tagName(dest_target.abi),
|
||||
|
@ -1,6 +1,6 @@
|
||||
const std = @import("std");
|
||||
const fs = std.fs;
|
||||
const fmtstream = std.fmtstream;
|
||||
const fmt = std.fmt;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
// Example abilist path:
|
||||
@ -154,7 +154,7 @@ pub fn main() !void {
|
||||
const fn_set = &target_funcs_gop.kv.value.list;
|
||||
|
||||
for (lib_names) |lib_name, lib_name_index| {
|
||||
const basename = try fmtstream.allocPrint(allocator, "lib{}.abilist", .{lib_name});
|
||||
const basename = try fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name});
|
||||
const abi_list_filename = blk: {
|
||||
if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {
|
||||
break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n64", basename });
|
||||
|
Loading…
x
Reference in New Issue
Block a user