From: Julien Danjou Date: Sun, 26 Nov 2006 19:46:23 +0000 (+0100) Subject: Use m_strncmp instead of strncmp X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=81efbf8081bad2eed7ad07209b301ca35fe183e8 Use m_strncmp instead of strncmp Signed-off-by: Julien Danjou Signed-off-by: Pierre Habouzit --- diff --git a/browser.c b/browser.c index a9437dd..52fbb06 100644 --- a/browser.c +++ b/browser.c @@ -462,8 +462,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, if (!(data = (NNTP_DATA *) tmp->data)) continue; nntp_sync_sidebar (data); - if (prefix && *prefix && strncmp (prefix, data->group, - m_strlen(prefix)) != 0) + if (m_strncmp (prefix, data->group, m_strlen(prefix)) != 0) continue; if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) continue; @@ -516,8 +515,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, if (m_strcmp(de->d_name, ".") == 0) continue; /* we don't need . */ - if (prefix && *prefix - && m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0) + if (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/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index 6050418..4737fed 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -3865,7 +3865,7 @@ static int verify_sender (HEADER * h, gpgme_protocol_t protocol __attribute__((u if (1 && (uid->email[0] == '<') && (uid->email[uid_length - 1] == '>') && (uid_length == sender_length + 2) - && (!strncmp (uid->email + 1, sender->mailbox, sender_length))) + && (!m_strncmp (uid->email + 1, sender->mailbox, sender_length))) ret = 0; } } diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index d0104a7..e27fba7 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -130,7 +130,7 @@ static int pgp_copy_checksig (FILE * fpin, FILE * fpout) rv = 0; } - if (strncmp (line, "[GNUPG:] ", 9) == 0) + if (m_strncmp (line, "[GNUPG:] ", 9) == 0) continue; fputs (line, fpout); fputc ('\n', fpout); @@ -974,7 +974,7 @@ BODY *pgp_sign_message (BODY * a) static short is_numerical_keyid (const char *s) { /* or should we require the "0x"? */ - if (strncmp (s, "0x", 2) == 0) + if (m_strncmp (s, "0x", 2) == 0) s += 2; if (m_strlen(s) % 8) return 0; @@ -1040,7 +1040,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc) p->mailbox); if ((r = mutt_yesorno (buf, M_YES)) == M_YES) { if (is_numerical_keyid (keyID)) { - if (strncmp (keyID, "0x", 2) == 0) + if (m_strncmp (keyID, "0x", 2) == 0) keyID += 2; goto bypass_selection; /* you don't see this. */ } diff --git a/lib-crypt/pgpmicalg.c b/lib-crypt/pgpmicalg.c index 4e5e836..ae16b11 100644 --- a/lib-crypt/pgpmicalg.c +++ b/lib-crypt/pgpmicalg.c @@ -65,7 +65,7 @@ static void pgp_dearmor (FILE * in, FILE * out) /* find the beginning of ASCII armor */ while ((r = fgets (line, sizeof (line), in)) != NULL) { - if (!strncmp (line, "-----BEGIN", 10)) + if (!m_strncmp (line, "-----BEGIN", 10)) break; } if (r == NULL) { @@ -89,7 +89,7 @@ static void pgp_dearmor (FILE * in, FILE * out) /* find the checksum */ while ((r = fgets (line, sizeof (line), in)) != NULL) { - if (*line == '=' || !strncmp (line, "-----END", 8)) + if (*line == '=' || !m_strncmp (line, "-----END", 8)) break; } if (r == NULL) { diff --git a/lib-lib/url.c b/lib-lib/url.c index 4829aa5..ce0f970 100644 --- a/lib-lib/url.c +++ b/lib-lib/url.c @@ -96,7 +96,7 @@ static char *ciss_parse_userhost(ciss_url_t *ciss, char *src) ciss->host = NULL; ciss->port = 0; - if (strncmp(src, "//", 2)) + if (m_strncmp(src, "//", 2)) return src; src += 2; diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index b03a17a..b1f6aef 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -800,7 +800,7 @@ string_list_t **mutt_parse_rfc822_line(ENVELOPE *e, HEADER *hdr, char *line, cha case MIME_LIST_POST: /* RFC 2369. FIXME: We should ignore whitespace, but don't. */ - if (strncmp(p, "NO", 2)) { + if (m_strncmp(p, "NO", 2)) { char *beg, *end; for (beg = strchr (p, '<'); beg; beg = strchr (end, ',')) { diff --git a/lib-mx/mh.c b/lib-mx/mh.c index 2ff376f..c3b671b 100644 --- a/lib-mx/mh.c +++ b/lib-mx/mh.c @@ -373,17 +373,17 @@ static void mh_sequences_add_one (CONTEXT * ctx, int n, short unseen, snprintf (sequences, sizeof (sequences), "%s/.mh_sequences", ctx->path); if ((ofp = fopen (sequences, "r"))) { while ((buff = mutt_read_line (buff, &sz, ofp, &line))) { - if (unseen && !strncmp (buff, seq_unseen, m_strlen(seq_unseen))) { + if (unseen && !m_strncmp (buff, seq_unseen, m_strlen(seq_unseen))) { fprintf (nfp, "%s %d\n", buff, n); unseen_done = 1; } else if (flagged - && !strncmp (buff, seq_flagged, m_strlen(seq_flagged))) { + && !m_strncmp (buff, seq_flagged, m_strlen(seq_flagged))) { fprintf (nfp, "%s %d\n", buff, n); flagged_done = 1; } else if (replied - && !strncmp (buff, seq_replied, m_strlen(seq_replied))) { + && !m_strncmp (buff, seq_replied, m_strlen(seq_replied))) { fprintf (nfp, "%s %d\n", buff, n); replied_done = 1; } @@ -1525,8 +1525,8 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint, int unused __a * Check to see if we have enough information to know if the * message has disappeared out from underneath us. */ - else if (((changed & 1) && (!strncmp (ctx->hdrs[i]->path, "new/", 4))) || - ((changed & 2) && (!strncmp (ctx->hdrs[i]->path, "cur/", 4)))) { + else if (((changed & 1) && (!m_strncmp (ctx->hdrs[i]->path, "new/", 4))) || + ((changed & 2) && (!m_strncmp (ctx->hdrs[i]->path, "cur/", 4)))) { /* This message disappeared, so we need to simulate a "reopen" * event. We know it disappeared because we just scanned the * subdirectory it used to reside in. diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index ddb5be5..aa09235 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -924,15 +924,14 @@ int mutt_index_menu (void) if (op == OP_TOGGLE_READ) { char buffer[LONG_STRING]; - if (!Context->pattern - || strncmp (Context->pattern, "!~R!~D~s", 8) != 0) { + if (m_strncmp (Context->pattern, "!~R!~D~s", 8) != 0) { snprintf (buffer, sizeof (buffer), "!~R!~D~s%s", Context->pattern ? Context->pattern : ".*"); set_option (OPTHIDEREAD); } else { m_strcpy(buf, sizeof(buf), Context->pattern + 8); - if (!*buf || strncmp (buf, ".*", 2) == 0) + if (m_strncmp (buf, ".*", 2) == 0) snprintf (buf, sizeof (buf), "~A"); unset_option (OPTHIDEREAD); } diff --git a/makedoc.c b/makedoc.c index e2cfc67..004d68b 100644 --- a/makedoc.c +++ b/makedoc.c @@ -981,11 +981,11 @@ static int print_it (int special, char *str, int docstat) add_s ("\\(rq"); else if (*str == '\\') add_s ("\\\\"); - else if (!strncmp (str, "``", 2)) { + else if (!m_strncmp (str, "``", 2)) { add_s ("\\(lq"); str++; } - else if (!strncmp (str, "''", 2)) { + else if (!m_strncmp (str, "''", 2)) { add_s ("\\(rq"); str++; } @@ -1177,49 +1177,49 @@ static int handle_docline (char *l, int docstat) l = skip_ws (l); - if (!strncmp (l, ".pp", 3)) + if (!m_strncmp (l, ".pp", 3)) return print_it (SP_NEWPAR, NULL, docstat); - else if (!strncmp (l, ".ts", 3)) + else if (!m_strncmp (l, ".ts", 3)) return print_it (SP_START_TAB, NULL, docstat); - else if (!strncmp (l, ".te", 3)) + else if (!m_strncmp (l, ".te", 3)) return print_it (SP_END_TAB, NULL, docstat); - else if (!strncmp (l, ".dl", 3)) + else if (!m_strncmp (l, ".dl", 3)) return print_it (SP_START_DL, NULL, docstat); - else if (!strncmp (l, ".de", 3)) + else if (!m_strncmp (l, ".de", 3)) return print_it (SP_END_DL, NULL, docstat); - else if (!strncmp (l, ". ", 2)) + else if (!m_strncmp (l, ". ", 2)) *l = ' '; for (s = l, d = buff; *s; s++) { - if (!strncmp (s, "\\(as", 4)) { + if (!m_strncmp (s, "\\(as", 4)) { *d++ = '*'; s += 3; } - else if (!strncmp (s, "\\(rs", 4)) { + else if (!m_strncmp (s, "\\(rs", 4)) { *d++ = '\\'; s += 3; } - else if (!strncmp (s, "\\fI", 3)) { + else if (!m_strncmp (s, "\\fI", 3)) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_START_EM, NULL, docstat); s += 2; } - else if (!strncmp (s, "\\fB", 3)) { + else if (!m_strncmp (s, "\\fB", 3)) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_START_BF, NULL, docstat); s += 2; } - else if (!strncmp (s, "\\fT", 3)) { + else if (!m_strncmp (s, "\\fT", 3)) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_START_TT, NULL, docstat); s += 2; } - else if (!strncmp (s, "\\fP", 3)) { + else if (!m_strncmp (s, "\\fP", 3)) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_END_FT, NULL, docstat); s += 2; } - else if (!strncmp (s, ".dt", 3)) { + else if (!m_strncmp (s, ".dt", 3)) { if (docstat & D_DD) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_END_DD, NULL, docstat); @@ -1228,7 +1228,7 @@ static int handle_docline (char *l, int docstat) docstat = print_it (SP_DT, NULL, docstat); s += 3; } - else if (!strncmp (s, ".dd", 3)) { + else if (!m_strncmp (s, ".dd", 3)) { docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_DD, NULL, docstat); s += 3; diff --git a/muttlib.c b/muttlib.c index 65007ae..695d08c 100644 --- a/muttlib.c +++ b/muttlib.c @@ -198,7 +198,7 @@ void mutt_pretty_mailbox (char *s) /* if s is an url, only collapse path component */ if (scheme != U_UNKNOWN) { p = strchr (s, ':') + 1; - if (!strncmp (p, "//", 2)) + if (!m_strncmp (p, "//", 2)) q = strchr (p + 2, '/'); if (!q) q = strchr (p, '\0');