Branch Coverage

lib/Markdown/Simple.xs
Criterion Covered Total %
branch 249 374 66.5


line true false branch
45 6 2 if (mds_special_init) return;
65 104 8 while (*p) {
67 96 8 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
18 78 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
24 2 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
21 3 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
0 21 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
4 1 if ((p == input || *(p-1) == '\n') && (*p == '-' || *p == '*' || *p == '+') && *(p+1) == ' ') {
72 2 2 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
1 1 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 1 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
2 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
74 2 0 if (*p == ' ') p++;
79 12 88 if (*p == '|') {
85 15 73 if (*p == '-' && ((p > input && *(p-1) == '|') || (p == input))) {
15 0 if (*p == '-' && ((p > input && *(p-1) == '|') || (p == input))) {
12 3 if (*p == '-' && ((p > input && *(p-1) == '|') || (p == input))) {
0 12 if (*p == '-' && ((p > input && *(p-1) == '|') || (p == input))) {
91 4 81 if ((*p == '*' && *(p+1) == '*') || (*p == '_' && *(p+1) == '_')) {
0 4 if ((*p == '*' && *(p+1) == '*') || (*p == '_' && *(p+1) == '_')) {
10 71 if ((*p == '*' && *(p+1) == '*') || (*p == '_' && *(p+1) == '_')) {
6 4 if ((*p == '*' && *(p+1) == '*') || (*p == '_' && *(p+1) == '_')) {
96 75 0 if (*p == '*' || *p == '_') {
4 71 if (*p == '*' || *p == '_') {
101 0 71 if (*p == '~' && *(p+1) == '~') {
0 0 if (*p == '~' && *(p+1) == '~') {
106 2 69 if (*p == '`') {
107 1 1 if (*(p+1) == '`' && *(p+2) == '`') {
1 0 if (*(p+1) == '`' && *(p+2) == '`') {
114 1 0 while (*p && *p != '\n') p++;
0 1 while (*p && *p != '\n') p++;
116 1 0 if (*p == '\n') { sv_catpvn(out, "\n", 1); p++; }
118 0 1 body_end = fence ? fence : p + strlen(p);
119 1 0 if (body_end > p)
121 1 0 if (fence) {
124 1 0 while (*p && *p != '\n') p++;
0 1 while (*p && *p != '\n') p++;
132 6 0 while (*p && *p != '`') p++;
5 1 while (*p && *p != '`') p++;
133 1 0 if (p > code_start)
135 1 0 if (*p == '`') p++;
140 1 68 if (*p == '!' && *(p+1) == '[') {
1 0 if (*p == '!' && *(p+1) == '[') {
142 2 0 while (*p && *p != ']') p++;
1 1 while (*p && *p != ']') p++;
143 1 0 if (*p == ']') p++;
144 1 0 if (*p == '(') {
146 6 0 while (*p && *p != ')') p++;
5 1 while (*p && *p != ')') p++;
147 1 0 if (*p == ')') p++;
152 1 67 if (*p == '[') {
157 11 0 while (*p && *p != ']') p++;
10 1 while (*p && *p != ']') p++;
159 1 0 if (text_len > 0)
161 1 0 if (*p == ']') p++;
162 1 0 if (*p == '(') {
164 9 0 while (*p && *p != ')') p++;
8 1 while (*p && *p != ')') p++;
165 1 0 if (*p == ')') p++;
170 3 64 if (*p == '#') {
171 3 3 while (*p == '#') p++;
172 3 0 if (*p == ' ') p++;
176 0 64 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
0 0 if (*p == '[' && (*(p+1) == ' ' || *(p+1) == 'x' || *(p+1) == 'X') && *(p+2) == ']') {
178 0 0 if (*p == ' ') p++;
184 44 20 if (mds_special[(unsigned char)*p]
185 44 0 || *p == '|' || *p == '-' || *p == '+'
32 12 || *p == '|' || *p == '-' || *p == '+'
32 0 || *p == '|' || *p == '-' || *p == '+'
186 25 7 || (*p >= '1' && *p <= '9')) {
4 21 || (*p >= '1' && *p <= '9')) {
191 111 20 do { p++; } while (*p && !mds_special[(unsigned char)*p]
192 111 0 && *p != '|' && *p != '-' && *p != '+'
111 0 && *p != '|' && *p != '-' && *p != '+'
111 0 && *p != '|' && *p != '-' && *p != '+'
193 131 6 && !(*p >= '1' && *p <= '9'));
18 93 && !(*p >= '1' && *p <= '9'));
91 2 && !(*p >= '1' && *p <= '9'));
206 155 2070 if (!h) return flags;
207 2044 26 if ((v = hv_fetch(h, "gfm", 3, 0)) && !SvTRUE(*v)) flags = MDS_FLAGS_COMMONMARK;
1984 60 if ((v = hv_fetch(h, "gfm", 3, 0)) && !SvTRUE(*v)) flags = MDS_FLAGS_COMMONMARK;
208 2 2068 if ((v = hv_fetch(h, "tables", 6, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_TABLES) : (flags & ~MDS_FLAG_TABLES);
0 2 if ((v = hv_fetch(h, "tables", 6, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_TABLES) : (flags & ~MDS_FLAG_TABLES);
209 1 2069 if ((v = hv_fetch(h, "strikethrough", 13, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_STRIKE) : (flags & ~MDS_FLAG_STRIKE);
0 1 if ((v = hv_fetch(h, "strikethrough", 13, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_STRIKE) : (flags & ~MDS_FLAG_STRIKE);
210 0 2070 if ((v = hv_fetch(h, "tasklist", 8, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_TASKLIST) : (flags & ~MDS_FLAG_TASKLIST);
0 0 if ((v = hv_fetch(h, "tasklist", 8, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_TASKLIST) : (flags & ~MDS_FLAG_TASKLIST);
211 1 2069 if ((v = hv_fetch(h, "autolink", 8, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_AUTOLINK) : (flags & ~MDS_FLAG_AUTOLINK);
0 1 if ((v = hv_fetch(h, "autolink", 8, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_AUTOLINK) : (flags & ~MDS_FLAG_AUTOLINK);
212 1 2069 if ((v = hv_fetch(h, "disallow_raw_html", 17, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_DISALLOW_RAW_HTML) : (flags & ~MDS_FLAG_DISALLOW_RAW_HTML);
0 1 if ((v = hv_fetch(h, "disallow_raw_html", 17, 0))) flags = SvTRUE(*v) ? (flags | MDS_FLAG_DISALLOW_RAW_HTML) : (flags & ~MDS_FLAG_DISALLOW_RAW_HTML);
213 1 2069 if ((v = hv_fetch(h, "hard_breaks", 11, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_HARD_BREAKS;
1 0 if ((v = hv_fetch(h, "hard_breaks", 11, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_HARD_BREAKS;
214 2 2068 if ((v = hv_fetch(h, "unsafe", 6, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_UNSAFE;
2 0 if ((v = hv_fetch(h, "unsafe", 6, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_UNSAFE;
215 1 2069 if ((v = hv_fetch(h, "no_simd", 7, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_NO_SIMD;
1 0 if ((v = hv_fetch(h, "no_simd", 7, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_NO_SIMD;
216 2 2068 if ((v = hv_fetch(h, "strict_utf8", 11, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_STRICT_UTF8;
2 0 if ((v = hv_fetch(h, "strict_utf8", 11, 0)) && SvTRUE(*v)) flags |= MDS_FLAG_STRICT_UTF8;
217 3 2067 if ((v = hv_fetch(h, "headers", 7, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_HEADINGS;
3 0 if ((v = hv_fetch(h, "headers", 7, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_HEADINGS;
218 1 2069 if ((v = hv_fetch(h, "italic", 6, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_EMPH;
1 0 if ((v = hv_fetch(h, "italic", 6, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_EMPH;
219 1 2069 if ((v = hv_fetch(h, "bold", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_STRONG;
1 0 if ((v = hv_fetch(h, "bold", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_STRONG;
220 1 2069 if ((v = hv_fetch(h, "code", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_CODE;
1 0 if ((v = hv_fetch(h, "code", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_CODE;
221 1 2069 if ((v = hv_fetch(h, "links", 5, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_LINKS;
1 0 if ((v = hv_fetch(h, "links", 5, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_LINKS;
222 1 2069 if ((v = hv_fetch(h, "images", 6, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_IMAGES;
1 0 if ((v = hv_fetch(h, "images", 6, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_IMAGES;
223 2 2068 if ((v = hv_fetch(h, "ordered_lists", 13, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_ORDERED_LISTS;
2 0 if ((v = hv_fetch(h, "ordered_lists", 13, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_ORDERED_LISTS;
224 2 2068 if ((v = hv_fetch(h, "unordered_lists", 15, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_UNORDERED_LISTS;
2 0 if ((v = hv_fetch(h, "unordered_lists", 15, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_UNORDERED_LISTS;
225 1 2069 if ((v = hv_fetch(h, "blockquote", 10, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_QUOTES;
1 0 if ((v = hv_fetch(h, "blockquote", 10, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_QUOTES;
226 1 2069 if ((v = hv_fetch(h, "thematic_break", 14, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_THEMATIC_BREAK;
1 0 if ((v = hv_fetch(h, "thematic_break", 14, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_THEMATIC_BREAK;
227 1 2069 if ((v = hv_fetch(h, "fenced_code", 11, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_FENCED_CODE;
1 0 if ((v = hv_fetch(h, "fenced_code", 11, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_FENCED_CODE;
228 1 2069 if ((v = hv_fetch(h, "indented_code", 13, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_INDENTED_CODE;
1 0 if ((v = hv_fetch(h, "indented_code", 13, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_INDENTED_CODE;
229 1 2069 if ((v = hv_fetch(h, "html", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_HTML;
1 0 if ((v = hv_fetch(h, "html", 4, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_HTML;
230 1 2069 if ((v = hv_fetch(h, "references", 10, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_REFERENCES;
1 0 if ((v = hv_fetch(h, "references", 10, 0)) && !SvTRUE(*v)) flags |= MDS_FLAG_NO_REFERENCES;
254 3 0 if (s) {
279 221 0 if (!self || !SvROK(self))
0 221 if (!self || !SvROK(self))
282 221 0 for (mg = SvMAGIC(iv); mg; mg = mg->mg_moremagic) {
283 221 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &mds_session_mg_vtbl)
221 0 if (mg->mg_type == PERL_MAGIC_ext && mg->mg_virtual == &mds_session_mg_vtbl)
308 2068 0 HV* h = (items > 1 && SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVHV)
2068 0 HV* h = (items > 1 && SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVHV)
2068 0 HV* h = (items > 1 && SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVHV)
309 2068 154 ? (HV*)SvRV(ST(1)) : NULL;
312 5 2217 if (SvCUR(out) == 0 && (flags & MDS_FLAG_STRICT_UTF8) && n) {
1 4 if (SvCUR(out) == 0 && (flags & MDS_FLAG_STRICT_UTF8) && n) {
1 0 if (SvCUR(out) == 0 && (flags & MDS_FLAG_STRICT_UTF8) && n) {
315 0 1 ? mds_simd_ops_scalar() : mds_simd_get();
316 1 0 if (!ops->validate_utf8(s, n))
337 1 2 HV* h = NULL;
345 2 1 if (opts && SvOK(opts)) {
2 0 if (opts && SvOK(opts)) {
346 2 0 if (!SvROK(opts) || SvTYPE(SvRV(opts)) != SVt_PVHV)
0 2 if (!SvROK(opts) || SvTYPE(SvRV(opts)) != SVt_PVHV)
350 0 3 if (!SvOK(class))
352 0 3 klass = SvROK(class) ? sv_reftype(SvRV(class), 1) : SvPV_nolen(class);
356 0 3 if (!s) croak("Markdown::Simple::new: out of memory");
382 221 0 in = SvOK(input) ? SvPV(input, n) : (n = 0, "");
385 1 220 if (SvCUR(out) == 0 && (s->flags & MDS_FLAG_STRICT_UTF8) && n) {
0 1 if (SvCUR(out) == 0 && (s->flags & MDS_FLAG_STRICT_UTF8) && n) {
0 0 if (SvCUR(out) == 0 && (s->flags & MDS_FLAG_STRICT_UTF8) && n) {
387 0 0 ? mds_simd_ops_scalar() : mds_simd_get();
388 0 0 if (!ops->validate_utf8(in, n))
402 0 0 RETVAL = (UV)s->flags;
444 1 598 if (!words) words = 1;
446 0 599 if (!bm) croak("oom");
467 1 599 if (!words) words = 1;
469 0 600 if (!bm) croak("oom");
520 304 2 cap = n ? n : 1;
522 0 306 if (!offs) croak("oom");
524 0 306 if (k == (size_t)-1) { free(offs); XSRETURN_UNDEF; }
542 208 1 cap = n ? n : 1;
544 0 209 if (!offs) croak("oom");
546 0 209 if (k == (size_t)-1) { free(offs); XSRETURN_UNDEF; }
562 3 0 uint32_t* offs = cc ? (uint32_t*)malloc(cc * sizeof(uint32_t)) : NULL;
564 1 2 if (k == (size_t)-1) { free(offs); XSRETURN_UNDEF; }
565 2 0 RETVAL = newSVpvn(offs ? (const char*)offs : "", k * sizeof(uint32_t));
613 64 1 for (i_a = 0; i_a < 64; i_a++) {
615 0 64 if (((uintptr_t)p) & (MDS_ARENA_ALIGN - 1)) { aligned_ok = 0; break; } }
619 200 1 for (si_a = 0; si_a < 200; si_a++) mds_arena_alloc(&a, 1024);
620 1 0 chained_ok = (a.head && a.head->next != NULL);
1 0 chained_ok = (a.head && a.head->next != NULL);
624 1 0 big_ok = (big != NULL && a.big != NULL);
1 0 big_ok = (big != NULL && a.big != NULL);
628 1 0 reset_ok = (a.head && a.head->next == NULL && a.big == NULL);
1 0 reset_ok = (a.head && a.head->next == NULL && a.big == NULL);
1 0 reset_ok = (a.head && a.head->next == NULL && a.big == NULL);
656 1000 1 for (i_b = 0; i_b < 1000; i_b++) mds_buf_write(aTHX_ &b, "abcdef", 6);
661 1 0 data_ok = (memcmp(p_b, "abcdef", 6) == 0 &&
662 1 0 memcmp(p_b + 5994, "abcdef", 6) == 0);