version 1.43, 2014/04/17 07:36:45 |
version 1.44, 2014/04/17 15:37:55 |
|
|
format_replace(struct format_tree *ft, const char *key, size_t keylen, |
format_replace(struct format_tree *ft, const char *key, size_t keylen, |
char **buf, size_t *len, size_t *off) |
char **buf, size_t *len, size_t *off) |
{ |
{ |
char *copy, *copy0, *endptr, *ptr, *saved; |
char *copy, *copy0, *endptr, *ptr, *saved, *trimmed; |
const char *value; |
const char *value; |
size_t valuelen; |
size_t valuelen; |
u_long limit = ULONG_MAX; |
u_long limit = 0; |
|
|
/* Make a copy of the key. */ |
/* Make a copy of the key. */ |
copy0 = copy = xmalloc(keylen + 1); |
copy0 = copy = xmalloc(keylen + 1); |
|
|
value = ""; |
value = ""; |
saved = NULL; |
saved = NULL; |
} |
} |
valuelen = strlen(value); |
|
|
|
/* Truncate the value if needed. */ |
/* Truncate the value if needed. */ |
if (valuelen > limit) |
if (limit != 0) { |
valuelen = limit; |
value = trimmed = utf8_trimcstr(value, limit); |
|
free(saved); |
|
saved = trimmed; |
|
} |
|
valuelen = strlen(value); |
|
|
/* Expand the buffer and copy in the value. */ |
/* Expand the buffer and copy in the value. */ |
while (*len - *off < valuelen + 1) { |
while (*len - *off < valuelen + 1) { |