authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-03 15:25:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-20 18:33:00-07:00
log95439c982033bf56a54f4dd85e6de951b52aeb0d
tree3310fb5184c592db4641db9fff3aeb01a3a21545
parent354c17869a4fb1053d472d6562f4987fbaca143e

std.Progress: avoid problematic catch syntax


1 files changed, 15 insertions(+), 5 deletions(-)

lib/std/Progress.zig+15-5
...@@ -1248,7 +1248,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {...@@ -1248,7 +1248,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {
1248 i += progress_pulsing.len;1248 i += progress_pulsing.len;
1249 } else {1249 } else {
1250 const percent = completed_items * 100 / estimated_total;1250 const percent = completed_items * 100 / estimated_total;
1251 i += (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent}) catch &.{}).len;1251 if (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent})) |b| {
1252 i += b.len;
1253 } else |_| {}
1252 }1254 }
1253 },1255 },
1254 .success => {1256 .success => {
...@@ -1265,7 +1267,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {...@@ -1265,7 +1267,9 @@ fn computeRedraw(serialized_buffer: *Serialized.Buffer) struct { []u8, usize } {
1265 i += progress_pulsing_error.len;1267 i += progress_pulsing_error.len;
1266 } else {1268 } else {
1267 const percent = completed_items * 100 / estimated_total;1269 const percent = completed_items * 100 / estimated_total;
1268 i += (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent}) catch &.{}).len;1270 if (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent})) |b| {
1271 i += b.len;
1272 } else |_| {}
1269 }1273 }
1270 },1274 },
1271 }1275 }
...@@ -1364,12 +1368,18 @@ fn computeNode(...@@ -1364,12 +1368,18 @@ fn computeNode(
1364 if (!is_empty_root) {1368 if (!is_empty_root) {
1365 if (name.len != 0 or estimated_total > 0) {1369 if (name.len != 0 or estimated_total > 0) {
1366 if (estimated_total > 0) {1370 if (estimated_total > 0) {
1367 i += (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total }) catch &.{}).len;1371 if (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| {
1372 i += b.len;
1373 } else |_| {}
1368 } else if (completed_items != 0) {1374 } else if (completed_items != 0) {
1369 i += (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items}) catch &.{}).len;1375 if (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items})) |b| {
1376 i += b.len;
1377 } else |_| {}
1370 }1378 }
1371 if (name.len != 0) {1379 if (name.len != 0) {
1372 i += (std.fmt.bufPrint(buf[i..], "{s}", .{name}) catch &.{}).len;1380 if (std.fmt.bufPrint(buf[i..], "{s}", .{name})) |b| {
1381 i += b.len;
1382 } else |_| {}
1373 }1383 }
1374 }1384 }
13751385