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

new: support conversion from quil_program to String #18

Merged
merged 3 commits into from
Jul 19, 2023
Merged

Conversation

notmgsk
Copy link
Contributor

@notmgsk notmgsk commented Jul 13, 2023

Adds a function pub fn program_string(program: Program) -> CString.

CString is used to ensure that strings are nul-terminated, etc.

Depends on branch mgsk-lib-updates on my quilc fork.

Closes #12

@notmgsk notmgsk marked this pull request as draft July 13, 2023 20:18
@notmgsk
Copy link
Contributor Author

notmgsk commented Jul 13, 2023

encoding error when the program includes a tab (\t)

debugger invoked on a SB-INT:C-STRING-DECODING-ERROR in thread
#<FOREIGN-THREAD "callback" RUNNING {10050FBF93}>:
  :UTF-8 c-string decoding error:
    the octet sequence #(235 127 0) cannot be decoded.

CString ensures we have a terminating nul. Using String's
`String::as_bytes` method does not provide a terminating `0` byte
and thus C code will run off the end of the string when processing it
resulting in undefined behavior.
@notmgsk notmgsk marked this pull request as ready for review July 17, 2023 18:35
@notmgsk notmgsk requested a review from MarquessV July 17, 2023 18:37
@notmgsk notmgsk merged commit 740ce84 into main Jul 19, 2023
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

Successfully merging this pull request may close these issues.

We need a way to convert a Program into a String
2 participants