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