(source: string)
| 1482 | */ |
| 1483 | const C_NAMED_VARIADIC_DEFINE_RE = /^([ \t]*#[ \t]*define[ \t]+[A-Za-z_]\w*\([^()\n]*?\b\w+)\.\.\./; |
| 1484 | export function blankCNamedVariadicDefineDots(source: string): string { |
| 1485 | if (source.indexOf('...') === -1) return source; |
| 1486 | const lines = source.split('\n'); |
| 1487 | let changed = false; |
| 1488 | for (let i = 0; i < lines.length; i++) { |
| 1489 | const line = lines[i] as string; |
| 1490 | const m = C_NAMED_VARIADIC_DEFINE_RE.exec(line); |
| 1491 | if (!m) continue; |
| 1492 | const keep = m[1] as string; |
| 1493 | lines[i] = keep + ' ' + line.slice(keep.length + 3); |
| 1494 | changed = true; |
| 1495 | } |
| 1496 | return changed ? lines.join('\n') : source; |
| 1497 | } |
| 1498 | |
| 1499 | /** C source pre-processing: neutralize `#ifdef __cplusplus` compat-guard |
| 1500 | * bodies (invisible to a C compiler; `extern "C" {` otherwise errors every |
no test coverage detected