Take characters while a predicate holds, and return a string.
| 257 | |
| 258 | // Take characters while a predicate holds, and return a string. |
| 259 | static inline cmark_chunk take_while(subject *subj, int (*f)(int)) { |
| 260 | unsigned char c; |
| 261 | bufsize_t startpos = subj->pos; |
| 262 | bufsize_t len = 0; |
| 263 | |
| 264 | while ((c = peek_char(subj)) && (*f)(c)) { |
| 265 | advance(subj); |
| 266 | len++; |
| 267 | } |
| 268 | |
| 269 | return cmark_chunk_dup(&subj->input, startpos, len); |
| 270 | } |
| 271 | |
| 272 | // Return the number of newlines in a given span of text in a subject. If |
| 273 | // the number is greater than zero, also return the number of characters |
no test coverage detected