Escape expression text written into C string literals (#360) - #362
Merged
Merged
Conversation
A numeric component parameter set by an expression containing a string
literal, e.g. blah=f("my choice", wavelength), was recorded for NeXus by
quoting its text, giving the invalid "f("my choice", wavelength)". The
instrument parameter table did the same for default-value expressions.
Escape the text with escape_str_for_c instead, and decide whether a table
value is already a literal from the Expr rather than by its first and last
characters.
Parsing string literals also used strip('"'), which ate the quote of a
trailing escape and turned "a \"q\"" into an unterminated literal; drop
exactly one quote from each end instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KCgTLuBhUYEeTdAq6Ryu9y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A numeric component parameter set by an expression containing a string literal, e.g. blah=f("my choice", wavelength), was recorded for NeXus by quoting its text, giving the invalid "f("my choice", wavelength)". The instrument parameter table did the same for default-value expressions. Escape the text with escape_str_for_c instead, and decide whether a table value is already a literal from the Expr rather than by its first and last characters.
Parsing string literals also used strip('"'), which ate the quote of a trailing escape and turned "a "q"" into an unterminated literal; drop exactly one quote from each end instead.
Claude-Session: https://claude.ai/code/session_01KCgTLuBhUYEeTdAq6Ryu9y