Navigation Menu

Skip to content

Commit

Permalink
buf,buflen
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Aug 17, 2018
1 parent 090e300 commit 7638b84
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
26 changes: 13 additions & 13 deletions mutt/string.c
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion mutt/string2.h
Expand Up @@ -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);
Expand Down
30 changes: 15 additions & 15 deletions muttlib.c
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 7638b84

Please sign in to comment.