From efc8974c737dd2920aa7b359a2f60fecbd397465 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Tue, 12 Aug 2014 22:39:27 +0800 Subject: [PATCH] Use find_emph_char to find delims in char_quote --- src/document.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/document.c b/src/document.c index 3f75cb0..40c96cd 100644 --- a/src/document.c +++ b/src/document.c @@ -792,15 +792,16 @@ char_quote(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size_t offs nq++; /* finding the next delimiter */ - i = 0; - for (end = nq; end < size && i < nq; end++) { - if (data[end] == '"') i++; - else i = 0; + end = nq; + while (1) { + i = end; + end += find_emph_char(data + end, size - end, '"'); + if (end == i) return 0; /* no matching delimiter */ + i = end; + while (end < size && data[end] == '"' && end - i < nq) end++; + if (end - i >= nq) break; } - if (i < nq && end >= size) - return 0; /* no matching delimiter */ - /* trimming outside spaces */ f_begin = nq; while (f_begin < end && data[f_begin] == ' ')