Skip to content

Commit b74bdf6

Browse files
committed
infocmp -C: only mark verbatim caps ".." when they use params/arithmetic/conditionals
The ".." obsolete marker is not applied to every untranslatable cap -- only to those whose value references a parameter or uses arithmetic/conditional ops (%p/%+/%-/%*/%?/%t/%e/%;). Caps that merely use dynamic-variable or bitwise exotica (%g/%P/%^/%{/unknown, e.g. icl6402 se, qvt119 is) are copied through verbatim WITHOUT the marker, matching ncurses (perfect correlation on %p; %+/%- add the arithmetic cases like c108 ts). Termcap (-C) content 65.8% -> 66.3%, exact 32.7%. terminfo -1 100%; tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CbiPgWC3PHKmrTNvZzXcWQ
1 parent a040860 commit b74bdf6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

crates/ncurses-tools/src/bin/infocmp.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,16 @@ fn me_from_sgr0(ti: &Terminfo) -> Option<Vec<u8>> {
462462
}
463463
}
464464

465-
/// Build a termcap field `code=value`, prefixed with `..` when the value was kept verbatim
466-
/// (untranslatable param ops): ncurses marks such caps obsolete/unusable by old termcap readers.
465+
/// Build a termcap field `code=value`. A value kept verbatim (untranslatable) is prefixed with `..`
466+
/// only when it references a parameter or uses arithmetic/conditional ops (`%p`/`%+`/`%-`/`%*`/`%?`/
467+
/// `%t`/`%e`/`%;`): ncurses marks such caps obsolete, but copies through non-parameterized exotica
468+
/// (`%g`/`%P`/`%^`/`%{`/unknown ops) unmarked.
467469
fn tc_field(code: &str, raw: &[u8]) -> String {
468470
let (val, verbatim) = tc_xlat(raw);
469-
let prefix = if verbatim { ".." } else { "" };
471+
let marks_obsolete = raw
472+
.windows(2)
473+
.any(|w| w[0] == b'%' && matches!(w[1], b'p' | b'+' | b'-' | b'*' | b'?' | b't' | b'e' | b';'));
474+
let prefix = if verbatim && marks_obsolete { ".." } else { "" };
470475
format!("{prefix}{code}={val}")
471476
}
472477

0 commit comments

Comments
 (0)