Better name for the offset args

This commit is contained in:
Vicent Marti 2012-10-10 15:41:21 +02:00
parent b6b58da3ff
commit 2bb12820b1

View file

@ -49,7 +49,7 @@ sd_autolink_issafe(const uint8_t *link, size_t link_len)
}
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;
@ -163,13 +163,13 @@ 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)
@ -183,7 +183,7 @@ sd_autolink__www(
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;
@ -199,14 +199,14 @@ 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))
@ -238,7 +238,7 @@ sd_autolink__email(
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;
@ -254,7 +254,7 @@ 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)
{
@ -263,7 +263,7 @@ sd_autolink__url(
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))
@ -283,7 +283,7 @@ sd_autolink__url(
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;