From 9830d3a05a374a0d05676301bd4065917b59ad53 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 4 Sep 2014 17:42:12 +0200 Subject: 430/11 --- src/inlines.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/inlines.c') diff --git a/src/inlines.c b/src/inlines.c index a0dcac9..599be84 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -21,7 +21,6 @@ reference* make_reference(chunk *label, chunk *url, chunk *title); static unsigned char *clean_url(chunk *url, int is_email); static unsigned char *clean_title(chunk *title); -inline static unsigned char *chunk_to_cstr(chunk *c); inline static void chunk_free(chunk *c); inline static void chunk_trim(chunk *c); @@ -37,6 +36,8 @@ static void subject_from_chunk(subject *e, chunk *chunk, reference** refmap); static void subject_from_buf(subject *e, gh_buf *buffer, reference** refmap); static int subject_find_special_char(subject *subj); +static void normalize_whitespace(gh_buf *s); + extern void free_reference(reference *ref) { free(ref->label); free(ref->url); @@ -62,19 +63,10 @@ extern void free_reference_map(reference **refmap) { static unsigned char *normalize_reference(chunk *ref) { gh_buf normalized = GH_BUF_INIT; - int r, w; utf8proc_case_fold(&normalized, ref->data, ref->len); gh_buf_trim(&normalized); - - for (r = 0, w = 0; r < normalized.size; ++r) { - if (r && gh_buf_at(&normalized, r - 1) == ' ') { - while (gh_buf_at(&normalized, r) == ' ') - r++; - } - - normalized.ptr[w++] = normalized.ptr[r]; - } + normalize_whitespace(&normalized); return gh_buf_detach(&normalized); } -- cgit v1.2.3