Skip to content

bug: cf_literal_to_str keeps the closing quote after an escape; strref_cmp_strref asymmetric on empty #48

Closed

Description

@zackees

Two behaviours the Phase 3 characterization tests pin as "characterized, not endorsed":

  • cf-lexer.c cf_literal_to_str decrements count once per output char, not once per consumed char, so "a\nb" yields a<LF>b" (the closing quote is kept after an escape).
  • lexer.c strref_cmp_strref returns -1 in both directions when only one side is empty.

Decide per case: fix in C (and update the pinned tests), or preserve them as documented differences in the lexer ports (#43).

Refs #4, #43

Activity

  1. b7216309-jpg commented on Oct 9, 2026

    @b7216309-jpg
    Contributor

    Proposal for both, as the lexer ports (#41, #49) currently preserve them:

    • cf_literal_to_str keeping the closing quote: fix in C. It's a plain bug. The result for any literal with an escape has a stray " (or ') at the end, so callers get a<LF>b" for "a\nb". The fix is to decrement the remaining count by the characters actually consumed. I'd send it like libobs/util: Fix dstr_insert_ch overrun and dstr_replace hang #53: a C fix with an updated pinned assertion in test_cf_lexer.c and a note in the PR. Then the port follows C again.
    • strref_cmp_strref returning -1 both ways when one side is empty: keep as documented. Its only two callers in the tree (cf-lexer.c: macro parameter and define lookup) compare the result against 0, so the sign is never observed, and changing it has no benefit.

    If that works for you, I'll open the cf_literal_to_str fix.

  2. zackees commented on Oct 9, 2026

    @zackees
    MemberAuthor

    Both halves are fixed in C:

    Each started with a failing test and ended green. The lexer port (#41/#43) should follow the new behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions