From: Richard Russon Date: Wed, 15 May 2019 19:01:38 +0000 (+0100) Subject: tidy char pointers X-Git-Tag: 2019-10-25~204^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11fa65e00f1f61b26a4dcab3fca46331868e4889;p=neomutt tidy char pointers Make char-pointer dereferencing more consistent. Any functions that used both `*ptr` and `ptr[0]` notation have been tidied. --- diff --git a/email/rfc2231.c b/email/rfc2231.c index 15363d344..ef17b563c 100644 --- a/email/rfc2231.c +++ b/email/rfc2231.c @@ -115,10 +115,10 @@ static void decode_one(char *dest, char *src) 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 @@ -267,9 +267,9 @@ void rfc2231_decode_parameters(struct ParameterList *p) 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); @@ -279,12 +279,12 @@ void rfc2231_decode_parameters(struct ParameterList *p) } 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 diff --git a/email/tags.c b/email/tags.c index c4383345e..ca0d8bf3e 100644 --- a/email/tags.c +++ b/email/tags.c @@ -94,8 +94,8 @@ static void driver_tags_add(struct TagHead *head, char *new_tag) 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; } diff --git a/handler.c b/handler.c index b50a34d81..f3bb0b9c5 100644 --- a/handler.c +++ b/handler.c @@ -215,14 +215,13 @@ static void decode_xbit(struct State *s, long len, bool istext, iconv_t cd) 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; } @@ -450,7 +449,7 @@ static bool is_mmnoask(const char *buf) q = strrchr(p, '/'); if (q) { - if (*(q + 1) == '*') + if (q[1] == '*') { if (mutt_str_strncasecmp(buf, p, q - p) == 0) return true; diff --git a/imap/imap.c b/imap/imap.c index 4685861b5..7d752da8f 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2333,7 +2333,7 @@ static int imap_tags_edit(struct Mailbox *m, const char *tags, char *buf, size_t } /* Skip duplicate space */ - while ((*checker == ' ') && (*(checker + 1) == ' ')) + while ((checker[0] == ' ') && (checker[1] == ' ')) checker++; /* copy char to new and go the next one */ diff --git a/imap/util.c b/imap/util.c index 729e532b8..ad75599e0 100644 --- a/imap/util.c +++ b/imap/util.c @@ -822,13 +822,13 @@ void imap_cachepath(char delim, const char *mailbox, char *dest, size_t dlen) 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 = '_'; diff --git a/init.c b/init.c index 5085ad683..a1725408e 100644 --- a/init.c +++ b/init.c @@ -2688,15 +2688,15 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags 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': @@ -2715,10 +2715,10 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags 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 @@ -2727,7 +2727,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags } 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 == '^') @@ -2761,7 +2761,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags if (*pc == '\\') pc += 2; } - } while (pc && *pc != '`'); + } while (pc && (pc[0] != '`')); if (!pc) { mutt_debug(LL_DEBUG1, "mismatched backticks\n"); @@ -2825,12 +2825,12 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags } } 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) @@ -2850,7 +2850,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags } 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; diff --git a/mutt/date.c b/mutt/date.c index af12e1459..ab1b7465d 100644 --- a/mutt/date.c +++ b/mutt/date.c @@ -424,7 +424,7 @@ int mutt_date_check_month(const char *s) */ 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++) diff --git a/mutt_header.c b/mutt_header.c index 15ec5033a..689c6586f 100644 --- a/mutt_header.c +++ b/mutt_header.c @@ -305,15 +305,15 @@ void mutt_edit_headers(const char *editor, const char *body, struct Email *msg, 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); diff --git a/muttlib.c b/muttlib.c index 852002df2..fbdcfe425 100644 --- a/muttlib.c +++ b/muttlib.c @@ -156,7 +156,7 @@ void mutt_buffer_expand_path_regex(struct Buffer *buf, bool regex) { case '~': { - if ((*(s + 1) == '/') || (*(s + 1) == 0)) + if ((s[1] == '/') || (s[1] == '\0')) { mutt_buffer_strcpy(p, HomeDir); tail = s + 1; @@ -258,7 +258,7 @@ void mutt_buffer_expand_path_regex(struct Buffer *buf, bool regex) case '!': { - if (*(s + 1) == '!') + if (s[1] == '!') { mutt_buffer_strcpy(p, LastFolder); tail = s + 2; diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index c5cd0823a..59dec0c84 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -3812,9 +3812,9 @@ static const char *parse_dn_part(struct DnArray *array, const char *str) 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) @@ -3852,7 +3852,7 @@ static const char *parse_dn_part(struct DnArray *array, const char *str) { n++; } - else if (isxdigit(*s) && isxdigit(*(s + 1))) + else if (isxdigit(s[0]) && isxdigit(s[1])) { s++; n++; @@ -3912,9 +3912,9 @@ static struct DnArray *parse_dn(const char *str) arrayidx = 0; while (*str) { - while (*str == ' ') + while (str[0] == ' ') str++; - if (!*str) + if (str[0] == '\0') break; /* ready */ if (arrayidx >= arraysize) { @@ -3935,11 +3935,11 @@ static struct DnArray *parse_dn(const char *str) 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; diff --git a/ncrypt/gnupgparse.c b/ncrypt/gnupgparse.c index a8214ac40..35f0dc4b1 100644 --- a/ncrypt/gnupgparse.c +++ b/ncrypt/gnupgparse.c @@ -82,10 +82,10 @@ static void fix_uid(char *uid) 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 @@ -110,7 +110,7 @@ static void fix_uid(char *uid) 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); diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 7218df146..b2c411ae5 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -565,15 +565,15 @@ static void apply_exclude_tags(notmuch_query_t *query) 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; @@ -1264,23 +1264,23 @@ static int update_tags(notmuch_message_t *msg, const char *tags) 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)) @@ -1294,8 +1294,8 @@ static int update_tags(notmuch_message_t *msg, const char *tags) } 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; @@ -1331,20 +1331,20 @@ static int update_email_flags(struct Mailbox *m, struct Email *e, const char *ta 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) @@ -1354,7 +1354,7 @@ static int update_email_flags(struct Mailbox *m, struct Email *e, const char *ta } 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) diff --git a/pager.c b/pager.c index bc9496cc4..3d7048102 100644 --- a/pager.c +++ b/pager.c @@ -836,8 +836,12 @@ static int braille_col = -1; */ 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); } @@ -1319,24 +1323,24 @@ static int fill_buffer(FILE *fp, LOFF_T *last_pos, LOFF_T offset, unsigned char 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))) { diff --git a/pattern.c b/pattern.c index e41da2c1c..619957be0 100644 --- a/pattern.c +++ b/pattern.c @@ -1460,17 +1460,17 @@ struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buf 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) { @@ -1478,7 +1478,7 @@ struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buf 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; @@ -1527,8 +1527,8 @@ struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buf 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; @@ -1560,7 +1560,7 @@ struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buf if (entry->eat_arg) { - if (!*ps.dptr) + if (ps.dptr[0] == '\0') { mutt_buffer_printf(err, "%s", _("missing parameter")); goto cleanup; @@ -1577,7 +1577,7 @@ struct PatternHead *mutt_pattern_comp(/* const */ char *s, int flags, struct Buf case '(': { p = find_matching_paren(ps.dptr + 1); - if (*p != ')') + if (p[0] != ')') { mutt_buffer_printf(err, _("mismatched parentheses: %s"), ps.dptr); goto cleanup; @@ -2268,11 +2268,11 @@ void mutt_check_simple(struct Buffer *buf, const char *simple) { 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; diff --git a/postpone.c b/postpone.c index 4c321e9e0..a385afbdd 100644 --- a/postpone.c +++ b/postpone.c @@ -457,23 +457,23 @@ SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, Securit 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; @@ -499,11 +499,11 @@ SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, Securit * 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; @@ -522,21 +522,22 @@ SecurityFlags mutt_parse_crypt_hdr(const char *p, bool set_empty_signas, Securit 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: diff --git a/sendlib.c b/sendlib.c index e203c0736..9f37753d2 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1848,7 +1848,7 @@ void mutt_write_references(const struct ListHead *r, FILE *fp, size_t trim) 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; @@ -1862,13 +1862,13 @@ static int print_val(FILE *fp, const char *pfx, const char *value, } 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; @@ -1906,7 +1906,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, 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; @@ -1927,7 +1927,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, /* 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; @@ -1940,7 +1940,7 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, if (display && fold) { char *pc = buf; - while (*pc && ((*pc == ' ') || (*pc == '\t'))) + while ((pc[0] != '\0') && ((pc[0] == ' ') || (pc[0] == '\t'))) { pc++; col--; @@ -1962,9 +1962,9 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value, * 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; @@ -1994,18 +1994,18 @@ static char *unfold_header(char *s) { 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; @@ -2014,7 +2014,7 @@ static char *unfold_header(char *s) *q++ = *p++; } if (q) - *q = '\0'; + q[0] = '\0'; return s; }