mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Convert fmt.bufPrint / fmt.allocPrint
This commit is contained in:
parent
4023ed56d4
commit
0059d9ee3e
@ -348,7 +348,7 @@ test "std.atomic.Queue dump" {
|
||||
fbs.reset();
|
||||
try queue.dumpToStream(fbs.outStream());
|
||||
|
||||
var expected = try std.fmt.bufPrint(expected_buffer[0..],
|
||||
var expected = try std.fmtstream.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.fmt.bufPrint(expected_buffer[0..],
|
||||
expected = try std.fmtstream.bufPrint(expected_buffer[0..],
|
||||
\\head: 0x{x}=1
|
||||
\\ 0x{x}=2
|
||||
\\ (null)
|
||||
|
||||
@ -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.fmt.allocPrint(allocator, "{}\x00", .{port});
|
||||
const port_c = try std.fmtstream.allocPrint(allocator, "{}\x00", .{port});
|
||||
defer allocator.free(port_c);
|
||||
|
||||
const hints = os.addrinfo{
|
||||
|
||||
@ -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.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
|
||||
const proc_path = std.fmtstream.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
|
||||
|
||||
return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
|
||||
}
|
||||
|
||||
@ -130,11 +130,11 @@ pub const Progress = struct {
|
||||
var end: usize = 0;
|
||||
if (self.columns_written > 0) {
|
||||
// restore cursor position
|
||||
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
|
||||
end += (std.fmtstream.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
|
||||
self.columns_written = 0;
|
||||
|
||||
// clear rest of line
|
||||
end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
|
||||
end += (std.fmtstream.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.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
|
||||
if (std.fmtstream.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 fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
|
||||
try fmtstream.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 fmt.allocPrint(allocator, " -D{}=[{}]", .{
|
||||
const name = try fmtstream.allocPrint(allocator, " -D{}=[{}]", .{
|
||||
option.name,
|
||||
Builder.typeIdName(option.type_id),
|
||||
});
|
||||
|
||||
@ -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.fmt.allocPrint0(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
|
||||
return std.fmtstream.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.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
|
||||
r.max_byte = @intCast(u8, (std.fmtstream.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.fmt.allocPrint0(allocator, "{}-{}{}", .{ arch, os, static_suffix });
|
||||
return std.fmtstream.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.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);
|
||||
const item = try std.fmtstream.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.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);
|
||||
const item = try std.fmtstream.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.fmt.allocPrint0(self.warnings.allocator, fmt, args);
|
||||
const item = try std.fmtstream.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.fmt.allocPrint(self.gpa(), fmt, args);
|
||||
const text = try std.fmtstream.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.fmt.allocPrint(self.gpa(), fmt, args);
|
||||
const text = try std.fmtstream.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.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
|
||||
const file_name = try std.fmtstream.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..] });
|
||||
|
||||
@ -894,7 +894,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.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
|
||||
var text = try std.fmtstream.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
|
||||
try out.write(text);
|
||||
var i: usize = text.len;
|
||||
const end = 79;
|
||||
|
||||
@ -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.fmt.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});
|
||||
const arg1 = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
|
||||
const out_arg = try std.fmtstream.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.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));
|
||||
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));
|
||||
}
|
||||
|
||||
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.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
|
||||
const cmt_lib_name = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
|
||||
const msvcrt_lib_name = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
|
||||
const vcruntime_lib_name = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
|
||||
const crt_lib_name = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
|
||||
const ver_str = try std.fmtstream.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.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
|
||||
const arg = try std.fmtstream.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.fmt.allocPrint(allocator, "{}", .{glibc});
|
||||
const tmp = try std.fmtstream.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.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file_index = try std.fmtstream.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.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
|
||||
const file_index = try std.fmtstream.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.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
|
||||
const output_file = try std.fmtstream.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
|
||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||
try std.fs.cwd().makePath(dirname);
|
||||
}
|
||||
|
||||
@ -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.fmt.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });
|
||||
const name = try std.fmtstream.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.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{
|
||||
.Abi => try std.fmtstream.allocPrint(comp.gpa(), "{}{}{}{}", .{
|
||||
size_str,
|
||||
mut_str,
|
||||
vol_str,
|
||||
self.key.child_type.name,
|
||||
}),
|
||||
.Override => |alignment| try std.fmt.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{
|
||||
.Override => |alignment| try std.fmtstream.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.fmt.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });
|
||||
const name = try std.fmtstream.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 fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{
|
||||
const annotated_case_name = fmtstream.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 = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
"compare-output",
|
||||
case.name,
|
||||
@tagName(mode),
|
||||
@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
|
||||
}
|
||||
},
|
||||
Special.RuntimeSafety => {
|
||||
const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
|
||||
const annotated_case_name = fmtstream.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 fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 = fmt.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;
|
||||
const annotated_case_name = fmtstream.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 fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
|
||||
const annotated_case_name = fmtstream.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;
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ const Buffer = std.Buffer;
|
||||
const io = std.io;
|
||||
const fs = std.fs;
|
||||
const mem = std.mem;
|
||||
const fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
|
||||
const annotated_case_name = fmtstream.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 = fmt.allocPrint(self.b.allocator, "compile-error {}", .{
|
||||
const annotated_case_name = fmtstream.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 = fmt.allocPrint(self.b.allocator, "build {} ({})", .{
|
||||
const annotated_case_name = fmtstream.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 = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
|
||||
const annotated_case_name = fmtstream.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.fmt.allocPrint(allocator, "generic-{}", .{abi_name});
|
||||
const generic_name = try std.fmtstream.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.fmt.allocPrint(allocator, "{}-{}-{}", .{
|
||||
const out_subpath = try std.fmtstream.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 fmt = std.fmt;
|
||||
const fmtstream = std.fmtstream;
|
||||
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 fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name});
|
||||
const basename = try fmtstream.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