Track one line. Returns the innermost tracked group when the line is one of its #else/#elif lines, else NULL.
| 70 | // Track one line. Returns the innermost tracked group when the line is one of |
| 71 | // its #else/#elif lines, else NULL. |
| 72 | static cpp_frame_t *cpp_nest_step(cpp_nest_t *n, int kind, bool active) { |
| 73 | switch (kind) { |
| 74 | case CPP_LINE_START: |
| 75 | if (n->depth < CPP_NEST_MAX && n->overflow == 0) { |
| 76 | n->frames[n->depth++] = (cpp_frame_t){n->next, 0, active}; |
| 77 | } else { |
| 78 | n->overflow++; |
| 79 | } |
| 80 | n->next++; |
| 81 | return NULL; |
| 82 | case CPP_LINE_ELSE: |
| 83 | if (n->overflow > 0 || n->depth == 0) { |
| 84 | return NULL; |
| 85 | } |
| 86 | n->frames[n->depth - 1].branch++; |
| 87 | return &n->frames[n->depth - 1]; |
| 88 | case CPP_LINE_END: |
| 89 | if (n->overflow > 0) { |
| 90 | n->overflow--; |
| 91 | } else if (n->depth > 0) { |
| 92 | n->depth--; |
| 93 | } |
| 94 | return NULL; |
| 95 | default: |
| 96 | return NULL; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Branch count per group. Returns the group count, or -1 on allocation failure. |
| 101 | static int cpp_group_branches(CBMArena *a, const char *src, int len, int **out) { |
no outgoing calls
no test coverage detected