Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in StdStream.print #4180

Merged
merged 9 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .release-notes/4180.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Fix unwanted indentation in `StdStream.print`
SeanTAllen marked this conversation as resolved.
Show resolved Hide resolved

When printing via `StdStream.print` strings containing null bytes, the standard library was printing the string until the first null byte and then padding the printed string with space characters until the string size was reached.

This bug was introduced in Pony 0.12.0 while fixing a different printing bug.

Now `Stdstream.print` is effectively printing every character in the string plus an ending newline character.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what this is supposed to mean. What is "effectively printing"? Does "effectively" here mean "more or less"? If yes, that would be a disturbing release note and I think it should be rewritten.

I would rewrite this, but I'm not sure what the intent is...

SeanTAllen marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions src/libponyrt/lang/stdfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,8 @@ PONY_API size_t pony_os_stdin_read(char* buffer, size_t space)

PONY_API void pony_os_std_print(FILE* fp, char* buffer, size_t len)
{
if(len == 0)
fprintf(fp, "\n");
else
fprintf(fp, "%*.*s\n", (int)len, (int)len, buffer);
fwrite(buffer, len, 1, fp);
fprintf(fp, "\n");
}

PONY_API void pony_os_std_write(FILE* fp, char* buffer, size_t len)
Expand Down