Does the body of the `#define NAME(` at `index` (continuation lines included) call `NAME`?
(lines: string[], index: number, name: string)
| 216 | |
| 217 | /** Does the body of the `#define NAME(` at `index` (continuation lines included) call `NAME`? */ |
| 218 | function callsItself(lines: string[], index: number, name: string): boolean { |
| 219 | let text = lines[index]!; |
| 220 | for (let j = index; /\\\s*$/.test(lines[j]!) && j + 1 < lines.length; j++) text += ' ' + lines[j + 1]!; |
| 221 | const body = text.slice(text.indexOf('(') + 1); |
| 222 | return new RegExp(`(?:\\b${name}\\s*\\(|\\(\\s*${name}\\s*\\)\\s*\\()`).test(body); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * The include-guard idiom: `#ifndef X_H` (or `#if !defined(X_H)`) whose next |