`#ifndef X` directly followed by `#define X` is an include guard. */
| 977 | |
| 978 | /* `#ifndef X` directly followed by `#define X` is an include guard. */ |
| 979 | static bool tm_is_include_guard(const tm_scan_t *sc, const tm_tok_t *guarded) { |
| 980 | tm_lex_t ahead = sc->lx; |
| 981 | tm_tok_t tok; |
| 982 | tm_next(&ahead, &tok); |
| 983 | if (tok.kind != TM_TOK_DIRECTIVE) { |
| 984 | return false; |
| 985 | } |
| 986 | tm_tok_t word; |
| 987 | tm_lex_t rest; |
| 988 | tm_directive_word(&tok, &word, &rest, sc->lx.incomplete); |
| 989 | if (!tm_tok_is(&word, "define")) { |
| 990 | return false; |
| 991 | } |
| 992 | tm_next(&rest, &word); |
| 993 | return word.kind == TM_TOK_IDENT && word.len == guarded->len && |
| 994 | memcmp(word.text, guarded->text, word.len) == 0; |
| 995 | } |
| 996 | |
| 997 | static void tm_directive(tm_scan_t *sc, const tm_tok_t *tok) { |
| 998 | tm_tok_t word; |
no test coverage detected