* 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)
| 1710 | * construction and strictly reduces parse errors on both extraction arms. |
| 1711 | */ |
| 1712 | function restoreDirectiveLines(original: string, blanked: string): string { |
| 1713 | if (blanked === original || original.indexOf('#') === -1) return blanked; |
| 1714 | const o = original.split('\n'); |
| 1715 | const b = blanked.split('\n'); |
| 1716 | let changed = false; |
| 1717 | let continuation: boolean = false; |
| 1718 | for (let i = 0; i < o.length && i < b.length; i++) { |
| 1719 | const line = o[i] as string; |
| 1720 | const isDirective: boolean = continuation || /^[ \t]*#/.test(line); |
| 1721 | if (isDirective && b[i] !== line) { |
| 1722 | b[i] = line; |
| 1723 | changed = true; |
| 1724 | } |
| 1725 | continuation = isDirective && /\\\s*$/.test(line.replace(/\r$/, '')); |
| 1726 | } |
| 1727 | return changed ? b.join('\n') : blanked; |
| 1728 | } |
| 1729 | |
| 1730 | /** Recover MSVC's COM alias only at type-definition sites. Match on a lexical |
| 1731 | * mask so comments, literals and directives cannot supply declaration evidence; |
no test coverage detected