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

Fix bug in StdStream.print #4180

merged 9 commits into from
Aug 26, 2022

Conversation

leonardoce
Copy link
Contributor

When printing via StdStream.print strings containing the null
terminator, we were just printing the string until the null terminator
and replacing the unprinted characters by padding the printed string
with space characters.

This behavior made String.size() inconsistent with what fprintf was
really printing.

This behavior has been introduced in #1768, which ensure we respected
the buffer size.

Closes #4171

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Aug 21, 2022
@leonardoce
Copy link
Contributor Author

Hi guys, this is my first PR here and I'm not totally sure this is the behavior we want.
Any advise is deeply appreciated.
Thank you!

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Aug 21, 2022
@ponylang-main
Copy link
Contributor

Hi @leonardoce,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 4180.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

When printing via `StdStream.print` strings containing the null
terminator, we were just printing the string until the null terminator
and replacing the unprinted characters by padding the printed string
with space characters.

This behavior made `String.size()` inconsistent with what `fprintf` was
really printing.

This behavior has been introduced in #1768, which ensure we respected
the buffer size.

Closes #4171
@leonardoce
Copy link
Contributor Author

Added the release notes snippet

.release-notes/4180.md Outdated Show resolved Hide resolved
.release-notes/4180.md Outdated Show resolved Hide resolved
.release-notes/4180.md Outdated Show resolved Hide resolved
.release-notes/4180.md Outdated Show resolved Hide resolved

That behavior was introduced in release 0.12.0, fixing a left-over from when Pony strings were null terminated.

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...

.release-notes/4180.md Outdated Show resolved Hide resolved
.release-notes/4180.md Outdated Show resolved Hide resolved
@SeanTAllen
Copy link
Member

We don't have a way to test this right now in an automated fashion so I will build this branch and test by hand:

actor Main
  new create(env: Env) =>
    env.out.print("Hello,\x00world!")

.release-notes/4180.md Outdated Show resolved Hide resolved
.release-notes/4180.md Outdated Show resolved Hide resolved
@SeanTAllen SeanTAllen changed the title Fix unwanted indentation in StdStream.print Fix bug in StdStream.print Aug 26, 2022
@SeanTAllen SeanTAllen self-assigned this Aug 26, 2022
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Aug 26, 2022
@SeanTAllen
Copy link
Member

Tested. This is looking good.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Aug 26, 2022
@SeanTAllen
Copy link
Member

I'll merge this later.

@SeanTAllen
Copy link
Member

Thanks @leonardoce.

@SeanTAllen SeanTAllen merged commit 83f5047 into ponylang:main Aug 26, 2022
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Aug 26, 2022
github-actions bot pushed a commit that referenced this pull request Aug 26, 2022
github-actions bot pushed a commit that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwanted indentation when printing null-terminated strings with StdStream.print
3 participants