From 02bee94b3612ee0c38e9dba02ab96e45131540aa Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 15 Jun 2019 21:19:01 +0100 Subject: [PATCH] reorder params for mutt_str_substr_copy() - rename substr_cpy() to substr_copy() - reorder params to put dest and destlen together --- complete.c | 4 ++-- hdrline.c | 2 +- mutt/string.c | 26 +++++++++++++------------- mutt/string2.h | 2 +- sendlib.c | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/complete.c b/complete.c index 415f439aa..52e8bbf07 100644 --- a/complete.c +++ b/complete.c @@ -110,7 +110,7 @@ int mutt_complete(char *buf, size_t buflen) return -1; } mutt_str_strfcpy(exp_dirpart, tmp, sizeof(exp_dirpart)); - mutt_str_substr_cpy(dirpart, buf, p + 1, sizeof(dirpart)); + mutt_str_substr_copy(buf, p + 1, dirpart, sizeof(dirpart)); mutt_str_strfcpy(filepart, p + 1, sizeof(filepart)); } else @@ -132,7 +132,7 @@ int mutt_complete(char *buf, size_t buflen) } else { - mutt_str_substr_cpy(dirpart, buf, p, sizeof(dirpart)); + mutt_str_substr_copy(buf, p, dirpart, sizeof(dirpart)); mutt_str_strfcpy(filepart, p + 1, sizeof(filepart)); mutt_str_strfcpy(exp_dirpart, dirpart, sizeof(exp_dirpart)); mutt_expand_path(exp_dirpart, sizeof(exp_dirpart)); diff --git a/hdrline.c b/hdrline.c index 0377f6109..f9f22805d 100644 --- a/hdrline.c +++ b/hdrline.c @@ -1457,7 +1457,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co if ((*end == '@') && (recurse < 20)) { recurse++; - mutt_str_substr_cpy(tmp, src, end, sizeof(tmp)); + mutt_str_substr_copy(src, end, tmp, sizeof(tmp)); mutt_expando_format(tmp, sizeof(tmp), col, cols, NONULL(mutt_idxfmt_hook(tmp, m, e)), index_format_str, data, flags); diff --git a/mutt/string.c b/mutt/string.c index e6d44546b..ebd1046cb 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -546,24 +546,24 @@ const char *mutt_str_strchrnul(const char *s, char c) } /** - * mutt_str_substr_cpy - Copy a sub-string into a buffer - * @param dest Buffer for the result - * @param begin Start of the string to copy - * @param end End of the string to copy - * @param destlen Length of buffer + * mutt_str_substr_copy - Copy a sub-string into a buffer + * @param begin Start of the string to copy + * @param end End of the string to copy + * @param buf Buffer for the result + * @param buflen Length of buffer * @retval ptr Destination buffer */ -char *mutt_str_substr_cpy(char *dest, const char *begin, const char *end, size_t destlen) +char *mutt_str_substr_copy(const char *begin, const char *end, char *buf, size_t buflen) { - if (!dest || !begin || !end || (destlen == 0)) - return dest; + if (!begin || !end || !buf || (buflen == 0)) + return buf; size_t len = end - begin; - if (len > (destlen - 1)) - len = destlen - 1; - memcpy(dest, begin, len); - dest[len] = '\0'; - return dest; + if (len > (buflen - 1)) + len = buflen - 1; + memcpy(buf, begin, len); + buf[len] = '\0'; + return buf; } /** diff --git a/mutt/string2.h b/mutt/string2.h index ae191e79a..f70012a43 100644 --- a/mutt/string2.h +++ b/mutt/string2.h @@ -109,7 +109,7 @@ int mutt_str_strncasecmp(const char *a, const char *b, size_t l); char * mutt_str_strncat(char *d, size_t l, const char *s, size_t sl); int mutt_str_strncmp(const char *a, const char *b, size_t l); size_t mutt_str_strnfcpy(char *dest, const char *src, size_t n, size_t dsize); -char * mutt_str_substr_cpy(char *dest, const char *begin, const char *end, size_t destlen); +char * mutt_str_substr_copy(const char *begin, const char *end, char *buf, size_t buflen); char * mutt_str_substr_dup(const char *begin, const char *end); const char *mutt_str_sysexit(int e); int mutt_str_word_casecmp(const char *a, const char *b); diff --git a/sendlib.c b/sendlib.c index 1a8da46f1..30008ad58 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1170,7 +1170,7 @@ enum ContentType mutt_lookup_mime_type(struct Body *att, const char *path) for (q = p; *q && !IS_SPACE(*q); q++) ; - mutt_str_substr_cpy(subtype, p, q, sizeof(subtype)); + mutt_str_substr_copy(p, q, subtype, sizeof(subtype)); type = mutt_check_mime_type(ct); if (type == TYPE_OTHER) -- 2.40.0