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

String.space assumes the string is null-terminated #1426

Closed
Perelandric opened this issue Nov 18, 2016 · 0 comments
Closed

String.space assumes the string is null-terminated #1426

Perelandric opened this issue Nov 18, 2016 · 0 comments

Comments

@Perelandric
Copy link
Contributor

The current implementation of String.space is:

_alloc - 1

This assumes that _alloc will always be greater than _size, resulting in faulty output.

For example:

let not_null_term = String.from_iso_array(recover ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] end)

env.out.print("size: " + not_null_term.size().string())
env.out.print("space:" + not_null_term.space().string())

Output:

size: 8
space:7

jemc pushed a commit that referenced this issue Nov 23, 2016
The `space()` method assumes that the string is null termianted, and so
it always returns `_alloc - 1`. When not null terminated, the space
should return the full `_alloc`.

This PR assumes PR #1429 is correct and has been merged.

Fixes #1426
jemc pushed a commit that referenced this issue Nov 29, 2016
This adds tests that were waiting on some interdependent PRs
to merge.

Tests are for issues #1426 and #1435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant