ext/rinku/autolink.c in rinku-1.7.0 vs ext/rinku/autolink.c in rinku-1.7.1

- old
+ new

@@ -47,11 +47,11 @@ return 0; } static size_t -autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size) +autolink_delim(uint8_t *data, size_t link_end, size_t max_rewind, size_t size) { uint8_t cclose, copen = 0; size_t i; for (i = 0; i < link_end; ++i) @@ -161,17 +161,17 @@ size_t sd_autolink__www( size_t *rewind_p, struct buf *link, uint8_t *data, - size_t offset, + size_t max_rewind, size_t size, unsigned int flags) { size_t link_end; - if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1])) + if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1])) return 0; if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) return 0; @@ -181,11 +181,11 @@ return 0; while (link_end < size && !isspace(data[link_end])) link_end++; - link_end = autolink_delim(data, link_end, offset, size); + link_end = autolink_delim(data, link_end, max_rewind, size); if (link_end == 0) return 0; bufput(link, data, link_end); @@ -197,18 +197,18 @@ size_t sd_autolink__email( size_t *rewind_p, struct buf *link, uint8_t *data, - size_t offset, + size_t max_rewind, size_t size, unsigned int flags) { size_t link_end, rewind; int nb = 0, np = 0; - for (rewind = 0; rewind < offset; ++rewind) { + for (rewind = 0; rewind < max_rewind; ++rewind) { uint8_t c = data[-rewind - 1]; if (isalnum(c)) continue; @@ -236,11 +236,11 @@ } if (link_end < 2 || nb != 1 || np == 0) return 0; - link_end = autolink_delim(data, link_end, offset, size); + link_end = autolink_delim(data, link_end, max_rewind, size); if (link_end == 0) return 0; bufput(link, data - rewind, link_end + rewind); @@ -252,20 +252,20 @@ size_t sd_autolink__url( size_t *rewind_p, struct buf *link, uint8_t *data, - size_t offset, + size_t max_rewind, size_t size, unsigned int flags) { size_t link_end, rewind = 0, domain_len; if (size < 4 || data[1] != '/' || data[2] != '/') return 0; - while (rewind < offset && isalpha(data[-rewind - 1])) + while (rewind < max_rewind && isalpha(data[-rewind - 1])) rewind++; if (!sd_autolink_issafe(data - rewind, size + rewind)) return 0; @@ -281,10 +281,10 @@ link_end += domain_len; while (link_end < size && !isspace(data[link_end])) link_end++; - link_end = autolink_delim(data, link_end, offset, size); + link_end = autolink_delim(data, link_end, max_rewind, size); if (link_end == 0) return 0; bufput(link, data - rewind, link_end + rewind);