mirror of
https://codeberg.org/ziglings/exercises.git
synced 2025-12-27 16:05:37 +00:00
Merge pull request 'Update to new Zig mem trim API' (#335) from dpflug/ziglings_exercises:main into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/335
This commit is contained in:
commit
2ffc3ee1d8
|
|
@ -473,7 +473,7 @@ const ZiglingStep = struct {
|
||||||
.Exited => |code| {
|
.Exited => |code| {
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
// The test failed.
|
// The test failed.
|
||||||
const stderr = std.mem.trimRight(u8, result.stderr, " \r\n");
|
const stderr = std.mem.trimEnd(u8, result.stderr, " \r\n");
|
||||||
|
|
||||||
return self.step.fail("\n{s}", .{stderr});
|
return self.step.fail("\n{s}", .{stderr});
|
||||||
}
|
}
|
||||||
|
|
@ -594,7 +594,7 @@ pub fn trimLines(allocator: std.mem.Allocator, buf: []const u8) ![]const u8 {
|
||||||
var iter = std.mem.splitSequence(u8, buf, " \n");
|
var iter = std.mem.splitSequence(u8, buf, " \n");
|
||||||
while (iter.next()) |line| {
|
while (iter.next()) |line| {
|
||||||
// TODO: trimming CR characters is probably not necessary.
|
// TODO: trimming CR characters is probably not necessary.
|
||||||
const data = std.mem.trimRight(u8, line, " \r");
|
const data = std.mem.trimEnd(u8, line, " \r");
|
||||||
try list.appendSlice(allocator, data);
|
try list.appendSlice(allocator, data);
|
||||||
try list.append(allocator, '\n');
|
try list.append(allocator, '\n');
|
||||||
}
|
}
|
||||||
|
|
@ -603,7 +603,7 @@ pub fn trimLines(allocator: std.mem.Allocator, buf: []const u8) ![]const u8 {
|
||||||
|
|
||||||
// Remove the trailing LF character, that is always present in the exercise
|
// Remove the trailing LF character, that is always present in the exercise
|
||||||
// output.
|
// output.
|
||||||
return std.mem.trimRight(u8, result, "\n");
|
return std.mem.trimEnd(u8, result, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints a message to stderr.
|
/// Prints a message to stderr.
|
||||||
|
|
@ -655,7 +655,7 @@ fn validate_exercises() bool {
|
||||||
|
|
||||||
var iter = std.mem.splitScalar(u8, ex.output, '\n');
|
var iter = std.mem.splitScalar(u8, ex.output, '\n');
|
||||||
while (iter.next()) |line| {
|
while (iter.next()) |line| {
|
||||||
const output = std.mem.trimRight(u8, line, " \r");
|
const output = std.mem.trimEnd(u8, line, " \r");
|
||||||
if (output.len != line.len) {
|
if (output.len != line.len) {
|
||||||
print("exercise {s} output field lines have trailing whitespace\n", .{
|
print("exercise {s} output field lines have trailing whitespace\n", .{
|
||||||
ex.main_file,
|
ex.main_file,
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ fn check(
|
||||||
|
|
||||||
fn readLine(reader: *fs.File.Reader, buf: []u8) !?[]const u8 {
|
fn readLine(reader: *fs.File.Reader, buf: []u8) !?[]const u8 {
|
||||||
try reader.interface.readSliceAll(buf);
|
try reader.interface.readSliceAll(buf);
|
||||||
return mem.trimRight(u8, buf, " \r\n");
|
return mem.trimEnd(u8, buf, " \r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fails with a custom error message.
|
/// Fails with a custom error message.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user