Make char-pointer dereferencing more consistent.
Any functions that used both `*ptr` and `ptr[0]` notation have been tidied.
for (d = dest; *src; src++)
{
- if ((*src == '%') && isxdigit((unsigned char) *(src + 1)) &&
- isxdigit((unsigned char) *(src + 2)))
+ if ((src[0] == '%') && isxdigit((unsigned char) src[1]) &&
+ isxdigit((unsigned char) src[2]))
{
- *d++ = (hexval(*(src + 1)) << 4) | (hexval(*(src + 2)));
+ *d++ = (hexval(src[1]) << 4) | hexval(src[2]);
src += 2;
}
else
else if (C_AssumedCharset)
mutt_ch_convert_nonmime_string(&np->value);
}
- else if (*(s + 1) == '\0')
+ else if (s[1] == '\0')
{
- *s = '\0';
+ s[0] = '\0';
s = get_charset(np->value, charset, sizeof(charset));
decode_one(np->value, s);
}
else
{
- *s = '\0';
+ s[0] = '\0';
s++; /* let s point to the first character of index. */
- for (t = s; *t && isdigit((unsigned char) *t); t++)
+ for (t = s; (t[0] != '\0') && isdigit((unsigned char) t[0]); t++)
;
- encoded = (*t == '*');
- *t = '\0';
+ encoded = (t[0] == '*');
+ t[0] = '\0';
/* RFC2231 says that the index starts at 0 and increments by 1,
* thus an overflow should never occur in a valid message, thus
char *p = strstr(C_HiddenTags, new_tag);
size_t xsz = p ? mutt_str_strlen(new_tag) : 0;
- if (p && ((p == C_HiddenTags) || (*(p - 1) == ',') || (*(p - 1) == ' ')) &&
- ((*(p + xsz) == '\0') || (*(p + xsz) == ',') || (*(p + xsz) == ' ')))
+ if (p && ((p == C_HiddenTags) || (p[-1] == ',') || (p[-1] == ' ')) &&
+ ((p[xsz] == '\0') || (p[xsz] == ',') || (p[xsz] == ' ')))
{
np->hidden = true;
}
static int qp_decode_triple(char *s, char *d)
{
/* soft line break */
- if ((*s == '=') && !(*(s + 1)))
+ if ((s[0] == '=') && (s[1] == '\0'))
return 1;
/* quoted-printable triple */
- if ((*s == '=') && isxdigit((unsigned char) *(s + 1)) &&
- isxdigit((unsigned char) *(s + 2)))
+ if ((s[0] == '=') && isxdigit((unsigned char) s[1]) && isxdigit((unsigned char) s[2]))
{
- *d = (hexval(*(s + 1)) << 4) | hexval(*(s + 2));
+ *d = (hexval(s[1]) << 4) | hexval(s[2]);
return 0;
}
q = strrchr(p, '/');
if (q)
{
- if (*(q + 1) == '*')
+ if (q[1] == '*')
{
if (mutt_str_strncasecmp(buf, p, q - p) == 0)
return true;
}
/* Skip duplicate space */
- while ((*checker == ' ') && (*(checker + 1) == ' '))
+ while ((checker[0] == ' ') && (checker[1] == ' '))
checker++;
/* copy char to new and go the next one */
char *s = NULL;
const char *p = mailbox;
- for (s = dest; p && *p && dlen; dlen--)
+ for (s = dest; p && (p[0] != '\0') && (dlen > 0); dlen--)
{
- if (*p == delim)
+ if (p[0] == delim)
{
*s = '/';
/* simple way to avoid collisions with UIDs */
- if ((*(p + 1) >= '0') && (*(p + 1) <= '9'))
+ if ((p[1] >= '0') && (p[1] <= '9'))
{
if (--dlen)
*++s = '_';
qc = ch;
else if ((ch == '\\') && (qc != '\''))
{
- if (!*tok->dptr)
+ if (tok->dptr[0] == '\0')
return -1; /* premature end of token */
switch (ch = *tok->dptr++)
{
case 'c':
case 'C':
- if (!*tok->dptr)
+ if (tok->dptr[0] == '\0')
return -1; /* premature end of token */
- mutt_buffer_addch(dest, (toupper((unsigned char) *tok->dptr) - '@') & 0x7f);
+ mutt_buffer_addch(dest, (toupper((unsigned char) tok->dptr[0]) - '@') & 0x7f);
tok->dptr++;
break;
case 'e':
mutt_buffer_addch(dest, '\t');
break;
default:
- if (isdigit((unsigned char) ch) && isdigit((unsigned char) *tok->dptr) &&
- isdigit((unsigned char) *(tok->dptr + 1)))
+ if (isdigit((unsigned char) ch) && isdigit((unsigned char) tok->dptr[0]) &&
+ isdigit((unsigned char) tok->dptr[1]))
{
- mutt_buffer_addch(dest, (ch << 6) + (*tok->dptr << 3) + *(tok->dptr + 1) - 3504);
+ mutt_buffer_addch(dest, (ch << 6) + (tok->dptr[0] << 3) + tok->dptr[1] - 3504);
tok->dptr += 2;
}
else
}
else if ((ch == '^') && (flags & MUTT_TOKEN_CONDENSE))
{
- if (!*tok->dptr)
+ if (tok->dptr[0] == '\0')
return -1; /* premature end of token */
ch = *tok->dptr++;
if (ch == '^')
if (*pc == '\\')
pc += 2;
}
- } while (pc && *pc != '`');
+ } while (pc && (pc[0] != '`'));
if (!pc)
{
mutt_debug(LL_DEBUG1, "mismatched backticks\n");
}
}
else if ((ch == '$') && (!qc || (qc == '"')) &&
- ((*tok->dptr == '{') || isalpha((unsigned char) *tok->dptr)))
+ ((tok->dptr[0] == '{') || isalpha((unsigned char) tok->dptr[0])))
{
const char *env = NULL;
char *var = NULL;
- if (*tok->dptr == '{')
+ if (tok->dptr[0] == '{')
{
pc = strchr(tok->dptr, '}');
if (pc)
}
else
{
- for (pc = tok->dptr; isalnum((unsigned char) *pc) || *pc == '_'; pc++)
+ for (pc = tok->dptr; isalnum((unsigned char) *pc) || (pc[0] == '_'); pc++)
;
var = mutt_str_substr_dup(tok->dptr, pc);
tok->dptr = pc;
*/
bool mutt_date_is_day_name(const char *s)
{
- if (!s || (strlen(s) < 3) || !*(s + 3) || !IS_SPACE(*(s + 3)))
+ if (!s || (strlen(s) < 3) || (s[3] == '\0') || !IS_SPACE(s[3]))
return false;
for (int i = 0; i < mutt_array_size(Weekdays); i++)
if (*p)
{
size_t l = 0;
- for (; *p && *p != ' ' && *p != '\t'; p++)
+ for (; (p[0] != '\0') && (p[0] != ' ') && (p[0] != '\t'); p++)
{
- if (*p == '\\')
+ if (p[0] == '\\')
{
- if (!*(p + 1))
+ if (p[1] == '\0')
break;
p++;
}
- if (l < sizeof(path) - 1)
+ if (l < (sizeof(path) - 1))
path[l++] = *p;
}
p = mutt_str_skip_email_wsp(p);
{
case '~':
{
- if ((*(s + 1) == '/') || (*(s + 1) == 0))
+ if ((s[1] == '/') || (s[1] == '\0'))
{
mutt_buffer_strcpy(p, HomeDir);
tail = s + 1;
case '!':
{
- if (*(s + 1) == '!')
+ if (s[1] == '!')
{
mutt_buffer_strcpy(p, LastFolder);
tail = s + 2;
char *p = NULL;
/* parse attribute type */
- for (s = str + 1; *s && *s != '='; s++)
+ for (s = str + 1; (s[0] != '\0') && (s[0] != '='); s++)
;
- if (!*s)
+ if (s[0] == '\0')
return NULL; /* error */
n = s - str;
if (n == 0)
{
n++;
}
- else if (isxdigit(*s) && isxdigit(*(s + 1)))
+ else if (isxdigit(s[0]) && isxdigit(s[1]))
{
s++;
n++;
arrayidx = 0;
while (*str)
{
- while (*str == ' ')
+ while (str[0] == ' ')
str++;
- if (!*str)
+ if (str[0] == '\0')
break; /* ready */
if (arrayidx >= arraysize)
{
arrayidx++;
if (!str)
goto failure;
- while (*str == ' ')
+ while (str[0] == ' ')
str++;
- if (*str && (*str != ',') && (*str != ';') && (*str != '+'))
+ if ((str[0] != '\0') && (str[0] != ',') && (str[0] != ';') && (str[0] != '+'))
goto failure; /* invalid delimiter */
- if (*str)
+ if (str[0] != '\0')
str++;
}
array[arrayidx].key = NULL;
for (s = uid, d = uid; *s;)
{
- if ((*s == '\\') && (*(s + 1) == 'x') &&
- isxdigit((unsigned char) *(s + 2)) && isxdigit((unsigned char) *(s + 3)))
+ if ((s[0] == '\\') && (s[1] == 'x') && isxdigit((unsigned char) s[2]) &&
+ isxdigit((unsigned char) s[3]))
{
- *d++ = hexval(*(s + 2)) << 4 | hexval(*(s + 3));
+ *d++ = (hexval(s[2]) << 4) | hexval(s[3]);
s += 4;
}
else
memcpy(uid, buf, ob - buf);
uid[ob - buf] = '\0';
}
- else if ((n >= 0) && (ob - buf == n) && (buf[n] = 0, (strlen(buf) < (size_t) n)))
+ else if ((n >= 0) && ((ob - buf) == n) && (buf[n] = 0, (strlen(buf) < (size_t) n)))
memcpy(uid, buf, n);
}
FREE(&buf);
char *buf = mutt_str_strdup(C_NmExcludeTags);
- for (char *p = buf; p && *p; p++)
+ for (char *p = buf; p && (p[0] != '\0'); p++)
{
if (!tag && isspace(*p))
continue;
if (!tag)
tag = p; /* begin of the tag */
- if ((*p == ',') || (*p == ' '))
+ if ((p[0] == ',') || (p[0] == ' '))
end = p; /* terminate the tag */
- else if (*(p + 1) == '\0')
+ else if (p[1] == '\0')
end = p + 1; /* end of optstr */
if (!tag || !end)
continue;
continue;
if (!tag)
tag = p; /* begin of the tag */
- if ((*p == ',') || (*p == ' '))
+ if ((p[0] == ',') || (p[0] == ' '))
end = p; /* terminate the tag */
- else if (*(p + 1) == '\0')
+ else if (p[1] == '\0')
end = p + 1; /* end of optstr */
if (!tag || !end)
continue;
if (tag >= end)
break;
- *end = '\0';
+ end[0] = '\0';
- if (*tag == '-')
+ if (tag[0] == '-')
{
mutt_debug(LL_DEBUG1, "nm: remove tag: '%s'\n", tag + 1);
notmuch_message_remove_tag(msg, tag + 1);
}
- else if (*tag == '!')
+ else if (tag[0] == '!')
{
mutt_debug(LL_DEBUG1, "nm: toggle tag: '%s'\n", tag + 1);
if (nm_message_has_tag(msg, tag + 1))
}
else
{
- mutt_debug(LL_DEBUG1, "nm: add tag: '%s'\n", (*tag == '+') ? tag + 1 : tag);
- notmuch_message_add_tag(msg, (*tag == '+') ? tag + 1 : tag);
+ mutt_debug(LL_DEBUG1, "nm: add tag: '%s'\n", (tag[0] == '+') ? tag + 1 : tag);
+ notmuch_message_add_tag(msg, (tag[0] == '+') ? tag + 1 : tag);
}
end = NULL;
tag = NULL;
continue;
if (!tag)
tag = p; /* begin of the tag */
- if ((*p == ',') || (*p == ' '))
+ if ((p[0] == ',') || (p[0] == ' '))
end = p; /* terminate the tag */
- else if (*(p + 1) == '\0')
+ else if (p[1] == '\0')
end = p + 1; /* end of optstr */
if (!tag || !end)
continue;
if (tag >= end)
break;
- *end = '\0';
+ end[0] = '\0';
- if (*tag == '-')
+ if (tag[0] == '-')
{
- tag = tag + 1;
+ tag++;
if (strcmp(tag, C_NmUnreadTag) == 0)
mutt_set_flag(m, e, MUTT_READ, true);
else if (strcmp(tag, C_NmRepliedTag) == 0)
}
else
{
- tag = (*tag == '+') ? tag + 1 : tag;
+ tag = (tag[0] == '+') ? tag + 1 : tag;
if (strcmp(tag, C_NmUnreadTag) == 0)
mutt_set_flag(m, e, MUTT_READ, false);
else if (strcmp(tag, C_NmRepliedTag) == 0)
*/
static int check_marker(const char *q, const char *p)
{
- for (; *p == *q && *q && *p && *q != '\a' && *p != '\a'; p++, q++)
- ;
+ for (; (p[0] == q[0]) && (q[0] != '\0') && (p[0] != '\0') && (q[0] != '\a') &&
+ (p[0] != '\a');
+ p++, q++)
+ {
+ }
+
return (int) (*p - *q);
}
q = *fmt;
while (*p)
{
- if ((*p == '\010') && (p > *buf)) // Ctrl-H (backspace)
+ if ((p[0] == '\010') && (p > *buf)) // Ctrl-H (backspace)
{
- if (*(p + 1) == '_') /* underline */
+ if (p[1] == '_') /* underline */
p += 2;
- else if (*(p + 1) && (q > *fmt)) /* bold or overstrike */
+ else if ((p[1] != '\0') && (q > *fmt)) /* bold or overstrike */
{
- *(q - 1) = *(p + 1);
+ q[-1] = p[1];
p += 2;
}
else /* ^H */
*q++ = *p++;
}
- else if ((*p == '\033') && (*(p + 1) == '[') && is_ansi(p + 2)) // Escape
+ else if ((p[0] == '\033') && (p[1] == '[') && is_ansi(p + 2)) // Escape
{
while (*p++ != 'm') /* skip ANSI sequence */
;
}
- else if ((*p == '\033') && (*(p + 1) == ']') && // Escape
+ else if ((p[0] == '\033') && (p[1] == ']') && // Escape
((check_attachment_marker((char *) p) == 0) ||
(check_protected_header_marker((char *) p) == 0)))
{
case '~':
{
struct Pattern *pat = NULL;
- if (!*(ps.dptr + 1))
+ if (ps.dptr[1] == '\0')
{
mutt_buffer_printf(err, _("missing pattern: %s"), ps.dptr);
goto cleanup;
}
thread_op = 0;
- if (*(ps.dptr + 1) == '(')
+ if (ps.dptr[1] == '(')
thread_op = MUTT_PAT_THREAD;
- else if ((*(ps.dptr + 1) == '<') && (*(ps.dptr + 2) == '('))
+ else if ((ps.dptr[1] == '<') && (ps.dptr[2] == '('))
thread_op = MUTT_PAT_PARENT;
- else if ((*(ps.dptr + 1) == '>') && (*(ps.dptr + 2) == '('))
+ else if ((ps.dptr[1] == '>') && (ps.dptr[2] == '('))
thread_op = MUTT_PAT_CHILDREN;
if (thread_op)
{
if ((thread_op == MUTT_PAT_PARENT) || (thread_op == MUTT_PAT_CHILDREN))
ps.dptr++;
p = find_matching_paren(ps.dptr + 1);
- if (*p != ')')
+ if (p[0] != ')')
{
mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
goto cleanup;
pat->not = not;
pat->alladdr = alladdr;
pat->isalias = isalias;
- pat->stringmatch = (*ps.dptr == '=');
- pat->groupmatch = (*ps.dptr == '%');
+ pat->stringmatch = (ps.dptr[0] == '=');
+ pat->groupmatch = (ps.dptr[0] == '%');
not = false;
alladdr = false;
isalias = false;
if (entry->eat_arg)
{
- if (!*ps.dptr)
+ if (ps.dptr[0] == '\0')
{
mutt_buffer_printf(err, "%s", _("missing parameter"));
goto cleanup;
case '(':
{
p = find_matching_paren(ps.dptr + 1);
- if (*p != ')')
+ if (p[0] != ')')
{
mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr);
goto cleanup;
{
bool do_simple = true;
- for (const char *p = mutt_b2s(buf); p && *p; p++)
+ for (const char *p = mutt_b2s(buf); p && (p[0] != '\0'); p++)
{
- if ((*p == '\\') && *(p + 1))
+ if ((p[0] == '\\') && (p[1] != '\0'))
p++;
- else if ((*p == '~') || (*p == '=') || (*p == '%'))
+ else if ((p[0] == '~') || (p[0] == '=') || (p[0] == '%'))
{
do_simple = false;
break;
return SEC_NO_FLAGS;
p = mutt_str_skip_email_wsp(p);
- for (; *p; p++)
+ for (; p[0] != '\0'; p++)
{
- switch (*p)
+ switch (p[0])
{
case 'c':
case 'C':
q = smime_cryptalg;
- if (*(p + 1) == '<')
+ if (p[1] == '<')
{
- for (p += 2; *p && (*p != '>') &&
+ for (p += 2; (p[0] != '\0') && (p[0] != '>') &&
(q < (smime_cryptalg + sizeof(smime_cryptalg) - 1));
*q++ = *p++)
{
}
- if (*p != '>')
+ if (p[0] != '>')
{
mutt_error(_("Illegal S/MIME header"));
return SEC_NO_FLAGS;
* to be able to recall old messages. */
case 'm':
case 'M':
- if (*(p + 1) == '<')
+ if (p[1] == '<')
{
- for (p += 2; *p && (*p != '>'); p++)
+ for (p += 2; (p[0] != '\0') && (p[0] != '>'); p++)
;
- if (*p != '>')
+ if (p[0] != '>')
{
mutt_error(_("Illegal crypto header"));
return SEC_NO_FLAGS;
flags |= SEC_SIGN;
q = sign_as;
- if (*(p + 1) == '<')
+ if (p[1] == '<')
{
- for (p += 2; *p && (*p != '>') && (q < (sign_as + sizeof(sign_as) - 1));
+ for (p += 2;
+ (p[0] != '\0') && (*p != '>') && (q < (sign_as + sizeof(sign_as) - 1));
*q++ = *p++)
{
}
- if (*p != '>')
+ if (p[0] != '>')
{
mutt_error(_("Illegal crypto header"));
return SEC_NO_FLAGS;
}
}
- *q = '\0';
+ q[0] = '\0';
break;
default:
static int print_val(FILE *fp, const char *pfx, const char *value,
CopyHeaderFlags chflags, size_t col)
{
- while (value && *value)
+ while (value && (value[0] != '\0'))
{
if (fputc(*value, fp) == EOF)
return -1;
}
if (*value == '\n')
{
- if (*(value + 1) && pfx && *pfx && (fputs(pfx, fp) == EOF))
+ if ((value[1] != '\0') && pfx && (pfx[0] != '\0') && (fputs(pfx, fp) == EOF))
return -1;
/* for display, turn folding spaces into folding tabs */
- if ((chflags & CH_DISPLAY) && ((*(value + 1) == ' ') || (*(value + 1) == '\t')))
+ if ((chflags & CH_DISPLAY) && ((value[1] == ' ') || (value[1] == '\t')))
{
value++;
- while (*value && ((*value == ' ') || (*value == '\t')))
+ while ((value[0] != '\0') && ((value[0] == ' ') || (value[0] == '\t')))
value++;
if (fputc('\t', fp) == EOF)
return -1;
return -1;
col = mutt_str_strlen(tag) + ((tag && (tag[0] != '\0')) ? 2 : 0) + mutt_str_strlen(pfx);
- while (p && *p)
+ while (p && (p[0] != '\0'))
{
int fold = 0;
/* insert a folding \n before the current word's lwsp except for
* header name, first word on a line (word longer than wrap width)
* and encoded words */
- if (!first && !enc && col && (col + w >= wraplen))
+ if (!first && !enc && col && ((col + w) >= wraplen))
{
col = mutt_str_strlen(pfx);
fold = 1;
if (display && fold)
{
char *pc = buf;
- while (*pc && ((*pc == ' ') || (*pc == '\t')))
+ while ((pc[0] != '\0') && ((pc[0] == ' ') || (pc[0] == '\t')))
{
pc++;
col--;
* XXX this covers ASCII space only, for display we probably
* want something like iswspace() here */
const char *sp = next;
- while (*sp && ((*sp == ' ') || (*sp == '\t')))
+ while ((sp[0] != '\0') && ((sp[0] == ' ') || (sp[0] == '\t')))
sp++;
- if (*sp == '\n')
+ if (sp[0] == '\n')
{
next = sp;
col = 0;
{
char *p = s, *q = s;
- while (p && *p)
+ while (p && (p[0] != '\0'))
{
/* remove CRLF prior to FWSP, turn \t into ' ' */
- if ((*p == '\r') && *(p + 1) && (*(p + 1) == '\n') && *(p + 2) &&
- ((*(p + 2) == ' ') || (*(p + 2) == '\t')))
+ if ((p[0] == '\r') && (p[1] != '\0') && (p[1] == '\n') && (p[2] != '\0') &&
+ ((p[2] == ' ') || (p[2] == '\t')))
{
*q++ = ' ';
p += 3;
continue;
}
/* remove LF prior to FWSP, turn \t into ' ' */
- else if ((*p == '\n') && *(p + 1) && ((*(p + 1) == ' ') || (*(p + 1) == '\t')))
+ else if ((p[0] == '\n') && (p[1] != '\0') && ((p[1] == ' ') || (p[1] == '\t')))
{
*q++ = ' ';
p += 2;
*q++ = *p++;
}
if (q)
- *q = '\0';
+ q[0] = '\0';
return s;
}