aboutsummaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-04 17:42:12 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-09 03:39:15 +0200
commit9830d3a05a374a0d05676301bd4065917b59ad53 (patch)
treec847941aa3471be70e8261eff34e8609d4f43114 /src/inlines.c
parent45c1d9fadb3e8aab4a01bb27a4e2ece379902d1a (diff)
430/11
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c14
1 files changed, 3 insertions, 11 deletions
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);
}