-
Notifications
You must be signed in to change notification settings - Fork 49
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 padding calculation, closes #45 #46
Conversation
Untested, but maths checked externally
It's either this or put the -1 within the brackets...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comments regarding the string delimiter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
You should probably update the PR text to at least say |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, forgot one more thing: writePaddedString()
needs to be modified as well, otherwise we still have this issue.
I thought it worked in the title too, but added to both to be sure. |
I don't see where @chabad360 . It uses the count from writeString which presumably already includes the null terminator. Or do you mean we need to ensure one is added? |
We need to ensure one is added. I would just add buf.WriteByte(0)
n += 1 right after |
Won't that get a double one if the string already has one (or is that impossible/guaranteed in Go)? Consider: |
Unless you specifically craft a string to include a null byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, LGTM. @hypebeast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. This PR looks good to me.
Thanks a lot for it. As soon as the build succeeds I'll merge it.
Thanks @hypebeast . It seems to works for all the test cases @chabad360 came up with and a few edge cases I conjured up too.
No worries, not quite the easy fix I first thought, but hopefully should make things better and more standardised all round. |
This now passes aside from https://travis-ci.org/github/hypebeast/go-osc/jobs/764014122#L275-L279 which is also present in master @hypebeast . Looks like this could fix it, but a bit outside my experience: |
I would say that issue is probably outside the scope of this PR. |
Yes, this is outside of this PR. Let me see if I can fix it ;) Thanks again for your work @peternewman and @chabad360 |
Fixes #45
Untested, but maths checked externallyCould probably do with some tests to catch such issues in future.