Skip to content

Commit cb396ad

Browse files
fix: use matcher pattern for patch system
- use match pattern; iterating through solutions and exercises in parallel may cause lenth mismatches
1 parent fc36fc4 commit cb396ad

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/patch.zig

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,22 @@ pub const PatchSystem = struct {
7272
is_debug_enabled: bool = false,
7373
},
7474
) !void {
75-
for (self.list_of_solution_file_paths.items, self.list_of_exercise_file_paths.items) |solution, exercise| {
75+
for (self.list_of_solution_file_paths.items) |solution| {
76+
const basename = STD.fs.path.basename(solution);
77+
78+
var matched_exercise: ?[]const u8 = null;
79+
for (self.list_of_exercise_file_paths.items) |exercise| {
80+
if (STD.mem.eql(u8, STD.fs.path.basename(exercise), basename)) {
81+
matched_exercise = exercise;
82+
break;
83+
}
84+
}
85+
86+
const exercise = matched_exercise orelse {
87+
STD.debug.print("No matching exercise found for {s}\n", .{basename});
88+
continue;
89+
};
90+
7691
const PATCH_FILE_PATH = try STD.mem.replaceOwned(
7792
u8,
7893
allocator,

0 commit comments

Comments
 (0)