From: Pierre Habouzit Date: Mon, 30 Oct 2006 21:49:09 +0000 (+0100) Subject: remove yet anoter round of str_* functions, replaced with their inlineable X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=c98480f8568e6c1bc927c6c5f2b5e80b4aa6548c remove yet anoter round of str_* functions, replaced with their inlineable counterparts. Signed-off-by: Pierre Habouzit --- diff --git a/alias.c b/alias.c index f791206..efed62d 100644 --- a/alias.c +++ b/alias.c @@ -47,7 +47,7 @@ ADDRESS *mutt_lookup_alias (const char *s) ALIAS *t = Aliases; for (; t; t = t->next) - if (!str_casecmp (s, t->name)) + if (!m_strcasecmp(s, t->name)) return (t->addr); return (NULL); /* no such alias */ } @@ -598,7 +598,7 @@ static int alias_SortAlias (const void *a, const void *b) { ALIAS *pa = *(ALIAS **) a; ALIAS *pb = *(ALIAS **) b; - int r = str_casecmp (pa->name, pb->name); + int r = m_strcasecmp(pa->name, pb->name); return (RSORT (r)); } @@ -617,7 +617,7 @@ static int alias_SortAddress (const void *a, const void *b) r = 1; else if (pa->personal) { if (pb->personal) - r = str_casecmp (pa->personal, pb->personal); + r = m_strcasecmp(pa->personal, pb->personal); else r = 1; } diff --git a/attach.c b/attach.c index 8eeb71b..9e3bbb9 100644 --- a/attach.c +++ b/attach.c @@ -299,7 +299,7 @@ static int is_mmnoask (const char *buf) } else { lng = m_strlen(p); - if (buf[lng] == '/' && str_ncasecmp (buf, p, lng) == 0) + if (buf[lng] == '/' && m_strncasecmp(buf, p, lng) == 0) return (1); } diff --git a/browser.c b/browser.c index 878b6bb..763a5be 100644 --- a/browser.c +++ b/browser.c @@ -96,7 +96,7 @@ static int browser_compare_subject (const void *a, const void *b) struct folder_file *pa = (struct folder_file *) a; struct folder_file *pb = (struct folder_file *) b; - int r = str_coll (pa->name, pb->name); + int r = strcoll(NONULL(pa->name), NONULL(pb->name)); return ((BrowserSort & SORT_REVERSE) ? -r : r); } @@ -535,7 +535,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, continue; /* we don't need . */ if (prefix && *prefix - && str_ncmp (prefix, de->d_name, m_strlen(prefix)) != 0) + && m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0) continue; if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not)) continue; diff --git a/buffy.c b/buffy.c index 99a746d..68b9165 100644 --- a/buffy.c +++ b/buffy.c @@ -79,7 +79,7 @@ static int fseeko_last_message (FILE * f) if (bytes_read == -1) return -1; for (i = bytes_read; --i >= 0;) - if (!str_ncmp (buffer + i, "\n\nFrom ", m_strlen("\n\nFrom "))) { /* found it - go to the beginning of the From */ + if (!m_strncmp(buffer + i, "\n\nFrom ", m_strlen("\n\nFrom "))) { /* found it - go to the beginning of the From */ fseeko (f, pos + i + 2, SEEK_SET); return 0; } @@ -87,7 +87,7 @@ static int fseeko_last_message (FILE * f) } /* here we are at the beginning of the file */ - if (!str_ncmp ("From ", buffer, 5)) { + if (!m_strncmp("From ", buffer, 5)) { fseeko (f, 0, 0); return (0); } diff --git a/charset.c b/charset.c index 5d7e0cc..b50ca2c 100644 --- a/charset.c +++ b/charset.c @@ -230,7 +230,7 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name) for (i = 0; PreferredMIMENames[i].key; i++) if (!ascii_strcasecmp (scratch, PreferredMIMENames[i].key) || - !str_casecmp (scratch, PreferredMIMENames[i].key)) { + !m_strcasecmp(scratch, PreferredMIMENames[i].key)) { strfcpy (dest, PreferredMIMENames[i].pref, dlen); return; } diff --git a/color.c b/color.c index d3b4be5..1e81ecb 100644 --- a/color.c +++ b/color.c @@ -298,13 +298,13 @@ parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER * err) { char *eptr; - if (str_ncasecmp (s, "bright", 6) == 0) { + if (m_strncasecmp(s, "bright", 6) == 0) { *attr |= brite; s += 6; } /* allow aliases for xterm color resources */ - if (str_ncasecmp (s, "color", 5) == 0) { + if (m_strncasecmp(s, "color", 5) == 0) { s += 5; *col = strtol (s, &eptr, 10); if (!*s || *eptr || *col < 0 || @@ -364,7 +364,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, return (-1); } - if (str_ncmp (buf->data, "index", 5) != 0) { + if (m_strncmp(buf->data, "index", 5) != 0) { snprintf (err->data, err->dsize, _("%s: command valid only for index object"), parse_uncolor ? "uncolor" : "unmono"); @@ -461,7 +461,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive, break; } else { - if (str_casecmp (s, tmp->pattern) == 0) + if (m_strcasecmp(s, tmp->pattern) == 0) break; } tmp = tmp->next; @@ -537,7 +537,7 @@ parse_object (BUFFER * buf, BUFFER * s, int *o, int *ql, BUFFER * err) } mutt_extract_token (buf, s, 0); - if (!str_ncmp (buf->data, "quoted", 6)) { + if (!m_strncmp(buf->data, "quoted", 6)) { if (buf->data[6]) { *ql = strtol (buf->data + 6, &eptr, 10); if (*eptr || q_level < 0) { diff --git a/complete.c b/complete.c index 55df906..679a839 100644 --- a/complete.c +++ b/complete.c @@ -78,7 +78,7 @@ int mutt_complete (char *s, size_t slen) NNTP_DATA *data = (NNTP_DATA *) l->data; if (data && data->subscribed && - str_ncmp (data->group, filepart, len) == 0) { + m_strncmp(data->group, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && data->group[i]; i++) { if (filepart[i] != data->group[i]) { @@ -185,7 +185,7 @@ int mutt_complete (char *s, size_t slen) } while ((de = readdir (dirp)) != NULL) { - if (str_ncmp (de->d_name, filepart, len) == 0) { + if (m_strncmp(de->d_name, filepart, len) == 0) { if (init) { for (i = 0; filepart[i] && de->d_name[i]; i++) { if (filepart[i] != de->d_name[i]) { diff --git a/copy.c b/copy.c index 717265b..2b86aad 100644 --- a/copy.c +++ b/copy.c @@ -77,7 +77,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end, /* Is it the begining of a header? */ if (nl && buf[0] != ' ' && buf[0] != '\t') { ignore = 1; - if (!from && str_ncmp ("From ", buf, 5) == 0) { + if (!from && m_strncmp("From ", buf, 5) == 0) { if ((flags & CH_FROM) == 0) continue; from = 1; @@ -167,7 +167,7 @@ mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end, ignore = 1; this_is_from = 0; - if (!from && str_ncmp ("From ", buf, 5) == 0) { + if (!from && m_strncmp("From ", buf, 5) == 0) { if ((flags & CH_FROM) == 0) continue; this_is_from = from = 1; diff --git a/crypt-gpgme.c b/crypt-gpgme.c index d01792b..c8cfd19 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -299,11 +299,11 @@ static int crypt_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr, rv |= CRYPT_KV_STRONGID; if (addr->mailbox && u_addr->mailbox - && str_casecmp (addr->mailbox, u_addr->mailbox) == 0) + && m_strcasecmp(addr->mailbox, u_addr->mailbox) == 0) rv |= CRYPT_KV_ADDR; if (addr->personal && u_addr->personal - && str_casecmp (addr->personal, u_addr->personal) == 0) + && m_strcasecmp(addr->personal, u_addr->personal) == 0) rv |= CRYPT_KV_STRING; return rv; @@ -1659,7 +1659,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, } while (fgets (buf, sizeof (buf), tfp)) { - if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) { + if (!m_strncmp("-----BEGIN PGP ", buf, 15)) { if (!m_strcmp("MESSAGE-----\n", buf + 15)) enc = 1; else if (!m_strcmp("SIGNED MESSAGE-----\n", buf + 15)) @@ -1802,7 +1802,7 @@ int pgp_gpgme_application_handler (BODY * m, STATE * s) bytes -= (offset - last_pos); /* don't rely on m_strlen(buf) */ last_pos = offset; - if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) { + if (!m_strncmp("-----BEGIN PGP ", buf, 15)) { clearsign = 0; start_pos = last_pos; @@ -2370,10 +2370,10 @@ static int _crypt_compare_address (const void *a, const void *b) crypt_key_t **t = (crypt_key_t **) b; int r; - if ((r = str_casecmp ((*s)->uid, (*t)->uid))) + if ((r = m_strcasecmp((*s)->uid, (*t)->uid))) return r > 0; else - return str_casecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0; + return m_strcasecmp(crypt_keyid (*s), crypt_keyid (*t)) > 0; } static int crypt_compare_address (const void *a, const void *b) @@ -2390,10 +2390,10 @@ static int _crypt_compare_keyid (const void *a, const void *b) crypt_key_t **t = (crypt_key_t **) b; int r; - if ((r = str_casecmp (crypt_keyid (*s), crypt_keyid (*t)))) + if ((r = m_strcasecmp(crypt_keyid (*s), crypt_keyid (*t)))) return r > 0; else - return str_casecmp ((*s)->uid, (*t)->uid) > 0; + return m_strcasecmp((*s)->uid, (*t)->uid) > 0; } static int crypt_compare_keyid (const void *a, const void *b) @@ -2419,7 +2419,7 @@ static int _crypt_compare_date (const void *a, const void *b) if (ts < tt) return 0; - return str_casecmp ((*s)->uid, (*t)->uid) > 0; + return m_strcasecmp((*s)->uid, (*t)->uid) > 0; } static int crypt_compare_date (const void *a, const void *b) @@ -2464,9 +2464,9 @@ static int _crypt_compare_trust (const void *a, const void *b) if (ts < tt) return 0; - if ((r = str_casecmp ((*s)->uid, (*t)->uid))) + if ((r = m_strcasecmp((*s)->uid, (*t)->uid))) return r > 0; - return (str_casecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0; + return (m_strcasecmp(crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0; } static int crypt_compare_trust (const void *a, const void *b) @@ -3569,12 +3569,12 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities, match = 0; debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid)); - if (!*p || !str_casecmp (p, crypt_keyid (k)) - || (!str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, crypt_keyid (k))) + if (!*p || !m_strcasecmp(p, crypt_keyid (k)) + || (!m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, crypt_keyid (k))) || (option (OPTPGPLONGIDS) - && !str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, crypt_keyid (k) + 8)) + && !m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, crypt_keyid (k) + 8)) || str_isstr (k->uid, p)) { crypt_key_t *tmp; @@ -3621,7 +3621,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, if (whatfor) { for (l = id_defaults; l; l = l->next) - if (!str_casecmp (whatfor, l->what)) { + if (!m_strcasecmp(whatfor, l->what)) { strfcpy (resp, NONULL (l->dflt), sizeof (resp)); break; } diff --git a/crypt.c b/crypt.c index 923b8d7..c1225ac 100644 --- a/crypt.c +++ b/crypt.c @@ -532,7 +532,7 @@ void convert_to_7bit (BODY * a) convert_to_7bit (a->parts); } else if (a->type == TYPEMESSAGE && - str_casecmp (a->subtype, "delivery-status")) { + m_strcasecmp(a->subtype, "delivery-status")) { if (a->encoding != ENC7BIT) mutt_message_to_7bit (a, NULL); } @@ -760,7 +760,7 @@ int mutt_signed_handler (BODY * a, STATE * s) /* consistency check */ if (!(a && a->next && a->next->type == protocol_major && - !str_casecmp (a->next->subtype, protocol_minor))) { + !m_strcasecmp(a->next->subtype, protocol_minor))) { state_attach_puts (_("[-- Error: " "Inconsistent multipart/signed structure! --]\n\n"), s); @@ -770,13 +770,13 @@ int mutt_signed_handler (BODY * a, STATE * s) if ((WithCrypto & APPLICATION_PGP) && protocol_major == TYPEAPPLICATION - && !str_casecmp (protocol_minor, "pgp-signature")); + && !m_strcasecmp(protocol_minor, "pgp-signature")); else if ((WithCrypto & APPLICATION_SMIME) && protocol_major == TYPEAPPLICATION - && !(str_casecmp (protocol_minor, "x-pkcs7-signature") - && str_casecmp (protocol_minor, "pkcs7-signature"))); + && !(m_strcasecmp(protocol_minor, "x-pkcs7-signature") + && m_strcasecmp(protocol_minor, "pkcs7-signature"))); else if (protocol_major == TYPEMULTIPART - && !str_casecmp (protocol_minor, "mixed")); + && !m_strcasecmp(protocol_minor, "mixed")); else { state_printf (s, _("[-- Error: " "Unknown multipart/signed protocol %s! --]\n\n"), @@ -794,7 +794,7 @@ int mutt_signed_handler (BODY * a, STATE * s) for (i = 0; i < sigcnt; i++) { if ((WithCrypto & APPLICATION_PGP) && signatures[i]->type == TYPEAPPLICATION - && !str_casecmp (signatures[i]->subtype, "pgp-signature")) { + && !m_strcasecmp(signatures[i]->subtype, "pgp-signature")) { if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; @@ -804,8 +804,8 @@ int mutt_signed_handler (BODY * a, STATE * s) if ((WithCrypto & APPLICATION_SMIME) && signatures[i]->type == TYPEAPPLICATION && - (!str_casecmp (signatures[i]->subtype, "x-pkcs7-signature") - || !str_casecmp (signatures[i]->subtype, + (!m_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature") + || !m_strcasecmp(signatures[i]->subtype, "pkcs7-signature"))) { if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; diff --git a/curs_main.c b/curs_main.c index 81d59c2..88ec80e 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2196,7 +2196,7 @@ int mutt_index_menu (void) sleep (2); } else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || - str_casecmp (CURHDR->env->followup_to, "poster") || + m_strcasecmp(CURHDR->env->followup_to, "poster") || query_quadoption (OPT_FOLLOWUPTOPOSTER, _("Reply by mail as poster prefers?")) != M_YES) { diff --git a/from.c b/from.c index 1ac13f5..87c44a0 100644 --- a/from.c +++ b/from.c @@ -35,7 +35,7 @@ int mutt_check_month (const char *s) int i; for (i = 0; i < 12; i++) - if (str_ncasecmp (s, Months[i], 3) == 0) + if (m_strncasecmp(s, Months[i], 3) == 0) return (i); return (-1); /* error */ } @@ -47,7 +47,7 @@ static int is_day_name (const char *s) if ((m_strlen(s) < 3) || !*(s + 3) || !ISSPACE (*(s + 3))) return 0; for (i = 0; i < 7; i++) - if (str_ncasecmp (s, Weekdays[i], 3) == 0) + if (m_strncasecmp(s, Weekdays[i], 3) == 0) return 1; return 0; } @@ -66,7 +66,7 @@ int is_from (const char *s, char *path, size_t pathlen, time_t * tp) if (path) *path = 0; - if (str_ncmp ("From ", s, 5) != 0) + if (m_strncmp("From ", s, 5) != 0) return 0; s = next_word (s); /* skip over the From part. */ diff --git a/getdomain.c b/getdomain.c index 1ffd40c..d58bb69 100644 --- a/getdomain.c +++ b/getdomain.c @@ -55,8 +55,7 @@ int getdnsdomainname (char *s, size_t l) p = tmp; while (ISSPACE (*p)) p++; - if (str_ncmp ("domain", p, 6) == 0 - || str_ncmp ("search", p, 6) == 0) { + if (m_strncmp("domain", p, 6) == 0 || m_strncmp("search", p, 6) == 0) { p += 6; for (q = strtok (p, " \t\n"); q; q = strtok (NULL, " \t\n")) diff --git a/handler.c b/handler.c index a118df7..4abb301 100644 --- a/handler.c +++ b/handler.c @@ -328,14 +328,14 @@ void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd) if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL) return; len -= m_strlen(tmps); - if ((!str_ncmp (tmps, "begin", 5)) && ISSPACE (tmps[5])) + if ((!m_strncmp(tmps, "begin", 5)) && ISSPACE (tmps[5])) break; } while (len > 0) { if ((fgets (tmps, sizeof (tmps), s->fpin)) == NULL) return; len -= m_strlen(tmps); - if (!str_ncmp (tmps, "end", 3)) + if (!m_strncmp(tmps, "end", 3)) break; pt = tmps; linelen = decode_byte (*pt); @@ -1399,7 +1399,7 @@ int mutt_body_handler (BODY * b, STATE * s) handler = mutt_signed_handler; } else if ((WithCrypto & APPLICATION_PGP) - && str_casecmp ("encrypted", b->subtype) == 0) { + && m_strcasecmp("encrypted", b->subtype) == 0) { p = mutt_get_parameter ("protocol", b->parameter); if (!p) diff --git a/hdrline.c b/hdrline.c index 2ba1266..eaf38a7 100644 --- a/hdrline.c +++ b/hdrline.c @@ -705,7 +705,7 @@ static const char *hdr_format_str (char *dest, && (hdr->thread->parent && hdr->thread->parent->message && hdr->thread->parent->message->env->x_label)) htmp = hdr->thread->parent->message; - if (htmp && str_casecmp (hdr->env->x_label, + if (htmp && m_strcasecmp(hdr->env->x_label, htmp->env->x_label) == 0) i = 0; } diff --git a/imap/browse.c b/imap/browse.c index 54d608b..9025dab 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -365,7 +365,7 @@ static int browse_add_list_result (IMAP_DATA * idata, const char *cmd, if (isparent) noselect = 1; /* prune current folder from output */ - if (isparent || str_ncmp (name, mx.mbox, m_strlen(name))) + if (isparent || m_strncmp(name, mx.mbox, m_strlen(name))) imap_add_folder (idata->delim, name, noselect, noinferiors, state, isparent); } @@ -401,7 +401,7 @@ static void imap_add_folder (char delim, char *folder, int noselect, if (isparent) strfcpy (relpath, "../", sizeof (relpath)); /* strip current folder from target, to render a relative path */ - else if (!str_ncmp (mx.mbox, folder, m_strlen(mx.mbox))) + else if (!m_strncmp(mx.mbox, folder, m_strlen(mx.mbox))) strfcpy (relpath, folder + m_strlen(mx.mbox), sizeof (relpath)); else strfcpy (relpath, folder, sizeof (relpath)); diff --git a/imap/imap.c b/imap/imap.c index 2a4feca..44d3eee 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1184,7 +1184,7 @@ int imap_mailbox_check (char *path, int new) if (m_strcmp(mbox_unquoted, idata->mailbox) == 0 || (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0 - && str_casecmp (mbox_unquoted, idata->mailbox) == 0)) { + && m_strcasecmp(mbox_unquoted, idata->mailbox) == 0)) { strfcpy (buf, "NOOP", sizeof (buf)); } else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) || @@ -1209,8 +1209,8 @@ int imap_mailbox_check (char *path, int new) /* The mailbox name may or may not be quoted here. We could try to * munge the server response and compare with quoted (or vise versa) * but it is probably more efficient to just strncmp against both. */ - if (str_ncmp (mbox_unquoted, s, m_strlen(mbox_unquoted)) == 0 - || str_ncmp (mbox, s, m_strlen(mbox)) == 0) { + if (m_strncmp(mbox_unquoted, s, m_strlen(mbox_unquoted)) == 0 + || m_strncmp(mbox, s, m_strlen(mbox)) == 0) { s = imap_next_word (s); s = imap_next_word (s); if (isdigit ((unsigned char) *s)) { @@ -1514,7 +1514,7 @@ static int imap_complete_hosts (char *dest, size_t len) { return (-1); for (i = 0; i < Incoming->length; i++) { mailbox = (BUFFY*) Incoming->data[i]; - if (!str_ncmp (dest, mailbox->path, matchlen)) { + if (!m_strncmp(dest, mailbox->path, matchlen)) { if (rc) { strfcpy (dest, mailbox->path, len); rc = 0; @@ -1535,7 +1535,7 @@ static int imap_complete_hosts (char *dest, size_t len) { url.user = NULL; url.path = NULL; url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0); - if (!str_ncmp (dest, urlstr, matchlen)) { + if (!m_strncmp(dest, urlstr, matchlen)) { if (rc) { strfcpy (dest, urlstr, len); rc = 0; diff --git a/imap/util.c b/imap/util.c index 8e6832b..5ca2fad 100644 --- a/imap/util.c +++ b/imap/util.c @@ -137,7 +137,7 @@ void imap_pretty_mailbox (char *path) if (mx_get_magic (Maildir) == M_IMAP && !imap_parse_path (Maildir, &home)) { hlen = m_strlen(home.mbox); if (tlen && mutt_account_match (&home.account, &target.account) && - !str_ncmp (home.mbox, target.mbox, hlen)) { + !m_strncmp(home.mbox, target.mbox, hlen)) { if (!hlen) home_match = 1; else diff --git a/init.c b/init.c index 6ca24b3..ef3f3d0 100644 --- a/init.c +++ b/init.c @@ -279,7 +279,7 @@ static void sys_to_string (char* dst, size_t dstlen, * if name starts with $folder, just strip it to keep hierarchy * $folder=imap://host, path=imap://host/inbox/b -> inbox/b */ - if (Maildirlength > 0 && str_ncmp (CurrentFolder, Maildir, + if (Maildirlength > 0 && m_strncmp(CurrentFolder, Maildir, Maildirlength) == 0 && m_strlen(CurrentFolder) > Maildirlength) { val = CurrentFolder + Maildirlength; @@ -1108,9 +1108,9 @@ static int parse_attach_list (BUFFER *buf, BUFFER *s, LIST **ldata, a = p_new(ATTACH_MATCH, 1); /* some cheap hacks that I expect to remove */ - if (!str_casecmp(buf->data, "any")) + if (!m_strcasecmp(buf->data, "any")) a->major = m_strdup("*/.*"); - else if (!str_casecmp(buf->data, "none")) + else if (!m_strcasecmp(buf->data, "none")) a->major = m_strdup("cheap_hack/this_should_never_match"); else a->major = m_strdup(buf->data); @@ -1164,9 +1164,9 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata, BUFFER *er do { mutt_extract_token (buf, s, 0); - if (!str_casecmp(buf->data, "any")) + if (!m_strcasecmp(buf->data, "any")) tmp = m_strdup("*/.*"); - else if (!str_casecmp(buf->data, "none")) + else if (!m_strcasecmp(buf->data, "none")) tmp = m_strdup("cheap_hack/this_should_never_match"); else tmp = m_strdup(buf->data); @@ -1186,7 +1186,7 @@ static int parse_unattach_list (BUFFER *buf, BUFFER *s, LIST **ldata, BUFFER *er a = (ATTACH_MATCH *)lp->data; debug_print(5, ("parse_unattach_list: check %s/%s [%d] : %s/%s [%d]\n", a->major, a->minor, a->major_int, tmp, minor, major)); - if (a->major_int == major && !str_casecmp(minor, a->minor)) { + if (a->major_int == major && !m_strcasecmp(minor, a->minor)) { debug_print(5, ("parse_unattach_list: removed %s/%s [%d]\n", a->major, a->minor, a->major_int)); regfree(&a->minor_rx); @@ -1258,13 +1258,13 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER op = '+'; category--; } - if (!str_ncasecmp(category, "attachment", strlen(category))) { + if (!m_strncasecmp(category, "attachment", strlen(category))) { if (op == '+') listp = &AttachAllow; else listp = &AttachExclude; } - else if (!str_ncasecmp(category, "inline", strlen(category))) { + else if (!m_strncasecmp(category, "inline", strlen(category))) { if (op == '+') listp = &InlineAllow; else @@ -1293,13 +1293,13 @@ static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFF op = '+'; p--; } - if (!str_ncasecmp(p, "attachment", strlen(p))) { + if (!m_strncasecmp(p, "attachment", strlen(p))) { if (op == '+') listp = &AttachAllow; else listp = &AttachExclude; } - else if (!str_ncasecmp(p, "inline", strlen(p))) { + else if (!m_strncasecmp(p, "inline", strlen(p))) { if (op == '+') listp = &InlineAllow; else @@ -1384,7 +1384,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s, unsigned long data, } else for (tmp = Aliases; tmp; tmp = tmp->next) { - if (str_casecmp (buf->data, tmp->name) == 0) { + if (m_strcasecmp(buf->data, tmp->name) == 0) { if (CurrentMenu == MENU_ALIAS) { tmp->del = 1; set_option (OPTFORCEREDRAWINDEX); @@ -1424,7 +1424,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s, unsigned long data, /* check to see if an alias with this name already exists */ for (; tmp; tmp = tmp->next) { - if (!str_casecmp (tmp->name, buf->data)) + if (!m_strcasecmp(tmp->name, buf->data)) break; last = tmp; } @@ -1561,12 +1561,12 @@ parse_sort (struct option_t* dst, const char *s, const struct mapping_t *map, char* errbuf, size_t errlen) { int i, flags = 0; - if (str_ncmp ("reverse-", s, 8) == 0) { + if (m_strncmp("reverse-", s, 8) == 0) { s += 8; flags = SORT_REVERSE; } - if (str_ncmp ("last-", s, 5) == 0) { + if (m_strncmp("last-", s, 5) == 0) { s += 5; flags |= SORT_LAST; } @@ -1708,8 +1708,8 @@ static void mutt_restore_default (const char* name, void* p, static int check_dsn_return (const char* option, unsigned long p, char* errbuf, size_t errlen) { char* val = (char*) p; - if (val && *val && str_ncmp (val, "hdrs", 4) != 0 && - str_ncmp (val, "full", 4) != 0) { + if (val && *val && m_strncmp(val, "hdrs", 4) != 0 && + m_strncmp(val, "full", 4) != 0) { if (errbuf) snprintf (errbuf, errlen, _("'%s' is invalid for $%s"), val, "dsn_return"); return (0); @@ -1731,10 +1731,10 @@ static int check_dsn_notify (const char* option, unsigned long p, return (1); for (i = 0; i < list->length; i++) - if (str_ncmp (list->data[i], "never", 5) != 0 && - str_ncmp (list->data[i], "failure", 7) != 0 && - str_ncmp (list->data[i], "delay", 5) != 0 && - str_ncmp (list->data[i], "success", 7) != 0) { + if (m_strncmp(list->data[i], "never", 5) != 0 && + m_strncmp(list->data[i], "failure", 7) != 0 && + m_strncmp(list->data[i], "delay", 5) != 0 && + m_strncmp(list->data[i], "success", 7) != 0) { if (errbuf) snprintf (errbuf, errlen, _("'%s' is invalid for $%s"), (char*) list->data[i], "dsn_notify"); @@ -1839,11 +1839,11 @@ static int parse_set (BUFFER * tmp, BUFFER * s, unsigned long data, query = 1; s->dptr++; } - else if (str_ncmp ("no", s->dptr, 2) == 0) { + else if (m_strncmp("no", s->dptr, 2) == 0) { s->dptr += 2; unset = !unset; } - else if (str_ncmp ("inv", s->dptr, 3) == 0) { + else if (m_strncmp("inv", s->dptr, 3) == 0) { s->dptr += 3; inv = !inv; } @@ -2284,17 +2284,17 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) /* return the completed command */ m_strcpy(buffer, len - spaces, Completed); } - else if (!str_ncmp (buffer, "set", 3) - || !str_ncmp (buffer, "unset", 5) - || !str_ncmp (buffer, "reset", 5) - || !str_ncmp (buffer, "toggle", 6)) { /* complete variables */ + else if (!m_strncmp(buffer, "set", 3) + || !m_strncmp(buffer, "unset", 5) + || !m_strncmp(buffer, "reset", 5) + || !m_strncmp(buffer, "toggle", 6)) { /* complete variables */ const char *prefixes[] = { "no", "inv", "?", "&", NULL }; pt++; /* loop through all the possible prefixes (no, inv, ...) */ - if (!str_ncmp (buffer, "set", 3)) { + if (!m_strncmp(buffer, "set", 3)) { for (num = 0; prefixes[num]; num++) { - if (!str_ncmp (pt, prefixes[num], m_strlen(prefixes[num]))) { + if (!m_strncmp(pt, prefixes[num], m_strlen(prefixes[num]))) { pt += m_strlen(prefixes[num]); break; } @@ -2332,7 +2332,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) m_strcpy(pt, buffer + len - pt - spaces, Completed); } - else if (!str_ncmp (buffer, "exec", 4)) { + else if (!m_strncmp(buffer, "exec", 4)) { struct binding_t *menu = km_get_table (CurrentMenu); if (!menu && CurrentMenu != MENU_PAGER) @@ -2401,7 +2401,7 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) if (*pt == '=') /* abort if no var before the '=' */ return 0; - if (str_ncmp (buffer, "set", 3) == 0) { + if (m_strncmp(buffer, "set", 3) == 0) { strfcpy (var, pt, sizeof(var)); /* ignore the trailing '=' when comparing */ var[m_strlen(var) - 1] = 0; diff --git a/lib-lib/ascii.h b/lib-lib/ascii.h index 5911dec..b449d8d 100644 --- a/lib-lib/ascii.h +++ b/lib-lib/ascii.h @@ -50,6 +50,6 @@ int ascii_strcasecmp(const char *a, const char *b); int ascii_strncasecmp(const char *a, const char *b, int n); #define ascii_strcmp(a,b) m_strcmp(a,b) -#define ascii_strncmp(a,b,c) str_ncmp(a,b,c) +#define ascii_strncmp(a,b,c) m_strncmp(a,b,c) #endif /* MUTT_LIB_LIB_ASCII_H */ diff --git a/lib-lib/str.h b/lib-lib/str.h index 8850830..7dc15d6 100644 --- a/lib-lib/str.h +++ b/lib-lib/str.h @@ -45,6 +45,18 @@ static inline int m_strcmp(const char *a, const char *b) { return strcmp(NONULL(a), NONULL(b)); } +static inline int m_strcasecmp(const char *a, const char *b) { + return strcasecmp(NONULL(a), NONULL(b)); +} + +static inline int m_strncmp(const char *a, const char *b, size_t n) { + return strncmp (NONULL(a), NONULL(b), n); +} + +static inline int m_strncasecmp(const char *a, const char *b, size_t n) { + return strncasecmp(NONULL(a), NONULL(b), n); +} + ssize_t m_strcpy(char *dst, ssize_t n, const char *src); ssize_t m_strncpy(char *dst, ssize_t n, const char *src, ssize_t l); diff --git a/lib/str.c b/lib/str.c index 016376e..b3fc401 100644 --- a/lib/str.c +++ b/lib/str.c @@ -17,26 +17,6 @@ #include "str.h" -int str_casecmp (const char *a, const char *b) -{ - return strcasecmp (NONULL (a), NONULL (b)); -} - -int str_ncmp (const char *a, const char *b, size_t l) -{ - return strncmp (NONULL (a), NONULL (b), l); -} - -int str_ncasecmp (const char *a, const char *b, size_t l) -{ - return strncasecmp (NONULL (a), NONULL (b), l); -} - -int str_coll (const char *a, const char *b) -{ - return strcoll (NONULL (a), NONULL (b)); -} - void str_replace (char **p, const char *s) { p_delete(p); @@ -109,7 +89,7 @@ int str_eq (const char* s1, const char* s2) { if (l != m_strlen(s2)) return (0); - return (str_ncmp (s1, s2, l) == 0); + return (m_strncmp(s1, s2, l) == 0); } char* str_skip_initws (char* s) { diff --git a/lib/str.h b/lib/str.h index 2f4e33c..8a480c3 100644 --- a/lib/str.h +++ b/lib/str.h @@ -35,15 +35,6 @@ * unreliable behavior on some systems */ # define SKIPWS(c) while (*(c) && isspace ((unsigned char) *(c))) c++; -/* - * safety wrappers/replacements - * (mostly only difference: safely handle NULL strings) - */ -int str_casecmp (const char*, const char*); -int str_ncmp (const char*, const char*, size_t); -int str_ncasecmp (const char*, const char*, size_t); -int str_coll (const char*, const char*); - /* * tools */ diff --git a/mbox.c b/mbox.c index cab71ac..46d7291 100644 --- a/mbox.c +++ b/mbox.c @@ -313,7 +313,7 @@ static int mbox_parse_mailbox (CONTEXT * ctx) */ if (fseeko (ctx->fp, tmploc, SEEK_SET) != 0 || fgets (buf, sizeof (buf), ctx->fp) == NULL || - str_ncmp ("From ", buf, 5) != 0) { + m_strncmp("From ", buf, 5) != 0) { debug_print (1, ("bad content-length in message %d (cl=%zd)\n", curhdr->index, curhdr->content->length)); debug_print (1, ("LINE: %s\n", buf)); @@ -470,7 +470,7 @@ static int _mbox_check_mailbox (CONTEXT * ctx, int *index_hint) if (fseeko (ctx->fp, ctx->size, SEEK_SET) != 0) debug_print (1, ("fseeko() failed\n")); if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) { - if ((ctx->magic == M_MBOX && str_ncmp ("From ", buffer, 5) == 0) + if ((ctx->magic == M_MBOX && m_strncmp("From ", buffer, 5) == 0) || (ctx->magic == M_MMDF && m_strcmp(MMDF_SEP, buffer) == 0)) { if (fseeko (ctx->fp, ctx->size, SEEK_SET) != 0) debug_print (1, ("fseeko() failed\n")); @@ -752,7 +752,7 @@ static int _mbox_sync_mailbox (CONTEXT * ctx, int unused, int *index_hint) if (fseeko (ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */ /* do a sanity check to make sure the mailbox looks ok */ fgets (buf, sizeof (buf), ctx->fp) == NULL || - (ctx->magic == M_MBOX && str_ncmp ("From ", buf, 5) != 0) || + (ctx->magic == M_MBOX && m_strncmp("From ", buf, 5) != 0) || (ctx->magic == M_MMDF && m_strcmp(MMDF_SEP, buf) != 0)) { debug_print (1, ("message not in expected position.\n")); debug_print (1, ("LINE: %s\n", buf)); @@ -1094,7 +1094,7 @@ int mbox_is_magic (const char* path, struct stat* st) { struct utimbuf times; #endif fgets (tmp, sizeof (tmp), f); - if (str_ncmp ("From ", tmp, 5) == 0) + if (m_strncmp("From ", tmp, 5) == 0) magic = M_MBOX; else if (m_strcmp(MMDF_SEP, tmp) == 0) magic = M_MMDF; diff --git a/mh.c b/mh.c index bba47ae..da270a2 100644 --- a/mh.c +++ b/mh.c @@ -308,11 +308,11 @@ void mh_update_sequences (CONTEXT * ctx) /* first, copy unknown sequences */ if ((ofp = fopen (sequences, "r"))) { while ((buff = mutt_read_line (buff, &s, ofp, &l))) { - if (!str_ncmp (buff, seq_unseen, m_strlen(seq_unseen))) + if (!m_strncmp(buff, seq_unseen, m_strlen(seq_unseen))) continue; - if (!str_ncmp (buff, seq_flagged, m_strlen(seq_flagged))) + if (!m_strncmp(buff, seq_flagged, m_strlen(seq_flagged))) continue; - if (!str_ncmp (buff, seq_replied, m_strlen(seq_replied))) + if (!m_strncmp(buff, seq_replied, m_strlen(seq_replied))) continue; fprintf (nfp, "%s\n", buff); @@ -492,7 +492,7 @@ static void maildir_parse_flags (HEADER * h, const char *path) h->read = 0; h->replied = 0; - if ((p = strrchr (path, ':')) != NULL && str_ncmp (p + 1, "2,", 2) == 0) { + if ((p = strrchr (path, ':')) != NULL && m_strncmp(p + 1, "2,", 2) == 0) { p += 3; str_replace (&h->maildir_flags, p); diff --git a/mutt_libesmtp.c b/mutt_libesmtp.c index ceab41b..11ea993 100644 --- a/mutt_libesmtp.c +++ b/mutt_libesmtp.c @@ -288,8 +288,8 @@ int mutt_libesmtp_check_usetls (const char* option, unsigned long p, char* val = (char*) p; if (!val || !*val) return (1); - if (str_ncmp (val, "enabled", 7) != 0 && - str_ncmp (val, "required", 8) != 0) { + if (m_strncmp(val, "enabled", 7) != 0 && + m_strncmp(val, "required", 8) != 0) { if (errbuf) snprintf (errbuf, errlen, _("'%s' is invalid for %s"), val, option); return (0); diff --git a/muttlib.c b/muttlib.c index 45dd76d..f2137a8 100644 --- a/muttlib.c +++ b/muttlib.c @@ -723,12 +723,12 @@ void mutt_pretty_mailbox (char *s) } *q = 0; - if (str_ncmp (s, Maildir, (len = m_strlen(Maildir))) == 0 && + if (m_strncmp(s, Maildir, (len = m_strlen(Maildir))) == 0 && s[len] == '/') { *s++ = '='; memmove (s, s + len, m_strlen(s + len) + 1); } - else if (str_ncmp (s, Homedir, (len = m_strlen(Homedir))) == 0 && + else if (m_strncmp(s, Homedir, (len = m_strlen(Homedir))) == 0 && s[len] == '/') { *s++ = '~'; memmove (s, s + len - 1, m_strlen(s + len - 1) + 1); diff --git a/nntp/newsrc.c b/nntp/newsrc.c index ff9df9e..66ff3f2 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -208,8 +208,8 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) rewind (index); while (fgets (buf, sizeof (buf), index)) { buf[m_strlen(buf) - 1] = 0; /* strip ending '\n' */ - if (!str_ncmp (buf, "#: ", 3) && - !str_casecmp (buf + 3, news->conn->account.host)) + if (!m_strncmp(buf, "#: ", 3) && + !m_strcasecmp(buf + 3, news->conn->account.host)) break; } while (fgets (buf, sizeof (buf), index)) { @@ -672,7 +672,7 @@ static int mutt_update_list_file (char *filename, char *section, c = buf; while (*c && *c != '\n') c++; c[0] = 0; /* strip EOL */ - if (!strncmp (buf, "#: ", 3) && !str_casecmp (buf+3, section)) + if (!strncmp (buf, "#: ", 3) && !m_strcasecmp(buf+3, section)) done++; } if (r != EOF && !done) { diff --git a/nntp/nntp.c b/nntp/nntp.c index 3a1e626..ca3e51e 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -119,7 +119,7 @@ static int nntp_auth (NNTP_SERVER * serv) return -1; } - if (str_ncmp ("281", buf, 3)) { + if (m_strncmp("281", buf, 3)) { conn->account.flags = flags; mutt_error _("Login failed."); @@ -154,9 +154,9 @@ static int nntp_connect_and_auth (NNTP_SERVER * serv) if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); - if (!str_ncmp ("200", buf, 3)) + if (!m_strncmp("200", buf, 3)) mutt_message (_("Connected to %s. Posting ok."), conn->account.host); - else if (!str_ncmp ("201", buf, 3)) + else if (!m_strncmp("201", buf, 3)) mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host); else { mutt_socket_close (conn); @@ -178,7 +178,7 @@ static int nntp_connect_and_auth (NNTP_SERVER * serv) if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); - if (!(conn->account.flags & M_ACCT_USER) && str_ncmp ("480", buf, 3)) { + if (!(conn->account.flags & M_ACCT_USER) && m_strncmp("480", buf, 3)) { serv->status = NNTP_OK; return 0; } @@ -210,30 +210,30 @@ static int nntp_attempt_features (NNTP_SERVER * serv) mutt_socket_write (conn, "XOVER\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); - if (str_ncmp ("500", buf, 3)) + if (m_strncmp("500", buf, 3)) serv->hasXOVER = 1; mutt_socket_write (conn, "XPAT\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); - if (str_ncmp ("500", buf, 3)) + if (m_strncmp("500", buf, 3)) serv->hasXPAT = 1; #if WANT_LISTGROUP_COMMAND mutt_socket_write (conn, "LISTGROUP\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return (nntp_connect_error (serv)); - if (str_ncmp ("500", buf, 3)) + if (m_strncmp("500", buf, 3)) serv->hasLISTGROUP = 1; #endif mutt_socket_write (conn, "XGTITLE +\r\n"); if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); - if (str_ncmp ("500", buf, 3)) + if (m_strncmp("500", buf, 3)) serv->hasXGTITLE = 1; - if (!str_ncmp ("282", buf, 3)) { + if (!m_strncmp("282", buf, 3)) { do { if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) return nntp_connect_error (serv); @@ -307,7 +307,7 @@ static int mutt_nntp_query (NNTP_DATA * data, char *line, size_t linelen) if (*line) done = FALSE; } - else if ((!str_ncmp ("480", buf, 3)) && nntp_auth (data->nserv) < 0) + else if ((!m_strncmp("480", buf, 3)) && nntp_auth (data->nserv) < 0) return -1; } while (!done); @@ -891,11 +891,11 @@ int nntp_open_mailbox (CONTEXT * ctx) return -1; } - if (str_ncmp ("211", buf, 3)) { + if (m_strncmp("211", buf, 3)) { LIST *l = serv->list; /* GROUP command failed */ - if (!str_ncmp ("411", buf, 3)) { + if (!m_strncmp("411", buf, 3)) { mutt_error (_("Newsgroup %s not found on server %s"), nntp_data->group, serv->conn->account.host); @@ -1208,7 +1208,7 @@ static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data) #endif return -1; } - if (str_ncmp ("211", buf, 3)) { + if (m_strncmp("211", buf, 3)) { buf[0] = 0; if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { #ifdef DEBUG @@ -1217,7 +1217,7 @@ static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data) return -1; } } - if (!str_ncmp ("211", buf, 3)) { + if (!m_strncmp("211", buf, 3)) { int first; int last; diff --git a/pager.c b/pager.c index 13f3908..ad57de7 100644 --- a/pager.c +++ b/pager.c @@ -390,7 +390,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, if (length <= q_list->length) { /* case 1: check the top level nodes */ - if (str_ncmp (qptr, q_list->prefix, length) == 0) { + if (m_strncmp(qptr, q_list->prefix, length) == 0) { if (length == q_list->length) return q_list; /* same prefix: return the current class */ @@ -477,7 +477,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, /* tmp != NULL means we already found a shorter prefix at case 1 */ if (tmp == NULL - && str_ncmp (qptr, q_list->prefix, q_list->length) == 0) { + && m_strncmp(qptr, q_list->prefix, q_list->length) == 0) { /* ok, it's a subclass somewhere on this branch */ ptr = q_list; @@ -489,7 +489,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, while (q_list) { if (length <= q_list->length) { - if (str_ncmp (tail_qptr, (q_list->prefix) + offset, tail_lng) + if (m_strncmp(tail_qptr, (q_list->prefix) + offset, tail_lng) == 0) { /* same prefix: return the current class */ if (length == q_list->length) @@ -570,7 +570,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList, else { /* longer than the current prefix: try subclassing it */ if (tmp == NULL - && str_ncmp (tail_qptr, (q_list->prefix) + offset, + && m_strncmp(tail_qptr, (q_list->prefix) + offset, q_list->length - offset) == 0) { /* still a subclass: go down one level */ ptr = q_list; @@ -678,10 +678,10 @@ resolve_types (char *buf, char *raw, struct line_t *lineInfo, int n, int last, } } } - else if (str_ncmp ("\033[0m", raw, 4) == 0) /* a little hack... */ + else if (m_strncmp("\033[0m", raw, 4) == 0) /* a little hack... */ lineInfo[n].type = MT_COLOR_NORMAL; #if 0 - else if (str_ncmp ("[-- ", buf, 4) == 0) + else if (m_strncmp("[-- ", buf, 4) == 0) lineInfo[n].type = MT_COLOR_ATTACHMENT; #else else if (check_attachment_marker ((char *) raw) == 0) @@ -2342,7 +2342,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) else followup_to = extra->hdr->env->followup_to; - if (!followup_to || str_casecmp (followup_to, "poster") || + if (!followup_to || m_strcasecmp(followup_to, "poster") || query_quadoption (OPT_FOLLOWUPTOPOSTER, _("Reply by mail as poster prefers?")) != M_YES) { if (extra->ctx && extra->ctx->magic == M_NNTP diff --git a/parse.c b/parse.c index 9ff0deb..5f737b7 100644 --- a/parse.c +++ b/parse.c @@ -596,7 +596,7 @@ BODY *mutt_parse_multipart (FILE * fp, const char *boundary, off_t end_off, crlf = (len > 1 && buffer[len - 2] == '\r') ? 1 : 0; if (buffer[0] == '-' && buffer[1] == '-' && - str_ncmp (buffer + 2, boundary, blen) == 0) { + m_strncmp(buffer + 2, boundary, blen) == 0) { if (last) { last->length = ftello (fp) - last->offset - len - 1 - crlf; if (last->parts && last->parts->length == 0) @@ -1040,7 +1040,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, matched = 1; } #ifdef USE_NNTP - else if (!str_casecmp (line + 1, "ollowup-to")) { + else if (!m_strcasecmp(line + 1, "ollowup-to")) { if (!e->followup_to) { str_skip_trailws (p); e->followup_to = m_strdup(str_skip_initws (p)); @@ -1123,7 +1123,7 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, #ifdef USE_NNTP case 'n': - if (!str_casecmp (line + 1, "ewsgroups")) { + if (!m_strcasecmp(line + 1, "ewsgroups")) { p_delete(&e->newsgroups); str_skip_trailws (p); e->newsgroups = m_strdup(str_skip_initws (p)); @@ -1134,8 +1134,8 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, case 'o': /* field `Organization:' saves only for pager! */ - if (!str_casecmp (line + 1, "rganization")) { - if (!e->organization && str_casecmp (p, "unknown")) + if (!m_strcasecmp(line + 1, "rganization")) { + if (!e->organization && m_strcasecmp(p, "unknown")) e->organization = m_strdup(p); } break; @@ -1232,12 +1232,12 @@ int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p, matched = 1; } #ifdef USE_NNTP - else if (!str_casecmp (line + 1, "-comment-to")) { + else if (!m_strcasecmp(line + 1, "-comment-to")) { if (!e->x_comment_to) e->x_comment_to = m_strdup(p); matched = 1; } - else if (!str_casecmp (line + 1, "ref")) { + else if (!m_strcasecmp(line + 1, "ref")) { if (!e->xref) e->xref = m_strdup(p); matched = 1; @@ -1329,7 +1329,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs, time_t t; /* some bogus MTAs will quote the original "From " line */ - if (str_ncmp (">From ", line, 6) == 0) + if (m_strncmp(">From ", line, 6) == 0) continue; /* just ignore */ else if (is_from (line, return_path, sizeof (return_path), &t)) { /* MH somtimes has the From_ line in the middle of the header! */ @@ -1491,7 +1491,7 @@ int count_body_parts (BODY *body, int flags) { } else if (bp->type == TYPEMULTIPART) { /* Always recurse multiparts, except multipart/alternative. */ shallrecurse = 1; - if (!str_casecmp(bp->subtype, "alternative")) + if (!m_strcasecmp(bp->subtype, "alternative")) shallrecurse = 0; /* Don't count containers if they're top-level. */ diff --git a/pattern.c b/pattern.c index 03b3940..e4d7caa 100644 --- a/pattern.c +++ b/pattern.c @@ -1289,7 +1289,7 @@ int mutt_pattern_func (int op, char *prompt) } /* record new limit pattern, unless match all */ - if (str_ncmp (buf, "~A", 2) != 0) { + if (m_strncmp(buf, "~A", 2) != 0) { Context->pattern = simple; simple = NULL; /* don't clobber it */ Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err); diff --git a/pgp.c b/pgp.c index 13104bc..33213bd 100644 --- a/pgp.c +++ b/pgp.c @@ -269,7 +269,7 @@ int pgp_application_pgp_handler (BODY * m, STATE * s) bytes -= (offset - last_pos); /* don't rely on m_strlen(buf) */ last_pos = offset; - if (str_ncmp ("-----BEGIN PGP ", buf, 15) == 0) { + if (m_strncmp("-----BEGIN PGP ", buf, 15) == 0) { clearsign = 0; start_pos = last_pos; @@ -507,7 +507,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, } while (fgets (buf, sizeof (buf), tfp)) { - if (str_ncmp ("-----BEGIN PGP ", buf, 15) == 0) { + if (m_strncmp("-----BEGIN PGP ", buf, 15) == 0) { if (m_strcmp("MESSAGE-----\n", buf + 15) == 0) enc = 1; else if (m_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0) diff --git a/pgpkey.c b/pgpkey.c index d995bc8..2411ee9 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -283,10 +283,10 @@ static int _pgp_compare_address (const void *a, const void *b) pgp_uid_t **s = (pgp_uid_t **) a; pgp_uid_t **t = (pgp_uid_t **) b; - if ((r = str_casecmp ((*s)->addr, (*t)->addr))) + if ((r = m_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; else - return (str_casecmp (_pgp_keyid ((*s)->parent), + return (m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent)) > 0); } @@ -305,11 +305,11 @@ static int _pgp_compare_keyid (const void *a, const void *b) pgp_uid_t **s = (pgp_uid_t **) a; pgp_uid_t **t = (pgp_uid_t **) b; - if ((r = str_casecmp (_pgp_keyid ((*s)->parent), + if ((r = m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent)))) return r > 0; else - return (str_casecmp ((*s)->addr, (*t)->addr)) > 0; + return (m_strcasecmp((*s)->addr, (*t)->addr)) > 0; } static int pgp_compare_keyid (const void *a, const void *b) @@ -326,7 +326,7 @@ static int _pgp_compare_date (const void *a, const void *b) if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r > 0; - return (str_casecmp ((*s)->addr, (*t)->addr)) > 0; + return (m_strcasecmp((*s)->addr, (*t)->addr)) > 0; } static int pgp_compare_date (const void *a, const void *b) @@ -351,9 +351,9 @@ static int _pgp_compare_trust (const void *a, const void *b) return r < 0; if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r < 0; - if ((r = str_casecmp ((*s)->addr, (*t)->addr))) + if ((r = m_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; - return (str_casecmp (_pgp_keyid ((*s)->parent), + return (m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent))) > 0; } @@ -412,11 +412,11 @@ static int pgp_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr, rv |= PGP_KV_STRONGID; if (addr->mailbox && u_addr->mailbox - && str_casecmp (addr->mailbox, u_addr->mailbox) == 0) + && m_strcasecmp(addr->mailbox, u_addr->mailbox) == 0) rv |= PGP_KV_ADDR; if (addr->personal && u_addr->personal - && str_casecmp (addr->personal, u_addr->personal) == 0) + && m_strcasecmp(addr->personal, u_addr->personal) == 0) rv |= PGP_KV_STRING; return rv; @@ -647,7 +647,7 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, if (whatfor) { for (l = id_defaults; l; l = l->next) - if (!str_casecmp (whatfor, l->what)) { + if (!m_strcasecmp(whatfor, l->what)) { strfcpy (resp, NONULL (l->dflt), sizeof (resp)); break; } @@ -933,11 +933,11 @@ pgp_key_t pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring) for (a = k->address; a; a = a->next) { debug_print (5, ("matching \"%s\" against key %s, \"%s\":\n", p, pgp_keyid (k), a->addr)); - if (!*p || str_casecmp (p, pgp_keyid (k)) == 0 - || (!str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, pgp_keyid (k))) - || (option (OPTPGPLONGIDS) && !str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, k->keyid + 8)) + if (!*p || m_strcasecmp(p, pgp_keyid (k)) == 0 + || (!m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, pgp_keyid (k))) + || (option (OPTPGPLONGIDS) && !m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, k->keyid + 8)) || str_isstr (a->addr, p)) { debug_print (5, ("match.\n")); match = 1; diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 5dc846d..2c4deb2 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -94,7 +94,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) break; #ifdef USE_SASL - if (!str_ncmp (inbuf, "+ ", 2) + if (!m_strncmp(inbuf, "+ ", 2) && sasl_decode64 (inbuf, strlen (inbuf), buf, LONG_STRING - 1, &len) != SASL_OK) #endif @@ -134,7 +134,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) if (rc != SASL_OK) goto bail; - if (!str_ncmp (inbuf, "+OK", 3)) { + if (!m_strncmp(inbuf, "+OK", 3)) { mutt_sasl_setup_conn (pop_data->conn, saslconn); return POP_A_SUCCESS; } @@ -143,7 +143,7 @@ bail: sasl_dispose (&saslconn); /* terminate SASL sessoin if the last responce is not +OK nor -ERR */ - if (!str_ncmp (inbuf, "+ ", 2)) { + if (!m_strncmp(inbuf, "+ ", 2)) { snprintf (buf, sizeof (buf), "*\r\n"); if (pop_query (pop_data, buf, sizeof (buf)) == PQ_NOT_CONNECTED) return POP_A_SOCKET; diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 285ed44..d32bf37 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -67,7 +67,7 @@ void pop_error (POP_DATA * pop_data, char *msg) t = strchr (pop_data->err_msg, '\0'); c = msg; - if (!str_ncmp (msg, "-ERR ", 5)) { + if (!m_strncmp(msg, "-ERR ", 5)) { c2 = msg + 5; SKIPWS (c2); @@ -222,7 +222,7 @@ pop_query_status pop_connect (POP_DATA * pop_data) pop_data->status = POP_CONNECTED; - if (str_ncmp (buf, "+OK", 3)) { + if (m_strncmp(buf, "+OK", 3)) { *pop_data->err_msg = '\0'; pop_error (pop_data, buf); mutt_error ("%s", pop_data->err_msg); @@ -411,7 +411,7 @@ pop_query_status pop_query_d (POP_DATA * pop_data, char *buf, size_t buflen, con pop_data->status = POP_DISCONNECTED; return PQ_NOT_CONNECTED; } - if (!str_ncmp (buf, "+OK", 3)) + if (!m_strncmp(buf, "+OK", 3)) return PQ_OK; pop_error (pop_data, buf); diff --git a/postpone.c b/postpone.c index f0ef950..8d020d2 100644 --- a/postpone.c +++ b/postpone.c @@ -334,10 +334,10 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, tmp = next; } else if ((WithCrypto & APPLICATION_PGP) - && (str_ncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated + && (m_strncmp("Pgp:", tmp->data, 4) == 0 /* this is generated * by old mutt versions */ - || str_ncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)) { + || m_strncmp("X-Mutt-PGP:", tmp->data, 11) == 0)) { hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1); hdr->security |= APPLICATION_PGP; @@ -352,7 +352,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, tmp = next; } else if ((WithCrypto & APPLICATION_SMIME) - && str_ncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0) { + && m_strncmp("X-Mutt-SMIME:", tmp->data, 13) == 0) { hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1); hdr->security |= APPLICATION_SMIME; @@ -368,7 +368,7 @@ int mutt_get_postponed (CONTEXT * ctx, HEADER * hdr, HEADER ** cur, char *fcc, } #ifdef MIXMASTER - else if (str_ncmp ("X-Mutt-Mix:", tmp->data, 11) == 0) { + else if (m_strncmp("X-Mutt-Mix:", tmp->data, 11) == 0) { char *t; mutt_free_list (&hdr->chain); diff --git a/recvattach.c b/recvattach.c index 885c528..157e93e 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1200,7 +1200,7 @@ void mutt_view_attachments (HEADER * hdr) CHECK_ATTACH; if (!idx[menu->current]->content->hdr->env->followup_to || - str_casecmp (idx[menu->current]->content->hdr->env->followup_to, + m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to, "poster") || query_quadoption (OPT_FOLLOWUPTOPOSTER, _("Reply by mail as poster prefers?")) != diff --git a/recvcmd.c b/recvcmd.c index fec63fe..dff5aee 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -689,7 +689,7 @@ attach_reply_envelope_defaults (ENVELOPE * env, ATTACHPTR ** idx, if ((flags & SENDNEWS)) { /* in case followup set Newsgroups: with Followup-To: if it present */ if (!env->newsgroups && curenv && - str_casecmp (curenv->followup_to, "poster")) + m_strcasecmp(curenv->followup_to, "poster")) env->newsgroups = m_strdup(curenv->followup_to); } else diff --git a/send.c b/send.c index 01fde6c..4bf3b74 100644 --- a/send.c +++ b/send.c @@ -751,7 +751,7 @@ envelope_defaults (ENVELOPE * env, CONTEXT * ctx, HEADER * cur, int flags) if ((flags & SENDNEWS)) { /* in case followup set Newsgroups: with Followup-To: if it present */ if (!env->newsgroups && curenv && - str_casecmp (curenv->followup_to, "poster")) + m_strcasecmp(curenv->followup_to, "poster")) env->newsgroups = m_strdup(curenv->followup_to); } else diff --git a/sendlib.c b/sendlib.c index a461354..add4d74 100644 --- a/sendlib.c +++ b/sendlib.c @@ -121,11 +121,11 @@ static void encode_quoted (FGETCONV * fc, FILE * fout, int istext) } /* Escape lines that begin with/only contain "the message separator". */ - if (linelen == 4 && !str_ncmp ("From", line, 4)) { + if (linelen == 4 && !m_strncmp("From", line, 4)) { strfcpy (line, "=46rom", sizeof (line)); linelen = 6; } - else if (linelen == 4 && !str_ncmp ("from", line, 4)) { + else if (linelen == 4 && !m_strncmp("from", line, 4)) { strfcpy (line, "=66rom", sizeof (line)); linelen = 6; } @@ -937,7 +937,7 @@ int mutt_lookup_mime_type (BODY * att, const char *path) while ((p = strtok (p, " \t\n"))) { sze = m_strlen(p); if ((sze > cur_sze) && (szf >= sze) && - (str_casecmp (path + szf - sze, p) == 0 + (m_strcasecmp(path + szf - sze, p) == 0 || ascii_strcasecmp (path + szf - sze, p) == 0) && (szf == sze || path[szf - diff --git a/sidebar.c b/sidebar.c index f86597c..ab95a22 100644 --- a/sidebar.c +++ b/sidebar.c @@ -211,12 +211,12 @@ int make_sidebar_entry (char* box, int idx, size_t len) memset(&entry, ' ', sizeof(entry)); #if USE_IMAP - if (l > 0 && str_ncmp (box, ImapHomeNamespace, l) == 0 && + if (l > 0 && m_strncmp(box, ImapHomeNamespace, l) == 0 && m_strlen(box) > l) box += l + 1; /* we're trimming the ImapHomeNamespace, the "+ 1" is for the separator */ else #endif - if (l_m > 0 && str_ncmp (box, Maildir, l_m) == 0 && + if (l_m > 0 && m_strncmp(box, Maildir, l_m) == 0 && m_strlen(box) > l_m) { box += l_m; if (Maildir[strlen(Maildir)-1]!='/') { diff --git a/smime.c b/smime.c index 608d53b..6a2486d 100644 --- a/smime.c +++ b/smime.c @@ -513,7 +513,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, } while (fgets (buf, sizeof (buf) - 1, fp) != NULL) - if (mailbox && !(str_ncasecmp (mailbox, buf, addr_len))) { + if (mailbox && !(m_strncasecmp(mailbox, buf, addr_len))) { numFields = sscanf (buf, MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " @@ -575,13 +575,13 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, /* query = label: return certificate. */ if (numFields >= 3 && - !(str_ncasecmp (query, fields[2], query_len))) { + !(m_strncasecmp(query, fields[2], query_len))) { ask = 0; strfcpy (key, fields[1], sizeof (key)); } /* query = certificate: return intermediate certificate. */ else if (numFields >= 4 && - !(str_ncasecmp (query, fields[1], query_len))) { + !(m_strncasecmp(query, fields[1], query_len))) { ask = 0; strfcpy (key, fields[3], sizeof (key)); } @@ -650,7 +650,7 @@ void _smime_getkeys (char *mailbox) if (k) { /* the key used last time. */ if (*SmimeKeyToUse && - !str_casecmp (k, SmimeKeyToUse + m_strlen(SmimeKeys) + 1)) { + !m_strcasecmp(k, SmimeKeyToUse + m_strlen(SmimeKeys) + 1)) { p_delete(&k); return; } @@ -663,7 +663,7 @@ void _smime_getkeys (char *mailbox) snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s", NONULL (SmimeCertificates), k); - if (str_casecmp (k, SmimeDefaultKey)) + if (m_strcasecmp(k, SmimeDefaultKey)) smime_void_passphrase (); p_delete(&k); @@ -671,7 +671,7 @@ void _smime_getkeys (char *mailbox) } if (*SmimeKeyToUse) { - if (!str_casecmp (SmimeDefaultKey, + if (!m_strcasecmp(SmimeDefaultKey, SmimeKeyToUse + m_strlen(SmimeKeys) + 1)) return; @@ -835,7 +835,7 @@ static int smime_handle_cert_email (char *certificate, char *mailbox, while ((fgets (email, sizeof (email), fpout))) { *(email + m_strlen(email) - 1) = '\0'; - if (str_ncasecmp (email, mailbox, m_strlen(mailbox)) == 0) + if (m_strncasecmp(email, mailbox, m_strlen(mailbox)) == 0) ret = 1; ret = ret < 0 ? 0 : ret; @@ -1565,7 +1565,7 @@ int smime_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) rewind (smimeerr); line = mutt_read_line (line, &linelen, smimeerr, &lineno); - if (linelen && !str_casecmp (line, "verification successful")) + if (linelen && !m_strcasecmp(line, "verification successful")) badsig = 0; p_delete(&line); @@ -1779,7 +1779,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile) rewind (smimeerr); line = mutt_read_line (line, &linelen, smimeerr, &lineno); - if (linelen && !str_casecmp (line, "verification successful")) + if (linelen && !m_strcasecmp(line, "verification successful")) m->goodsig = 1; p_delete(&line); } diff --git a/sort.c b/sort.c index af00646..b6aad71 100644 --- a/sort.c +++ b/sort.c @@ -83,7 +83,7 @@ int compare_subject (const void *a, const void *b) else if (!(*pb)->env->real_subj) rc = 1; else - rc = str_casecmp ((*pa)->env->real_subj, (*pb)->env->real_subj); + rc = m_strcasecmp((*pa)->env->real_subj, (*pb)->env->real_subj); AUXSORT (rc, a, b); return (SORTCODE (rc)); } @@ -121,7 +121,7 @@ int compare_to (const void *a, const void *b) m_strcpy(fa, sizeof(fa), mutt_get_name((*ppa)->env->to)); m_strcpy(fb, sizeof(fb), mutt_get_name((*ppb)->env->to)); - result = str_casecmp (fa, fb); + result = m_strcasecmp(fa, fb); AUXSORT (result, a, b); return (SORTCODE (result)); } @@ -141,7 +141,7 @@ int compare_from (const void *a, const void *b) m_strcpy(fa, sizeof(fa), mutt_get_name((*ppa)->env->from)); m_strcpy(fb, sizeof(fb), mutt_get_name((*ppb)->env->from)); - result = str_casecmp (fa, fb); + result = m_strcasecmp(fa, fb); AUXSORT (result, a, b); return (SORTCODE (result)); } diff --git a/thread.c b/thread.c index dc786bb..6d2b649 100644 --- a/thread.c +++ b/thread.c @@ -1252,7 +1252,7 @@ static void clean_references (THREAD * brk, THREAD * cur) for (p = brk; !done && p; p = p->parent) for (ref = cur->message->env->references; p->message && ref; ref = ref->next) - if (!str_casecmp (ref->data, p->message->env->message_id)) { + if (!m_strcasecmp(ref->data, p->message->env->message_id)) { done = 1; break; }