Skip to content

Escape expression text written into C string literals (#360) - #362

Merged
g5t merged 2 commits into
mccode-dev:mainfrom
g5t:fix-360-string-literals
Oct 3, 2026
Merged

g5t merged 2 commits into
mccode-dev:mainfrom
g5t:fix-360-string-literals

Conversation

@g5t

@g5t g5t commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

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

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
@g5t
g5t merged commit e8ae708 into mccode-dev:main Oct 3, 2026
14 checks passed
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.

Non-string component instance parameters with string literal setting expressions break C generated for NeXus

2 participants