* Restore preprocessor-directive lines to their original bytes after the * blanking passes ran. The token-level blanks match on shape, not context, so * a macro name that happens to sit inside a DIRECTIVE gets blanked too — and * blanking the name position of `#define FMT_API FMT_VISIBILITY("defa
(original: string, blanked: string)
| 1709 | * construction and strictly reduces parse errors on both extraction arms. |
| 1710 | */ |
| 1711 | function restoreDirectiveLines(original: string, blanked: string): string { |
| 1712 | if (blanked === original || original.indexOf('#') === -1) return blanked; |
| 1713 | const o = original.split('\n'); |
| 1714 | const b = blanked.split('\n'); |
| 1715 | let changed = false; |
| 1716 | let continuation: boolean = false; |
| 1717 | for (let i = 0; i < o.length && i < b.length; i++) { |
| 1718 | const line = o[i] as string; |
| 1719 | const isDirective: boolean = continuation || /^[ \t]*#/.test(line); |
| 1720 | if (isDirective && b[i] !== line) { |
| 1721 | b[i] = line; |
| 1722 | changed = true; |
| 1723 | } |
| 1724 | continuation = isDirective && /\\\s*$/.test(line.replace(/\r$/, '')); |
| 1725 | } |
| 1726 | return changed ? b.join('\n') : blanked; |
| 1727 | } |
| 1728 | |
| 1729 | /** Recover MSVC's COM alias only at type-definition sites. Match on a lexical |
| 1730 | * mask so comments, literals and directives cannot supply declaration evidence; |
no test coverage detected