int verif_state(const char c, const char *reglol) { char *copy; int reverse; int pure; copy = (char *)reglol; if (*copy == '!' && (reverse = 1)) ++copy; else reverse = 0; while (*copy) { pure = 0; if (*copy == '\\' && (pure = handle_backslash(©)) < 0) return (-1); if (!pure && *copy == '*') return (reverse); if (pure && c == (pure & 0x7F)) return (reverse); else if (!pure && c == *copy) return (reverse); ++copy; } return (!reverse); }
// Parse an inline, advancing subject, and add it as a child of parent. // Return 0 if no inline can be parsed, 1 otherwise. static int parse_inline(subject* subj, cmark_node * parent, int options) { cmark_node* new_inl = NULL; cmark_chunk contents; unsigned char c; int endpos; c = peek_char(subj); if (c == 0) { return 0; } switch(c) { case '\n': new_inl = handle_newline(subj); break; case '`': new_inl = handle_backticks(subj); break; case '\\': new_inl = handle_backslash(subj); break; case '&': new_inl = handle_entity(subj); break; case '<': new_inl = handle_pointy_brace(subj); break; case '*': case '_': case '\'': case '"': new_inl = handle_delim(subj, c, options & CMARK_OPT_SMART); break; case '-': new_inl = handle_hyphen(subj, options & CMARK_OPT_SMART); break; case '.': new_inl = handle_period(subj, options & CMARK_OPT_SMART); break; case '[': advance(subj); new_inl = make_str(cmark_chunk_literal("[")); push_delimiter(subj, '[', true, false, new_inl); break; case ']': new_inl = handle_close_bracket(subj, parent); break; case '!': advance(subj); if (peek_char(subj) == '[') { advance(subj); new_inl = make_str(cmark_chunk_literal("![")); push_delimiter(subj, '!', false, true, new_inl); } else { new_inl = make_str(cmark_chunk_literal("!")); } break; default: endpos = subject_find_special_char(subj, options); contents = cmark_chunk_dup(&subj->input, subj->pos, endpos - subj->pos); subj->pos = endpos; // if we're at a newline, strip trailing spaces. if (peek_char(subj) == '\n') { cmark_chunk_rtrim(&contents); } new_inl = make_str(contents); } if (new_inl != NULL) { cmark_node_append_child(parent, new_inl); } return 1; }