Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes issue #800.
I am not 100% sure this is in line with the original intent of the fields, and I have very little C experience!
The CommandDesc struct has two relevant fields here: src and
command. The src field is supposed to contain the source of the entire
input while the command field is supposed to contain just the name of
the command being invoked; aka everything before the first space.
We would start with input like this:
What we want is:
src: eval trace("hello" .. "world")
command: eval
The src field was set to a copy of the input, and then the command
field was set to running strtok on src to find the first space. But
even though strtok returns what looks like a string, it's actually
just pointing to the same copy of src which now happens to have been
terminated right where the first space used to be.
So what we got was just:
src: eval
command: eval
The fix is to copy the input into src and command fields separately
and only call strtok on command, allowing src to be left alone.