From: Richard Russon Date: Thu, 16 Aug 2018 23:49:15 +0000 (+0100) Subject: buf,buflen X-Git-Tag: 2019-10-25~693^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7638b84e6574c916ae007ce830e3a6add436a9ad;p=neomutt buf,buflen --- diff --git a/mutt/string.c b/mutt/string.c index 1c09e9e0c..a8698e02f 100644 --- a/mutt/string.c +++ b/mutt/string.c @@ -296,26 +296,26 @@ char *mutt_str_strdup(const char *str) /** * mutt_str_strcat - Concatenate two strings - * @param d Buffer containing source string - * @param l Length of buffer - * @param s String to add + * @param buf Buffer containing source string + * @param buflen Length of buffer + * @param s String to add * @retval ptr Start of joined string */ -char *mutt_str_strcat(char *d, size_t l, const char *s) +char *mutt_str_strcat(char *buf, size_t buflen, const char *s) { - char *p = d; + char *p = buf; - if (!l) - return d; + if (!buflen) + return buf; - l--; /* Space for the trailing '\0'. */ + buflen--; /* Space for the trailing '\0'. */ - for (; *d && l; l--) - d++; - for (; *s && l; l--) - *d++ = *s++; + for (; *buf && buflen; buflen--) + buf++; + for (; *s && buflen; buflen--) + *buf++ = *s++; - *d = '\0'; + *buf = '\0'; return p; } diff --git a/mutt/string2.h b/mutt/string2.h index bddf7c58e..cd931a731 100644 --- a/mutt/string2.h +++ b/mutt/string2.h @@ -83,7 +83,7 @@ const char *mutt_str_rstrnstr(const char *haystack, size_t haystack_length, cons char * mutt_str_skip_email_wsp(const char *s); char * mutt_str_skip_whitespace(char *p); int mutt_str_strcasecmp(const char *a, const char *b); -char * mutt_str_strcat(char *d, size_t l, const char *s); +char * mutt_str_strcat(char *buf, size_t buflen, const char *s); const char *mutt_str_strchrnul(const char *s, char c); int mutt_str_strcmp(const char *a, const char *b); int mutt_str_strcoll(const char *a, const char *b); diff --git a/muttlib.c b/muttlib.c index 01c61bc72..2c3c0889c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -538,24 +538,24 @@ void mutt_mktemp_full(char *buf, size_t buflen, const char *prefix, /** * mutt_pretty_mailbox - Shorten a mailbox path using '~' or '=' - * @param s Buffer containing string to shorten + * @param buf Buffer containing string to shorten * @param buflen Length of buffer * * Collapse the pathname using ~ or = when possible */ -void mutt_pretty_mailbox(char *s, size_t buflen) +void mutt_pretty_mailbox(char *buf, size_t buflen) { - char *p = s, *q = s; + char *p = buf, *q = buf; size_t len; enum UrlScheme scheme; char tmp[PATH_MAX]; - scheme = url_check_scheme(s); + scheme = url_check_scheme(buf); #ifdef USE_IMAP if (scheme == U_IMAP || scheme == U_IMAPS) { - imap_pretty_mailbox(s); + imap_pretty_mailbox(buf); return; } #endif @@ -565,10 +565,10 @@ void mutt_pretty_mailbox(char *s, size_t buflen) return; #endif - /* if s is an url, only collapse path component */ + /* if buf is an url, only collapse path component */ if (scheme != U_UNKNOWN) { - p = strchr(s, ':') + 1; + p = strchr(buf, ':') + 1; if (strncmp(p, "//", 2) == 0) q = strchr(p + 2, '/'); if (!q) @@ -600,19 +600,19 @@ void mutt_pretty_mailbox(char *s, size_t buflen) *q = 0; } else if (strstr(p, "..") && (scheme == U_UNKNOWN || scheme == U_FILE) && realpath(p, tmp)) - mutt_str_strfcpy(p, tmp, buflen - (p - s)); + mutt_str_strfcpy(p, tmp, buflen - (p - buf)); len = mutt_str_strlen(Folder); - if ((mutt_str_strncmp(s, Folder, len) == 0) && s[len] == '/') + if ((mutt_str_strncmp(buf, Folder, len) == 0) && buf[len] == '/') { - *s++ = '='; - memmove(s, s + len, mutt_str_strlen(s + len) + 1); + *buf++ = '='; + memmove(buf, buf + len, mutt_str_strlen(buf + len) + 1); } - else if ((mutt_str_strncmp(s, HomeDir, (len = mutt_str_strlen(HomeDir))) == 0) && - s[len] == '/') + else if ((mutt_str_strncmp(buf, HomeDir, (len = mutt_str_strlen(HomeDir))) == 0) && + buf[len] == '/') { - *s++ = '~'; - memmove(s, s + len - 1, mutt_str_strlen(s + len - 1) + 1); + *buf++ = '~'; + memmove(buf, buf + len - 1, mutt_str_strlen(buf + len - 1) + 1); } }