| 162 | } |
| 163 | |
| 164 | HELL_DEF hell_parser_status_t hell_parser_delim(hell_parser_t *parser, char delim, unsigned count) |
| 165 | { |
| 166 | if (!parser) |
| 167 | return HELL_PARSER_ERROR; |
| 168 | |
| 169 | count = (count == 0) ? 1 : count; /* Default count to 1 if 0 */ |
| 170 | size_t matched = 0; /* Tracks consecutive delimiter matches */ |
| 171 | |
| 172 | while (!hell_parser_eof(parser)) |
| 173 | { |
| 174 | char current; |
| 175 | if (hell_parser_next(parser, ¤t) != HELL_PARSER_OK) |
| 176 | break; |
| 177 | |
| 178 | if (current == delim) |
| 179 | { |
| 180 | matched++; |
| 181 | if (matched == count) |
| 182 | return HELL_PARSER_OK; |
| 183 | } |
| 184 | else |
| 185 | matched = 0; |
| 186 | } |
| 187 | return HELL_PARSER_ERROR; |
| 188 | } |
| 189 | |
| 190 | /* Get content inside delim [count] times, if count is 0 it defaults to 1. |
| 191 | * For example, for '%' with count 2, it triggers on "%%" in the text. |
nothing calls this directly
no test coverage detected