Skip to content

std.fmt: migrate bufPrintZ to bufPrintSentinel#25260

Merged
linusg merged 3 commits intoziglang:masterfrom
mrjbq7:bufPrintZ
Sep 19, 2025
Merged

std.fmt: migrate bufPrintZ to bufPrintSentinel#25260
linusg merged 3 commits intoziglang:masterfrom
mrjbq7:bufPrintZ

Conversation

@mrjbq7
Copy link
Contributor

@mrjbq7 mrjbq7 commented Sep 17, 2025

I noticed std.fmt.allocPrintSentinel and migrated bufPrintZ to bufPrintSentinel to match.

Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, one thing to address and then it can be merged.

pub fn bufPrintZ(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![:0]u8 {
const result = try bufPrint(buf, fmt ++ "\x00", args);
return result[0 .. result.len - 1 :0];
pub fn bufPrintSentinel(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a breaking change, it should have an alias for one release cycle before being deleted.

Suggested change
pub fn bufPrintSentinel(
/// Deprecated in favor of `bufPrintSentinel`
pub const bufPrintZ = bufPrintSentinel;
pub fn bufPrintSentinel(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, pushed that!

Copy link
Contributor

@StAlKeR7779 StAlKeR7779 Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I wrong, but shouldn't it be done as function, not alias? Because signature differs by one argument(comptime sentinel: u8)

@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. release notes This PR should be mentioned in the release notes. labels Sep 18, 2025
@andrewrk andrewrk enabled auto-merge (squash) September 18, 2025 03:00
@linusg linusg disabled auto-merge September 18, 2025 10:31
@linusg
Copy link
Collaborator

linusg commented Sep 18, 2025

Disabled auto-merge as per @StAlKeR7779's comment.

@mrjbq7
Copy link
Contributor Author

mrjbq7 commented Sep 18, 2025

@linusg i wondered about that, I pushed bb8cf75 which makes for a compatible symbol rather than a "expected 4 args got 3" compile error. Is that what you're thinking?

@linusg
Copy link
Collaborator

linusg commented Sep 18, 2025

Yeah, that looks good. Thanks!

@linusg linusg enabled auto-merge (squash) September 18, 2025 19:46
@andrewrk
Copy link
Member

Sorry, bad suggestion to make it an alias!

@linusg linusg merged commit 37ecaae into ziglang:master Sep 19, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Implementing this issue could cause existing code to no longer compile or have different behavior. release notes This PR should be mentioned in the release notes. standard library This issue involves writing Zig code for the standard library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants