From: Thomas Roessler Date: Tue, 10 Nov 1998 22:14:00 +0000 (+0000) Subject: Introduce or rewrite mutt_{str*cmp,strlen} and use them all over the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09837bca1ac0750a1c702a74d8ceae06be0b7fcf;p=neomutt Introduce or rewrite mutt_{str*cmp,strlen} and use them all over the place. If there are still segmentation faults due to missing NONULLs over, they are gone now. --- diff --git a/addrbook.c b/addrbook.c index 790d836e7..e3fd75b5a 100644 --- a/addrbook.c +++ b/addrbook.c @@ -93,7 +93,7 @@ static int alias_SortAlias (const void *a, const void *b) { ALIAS *pa = *(ALIAS **) a; ALIAS *pb = *(ALIAS **) b; - int r = strcasecmp (pa->name, pb->name); + int r = mutt_strcasecmp (pa->name, pb->name); return (RSORT (r)); } @@ -107,14 +107,14 @@ static int alias_SortAddress (const void *a, const void *b) if (pa->personal) { if (pb->personal) - r = strcasecmp (pa->personal, pb->personal); + r = mutt_strcasecmp (pa->personal, pb->personal); else r = 1; } else if (pb->personal) r = -1; else - r = strcasecmp (pa->mailbox, pb->mailbox); + r = mutt_strcasecmp (pa->mailbox, pb->mailbox); return (RSORT (r)); } diff --git a/alias.c b/alias.c index 13786ffa6..bd462c596 100644 --- a/alias.c +++ b/alias.c @@ -29,7 +29,7 @@ ADDRESS *mutt_lookup_alias (const char *s) ALIAS *t = Aliases; for (; t; t = t->next) - if (!strcasecmp (s, t->name)) + if (!mutt_strcasecmp (s, t->name)) return (t->addr); return (NULL); /* no such alias */ } @@ -52,7 +52,7 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn) i = 0; for (u = *expn; u; u = u->next) { - if (strcmp (a->mailbox, u->data) == 0) /* alias already found */ + if (mutt_strcmp (a->mailbox, u->data) == 0) /* alias already found */ { dprint (1, (debugfile, "mutt_expand_aliases_r(): loop in alias found for '%s'\n", a->mailbox)); i = 1; @@ -287,7 +287,7 @@ ADDRESS *alias_reverse_lookup (ADDRESS *a) for (ap = t->addr; ap; ap = ap->next) { if (!ap->group && ap->mailbox && - strcasecmp (ap->mailbox, a->mailbox) == 0) + mutt_strcasecmp (ap->mailbox, a->mailbox) == 0) return ap; } } @@ -315,7 +315,7 @@ int mutt_alias_complete (char *s, size_t buflen) if (a->name && strstr (a->name, s) == a->name) { if (!bestname[0]) /* init */ - strfcpy (bestname, a->name, min (strlen (a->name) + 1, sizeof (bestname))); + strfcpy (bestname, a->name, min (mutt_strlen (a->name) + 1, sizeof (bestname))); else { for (i = 0 ; a->name[i] && a->name[i] == bestname[i] ; i++) @@ -334,7 +334,7 @@ int mutt_alias_complete (char *s, size_t buflen) } else { - if (strcmp (bestname, s) == 0) /* add anything to the completion? */ + if (mutt_strcmp (bestname, s) == 0) /* add anything to the completion? */ { /* build alias list and show it */ a = Aliases; @@ -369,7 +369,7 @@ int mutt_alias_complete (char *s, size_t buflen) return 0; } else /* we are adding something to the completion */ - strfcpy (s, bestname, strlen (bestname) + 1); + strfcpy (s, bestname, mutt_strlen (bestname) + 1); } return 1; @@ -380,7 +380,7 @@ static int string_is_address(const char *str, const char *u, const char *d) char buf[LONG_STRING]; snprintf(buf, sizeof(buf), "%s@%s", NONULL(u), NONULL(d)); - if (strcasecmp(str, buf) == 0) + if (mutt_strcasecmp(str, buf) == 0) return 1; return 0; @@ -395,7 +395,7 @@ int mutt_addr_is_user (ADDRESS *addr) if (!addr->mailbox) return 0; - if (strcasecmp (addr->mailbox, NONULL(Username)) == 0) + if (mutt_strcasecmp (addr->mailbox, Username) == 0) return 1; if(string_is_address(addr->mailbox, Username, Hostname)) return 1; diff --git a/attach.c b/attach.c index 029fdac53..b9145ac73 100644 --- a/attach.c +++ b/attach.c @@ -256,7 +256,7 @@ int mutt_edit_attachment (BODY *a) else if (a->type == TYPETEXT) { /* On text, default to editor */ - mutt_edit_file ((!Editor || strcmp ("builtin", Editor) == 0) ? + mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor), newfile); } else @@ -284,10 +284,10 @@ int mutt_is_autoview (char *type) while (t) { - i = strlen (t->data) - 1; + i = mutt_strlen (t->data) - 1; if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && - strncasecmp (type, t->data, i) == 0) || - strcasecmp (type, t->data) == 0) + mutt_strncasecmp (type, t->data, i) == 0) || + mutt_strcasecmp (type, t->data) == 0) return 1; t = t->next; } @@ -359,7 +359,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag) if (rfc1524_expand_filename (entry->nametemplate, fname, tempfile, sizeof (tempfile))) { - if (fp == NULL && strcmp(tempfile, a->filename)) + if (fp == NULL && mutt_strcmp(tempfile, a->filename)) { /* send case: the file is already there */ if (safe_symlink (a->filename, tempfile) == -1) @@ -859,8 +859,8 @@ int mutt_print_attachment (FILE *fp, BODY *a) return (1); } - if (!strcasecmp ("text/plain", a->subtype) || - !strcasecmp ("application/postscript", a->subtype)) + if (!mutt_strcasecmp ("text/plain", a->subtype) || + !mutt_strcasecmp ("application/postscript", a->subtype)) { return (mutt_pipe_attachment (fp, a, NONULL(PrintCmd), NULL)); } diff --git a/browser.c b/browser.c index 6eeecf2bd..d32fed4be 100644 --- a/browser.c +++ b/browser.c @@ -85,7 +85,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 = strcmp (pa->name, pb->name); + int r = mutt_strcmp (pa->name, pb->name); return ((BrowserSort & SORT_REVERSE) ? -r : r); } @@ -358,10 +358,10 @@ static int examine_directory (MUTTMENU *menu, struct browser_state *state, while ((de = readdir (dp)) != NULL) { - if (strcmp (de->d_name, ".") == 0) + if (mutt_strcmp (de->d_name, ".") == 0) continue; /* we don't need . */ - if (prefix && *prefix && strncmp (prefix, de->d_name, strlen (prefix)) != 0) + if (prefix && *prefix && mutt_strncmp (prefix, de->d_name, mutt_strlen (prefix)) != 0) continue; if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not)) continue; @@ -375,7 +375,7 @@ static int examine_directory (MUTTMENU *menu, struct browser_state *state, continue; tmp = Incoming; - while (tmp && strcmp (buffer, NONULL(tmp->path))) + while (tmp && mutt_strcmp (buffer, tmp->path)) tmp = tmp->next; add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); } @@ -472,7 +472,7 @@ void mutt_select_file (char *f, size_t flen, int buffy) if (*f) { mutt_expand_path (f, flen); - for (i = strlen (f) - 1; i > 0 && f[i] != '/' ; i--); + for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--); if (i > 0) { if (f[0] == '/') @@ -559,9 +559,9 @@ void mutt_select_file (char *f, size_t flen, int buffy) /* save the old directory */ strfcpy (OldLastDir, LastDir, sizeof (OldLastDir)); - if (strcmp (state.entry[menu->current].name, "..") == 0) + if (mutt_strcmp (state.entry[menu->current].name, "..") == 0) { - if (strcmp ("..", LastDir + strlen (LastDir) - 2) == 0) + if (mutt_strcmp ("..", LastDir + mutt_strlen (LastDir) - 2) == 0) strcat (LastDir, "/.."); else { @@ -584,7 +584,7 @@ void mutt_select_file (char *f, size_t flen, int buffy) mutt_expand_path (LastDir, sizeof (LastDir)); } else - sprintf (LastDir + strlen (LastDir), "/%s", + sprintf (LastDir + mutt_strlen (LastDir), "/%s", state.entry[menu->current].name); destroy_state (&state); @@ -636,7 +636,7 @@ void mutt_select_file (char *f, size_t flen, int buffy) strfcpy (buf, LastDir, sizeof (buf)); {/* add '/' at the end of the directory name */ - int len=strlen(LastDir); + int len=mutt_strlen(LastDir); if (sizeof (buf) > len) buf[len]='/'; } diff --git a/buffy.c b/buffy.c index 09955835b..2ee6f6be5 100644 --- a/buffy.c +++ b/buffy.c @@ -64,13 +64,13 @@ int fseek_last_message (FILE * f) while ((pos -= bytes_read) >= 0) { /* we save in the buffer at the end the first 7 chars from the last read */ - strncpy (buffer + BUFSIZ, buffer, 5+2); /* 2 == 2 * strlen(CRLF) */ + strncpy (buffer + BUFSIZ, buffer, 5+2); /* 2 == 2 * mutt_strlen(CRLF) */ fseek (f, pos, SEEK_SET); bytes_read = fread (buffer, sizeof (char), bytes_read, f); if (bytes_read == -1) return -1; for (i = bytes_read; --i >= 0;) - if (!strncmp (buffer + i, "\n\nFrom ", strlen ("\n\nFrom "))) + if (!mutt_strncmp (buffer + i, "\n\nFrom ", mutt_strlen ("\n\nFrom "))) { /* found it - go to the beginning of the From */ fseek (f, pos + i + 2, SEEK_SET); return 0; @@ -79,7 +79,7 @@ int fseek_last_message (FILE * f) } /* here we are at the beginning of the file */ - if (!strncmp ("From ", buffer, 5)) + if (!mutt_strncmp ("From ", buffer, 5)) { fseek (f, 0, 0); return (0); @@ -177,7 +177,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e /* simple check to avoid duplicates */ for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) { - if (strcmp (buf, (*tmp)->path) == 0) + if (mutt_strcmp (buf, (*tmp)->path) == 0) break; } @@ -413,7 +413,7 @@ void mutt_buffy (char *s) count = 0; while (count < 3) { - if (strcmp (s, tmp->path) == 0) + if (mutt_strcmp (s, tmp->path) == 0) count++; else if (count && tmp->new) break; diff --git a/charset.c b/charset.c index ed094bc83..013b4d71c 100644 --- a/charset.c +++ b/charset.c @@ -54,7 +54,7 @@ static void canonical_charset(char *dest, size_t dlen, const char *name) { int i; - if(!strncasecmp(name, "x-", 2)) + if(!mutt_strncasecmp(name, "x-", 2)) name = name + 2; for(i = 0; name[i] && i < dlen - 1; i++) @@ -85,7 +85,7 @@ static CHARSET *load_charset(const char *name) if(fgets(buffer, sizeof(buffer), fp) == NULL) goto bail; - if(strcmp(buffer, CHARSET_MAGIC) != 0) + if(mutt_strcmp(buffer, CHARSET_MAGIC) != 0) goto bail; chs->map = safe_malloc(sizeof(CHARSET_MAP)); @@ -212,7 +212,7 @@ CHARSET_MAP *mutt_get_translation(const char *_from, const char *_to) to = to_canon; /* quick check for the identity mapping */ - if((from == to) || ((*from == *to) && !strcmp(from, to))) + if((from == to) || ((*from == *to) && !mutt_strcmp(from, to))) return NULL; snprintf(key, sizeof(key), "%s %s", from, to); @@ -260,7 +260,7 @@ int mutt_is_utf8(const char *s) return 0; canonical_charset(buffer, sizeof(buffer), s); - return !strcmp(buffer, "utf-8"); + return !mutt_strcmp(buffer, "utf-8"); } /* macros for the various bit maps we need */ diff --git a/color.c b/color.c index 1d7ea0138..2f58296da 100644 --- a/color.c +++ b/color.c @@ -290,14 +290,14 @@ parse_color_name (const char *s, int *col, int *attr, int brite, BUFFER *err) { char *eptr; - if (strncasecmp (s, "bright", 6) == 0) + if (mutt_strncasecmp (s, "bright", 6) == 0) { *attr |= brite; s += 6; } /* allow aliases for xterm color resources */ - if (strncasecmp (s, "color", 5) == 0) + if (mutt_strncasecmp (s, "color", 5) == 0) { s += 5; *col = strtol (s, &eptr, 10); @@ -360,7 +360,7 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, return (-1); } - if (strncmp (buf->data, "index", 5) != 0) + if (mutt_strncmp (buf->data, "index", 5) != 0) { snprintf (err->data, err->dsize, _("%s: command valid only for index object"), @@ -391,7 +391,7 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, do { mutt_extract_token (buf, s, 0); - if (!strcmp ("*", buf->data)) + if (!mutt_strcmp ("*", buf->data)) { for (tmp = ColorIndexList; tmp; ) { @@ -407,7 +407,7 @@ _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, { for (last = NULL, tmp = ColorIndexList; tmp; last = tmp, tmp = tmp->next) { - if (!strcmp (buf->data, tmp->pattern)) + if (!mutt_strcmp (buf->data, tmp->pattern)) { if (!do_cache) do_cache = 1; @@ -454,12 +454,12 @@ add_pattern (COLOR_LINE **top, const char *s, int sensitive, { if (sensitive) { - if (strcmp (s, tmp->pattern) == 0) + if (mutt_strcmp (s, tmp->pattern) == 0) break; } else { - if (strcasecmp (s, tmp->pattern) == 0) + if (mutt_strcasecmp (s, tmp->pattern) == 0) break; } tmp = tmp->next; @@ -540,7 +540,7 @@ parse_object(BUFFER *buf, BUFFER *s, int *o, int *ql, BUFFER *err) } mutt_extract_token(buf, s, 0); - if(!strncmp(buf->data, "quoted", 6)) + if(!mutt_strncmp(buf->data, "quoted", 6)) { if(buf->data[6]) { @@ -614,17 +614,17 @@ parse_attr_spec(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *err mutt_extract_token (buf, s, 0); - if (strcasecmp ("bold", buf->data) == 0) + if (mutt_strcasecmp ("bold", buf->data) == 0) *attr |= A_BOLD; - else if (strcasecmp ("underline", buf->data) == 0) + else if (mutt_strcasecmp ("underline", buf->data) == 0) *attr |= A_UNDERLINE; - else if (strcasecmp ("none", buf->data) == 0) + else if (mutt_strcasecmp ("none", buf->data) == 0) *attr = A_NORMAL; - else if (strcasecmp ("reverse", buf->data) == 0) + else if (mutt_strcasecmp ("reverse", buf->data) == 0) *attr |= A_REVERSE; - else if (strcasecmp ("standout", buf->data) == 0) + else if (mutt_strcasecmp ("standout", buf->data) == 0) *attr |= A_STANDOUT; - else if (strcasecmp ("normal", buf->data) == 0) + else if (mutt_strcasecmp ("normal", buf->data) == 0) *attr = A_NORMAL; /* needs use = instead of |= to clear other bits */ else { diff --git a/commands.c b/commands.c index eb9c9949d..b4cabad92 100644 --- a/commands.c +++ b/commands.c @@ -69,7 +69,7 @@ static int is_mmnoask (const char *buf) if ((p = getenv ("MM_NOASK")) != NULL && *p) { - if (strcmp (p, "1") == 0) + if (mutt_strcmp (p, "1") == 0) return (1); strfcpy (tmp, p, sizeof (tmp)); @@ -81,19 +81,19 @@ static int is_mmnoask (const char *buf) { if (*(q+1) == '*') { - if (strncasecmp (buf, p, q-p) == 0) + if (mutt_strncasecmp (buf, p, q-p) == 0) return (1); } else { - if (strcasecmp (buf, p) == 0) + if (mutt_strcasecmp (buf, p) == 0) return (1); } } else { - lng = strlen (p); - if (buf[lng] == '/' && strncasecmp (buf, p, lng) == 0) + lng = mutt_strlen (p); + if (buf[lng] == '/' && mutt_strncasecmp (buf, p, lng) == 0) return (1); } @@ -178,7 +178,7 @@ int mutt_display_message (HEADER *cur) return (0); } - if (!Pager || strcmp (Pager, "builtin") == 0) + if (!Pager || mutt_strcmp (Pager, "builtin") == 0) builtin = 1; else { @@ -622,7 +622,7 @@ int mutt_save_message (HEADER *h, int delete, int decode, int decrypt, int *redr /* This is an undocumented feature of ELM pointed out to me by Felix von * Leitner */ - if (strcmp (buf, ".") == 0) + if (mutt_strcmp (buf, ".") == 0) strfcpy (buf, LastSaveFolder, sizeof (buf)); else strfcpy (LastSaveFolder, buf, sizeof (LastSaveFolder)); diff --git a/complete.c b/complete.c index 3cd63d412..e7bd5e1ef 100644 --- a/complete.c +++ b/complete.c @@ -48,8 +48,8 @@ int mutt_complete (char *s) if ((p = strrchr (s, '/'))) { *p++ = 0; - sprintf (exp_dirpart + strlen (exp_dirpart), "/%s", s+1); - sprintf (dirpart + strlen (dirpart), "%s/", s+1); + sprintf (exp_dirpart + mutt_strlen (exp_dirpart), "/%s", s+1); + sprintf (dirpart + mutt_strlen (dirpart), "%s/", s+1); strfcpy (filepart, p, sizeof (filepart)); } else @@ -100,11 +100,11 @@ int mutt_complete (char *s) * special case to handle when there is no filepart yet. find the first * file/directory which is not ``.'' or ``..'' */ - if ((len = strlen (filepart)) == 0) + if ((len = mutt_strlen (filepart)) == 0) { while ((de = readdir (dirp)) != NULL) { - if (strcmp (".", de->d_name) != 0 && strcmp ("..", de->d_name) != 0) + if (mutt_strcmp (".", de->d_name) != 0 && mutt_strcmp ("..", de->d_name) != 0) { strfcpy (filepart, de->d_name, sizeof (filepart)); init++; @@ -115,7 +115,7 @@ int mutt_complete (char *s) while ((de = readdir (dirp)) != NULL) { - if (strncmp (de->d_name, filepart, len) == 0) + if (mutt_strncmp (de->d_name, filepart, len) == 0) { if (init) { @@ -156,7 +156,7 @@ int mutt_complete (char *s) if (dirpart[0]) { strcpy (s, dirpart); - if (strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') + if (mutt_strcmp ("/", dirpart) != 0 && dirpart[0] != '=' && dirpart[0] != '+') strcat (s, "/"); strcat (s, filepart); } diff --git a/compose.c b/compose.c index ac31f8be7..235f1cbf9 100644 --- a/compose.c +++ b/compose.c @@ -191,8 +191,8 @@ static int pgp_send_menu (int bits, int *redraw) if(mutt_get_field (_("MIC algorithm: "), input_micalg, sizeof(input_micalg), 0) == 0) { - if(strcasecmp(input_micalg, "pgp-md5") && strcasecmp(input_micalg, "pgp-sha1") - && strcasecmp(input_micalg, "pgp-rmd160")) + if(mutt_strcasecmp(input_micalg, "pgp-md5") && mutt_strcasecmp(input_micalg, "pgp-sha1") + && mutt_strcasecmp(input_micalg, "pgp-rmd160")) { mutt_error _("Unknown MIC algorithm, valid ones are: pgp-md5, pgp-sha1, pgp-rmd160"); } @@ -446,7 +446,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ MAYBE_REDRAW (menu->redraw); break; case OP_COMPOSE_EDIT_MESSAGE: - if (Editor && (strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS)) + if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS)) { mutt_edit_file (Editor, msg->content->filename); mutt_update_encoding (msg->content); @@ -458,7 +458,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (op == OP_COMPOSE_EDIT_HEADERS || (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS))) { - mutt_edit_headers ((!Editor || strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor), + mutt_edit_headers ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor), msg->content->filename, msg, fcc, fcclen); } else @@ -789,7 +789,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ case OP_COMPOSE_EDIT_FILE: CHECK_COUNT; - mutt_edit_file ((!Editor || strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor), + mutt_edit_file ((!Editor || mutt_strcmp ("builtin", Editor) == 0) ? NONULL(Visual) : NONULL(Editor), idx[menu->current]->content->filename); mutt_update_encoding (idx[menu->current]->content); menu->redraw = REDRAW_CURRENT; diff --git a/copy.c b/copy.c index f04de4221..8b33d2076 100644 --- a/copy.c +++ b/copy.c @@ -78,7 +78,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, if (nl && buf[0] != ' ' && buf[0] != '\t') { ignore = 1; - if (!from && strncmp ("From ", buf, 5) == 0) + if (!from && mutt_strncmp ("From ", buf, 5) == 0) { if ((flags & CH_FROM) == 0) continue; @@ -88,12 +88,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, break; /* end of header */ if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) && - (strncasecmp ("Status:", buf, 7) == 0 || - strncasecmp ("X-Status:", buf, 9) == 0)) + (mutt_strncasecmp ("Status:", buf, 7) == 0 || + mutt_strncasecmp ("X-Status:", buf, 9) == 0)) continue; if ((flags & (CH_UPDATE_LEN | CH_XMIT)) && - (strncasecmp ("Content-Length:", buf, 15) == 0 || - strncasecmp ("Lines:", buf, 6) == 0)) + (mutt_strncasecmp ("Content-Length:", buf, 15) == 0 || + mutt_strncasecmp ("Lines:", buf, 6) == 0)) continue; ignore = 0; } @@ -138,7 +138,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, if (nl && buf[0] != ' ' && buf[0] != '\t') { ignore = 1; - if (!from && strncmp ("From ", buf, 5) == 0) + if (!from && mutt_strncmp ("From ", buf, 5) == 0) { if ((flags & CH_FROM) == 0) continue; @@ -152,18 +152,18 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, !mutt_matches_ignore (buf, UnIgnore)) continue; if ((flags & (CH_UPDATE | CH_XMIT | CH_NOSTATUS)) && - (strncasecmp ("Status:", buf, 7) == 0 || - strncasecmp ("X-Status:", buf, 9) == 0)) + (mutt_strncasecmp ("Status:", buf, 7) == 0 || + mutt_strncasecmp ("X-Status:", buf, 9) == 0)) continue; if ((flags & (CH_UPDATE_LEN | CH_XMIT)) && - (strncasecmp ("Content-Length:", buf, 15) == 0 || - strncasecmp ("Lines:", buf, 6) == 0)) + (mutt_strncasecmp ("Content-Length:", buf, 15) == 0 || + mutt_strncasecmp ("Lines:", buf, 6) == 0)) continue; if ((flags & CH_MIME) && - ((strncasecmp ("content-", buf, 8) == 0 && - (strncasecmp ("transfer-encoding:", buf + 8, 18) == 0 || - strncasecmp ("type:", buf + 8, 5) == 0)) || - strncasecmp ("mime-version:", buf, 13) == 0)) + ((mutt_strncasecmp ("content-", buf, 8) == 0 && + (mutt_strncasecmp ("transfer-encoding:", buf + 8, 18) == 0 || + mutt_strncasecmp ("type:", buf + 8, 5) == 0)) || + mutt_strncasecmp ("mime-version:", buf, 13) == 0)) continue; /* Find x -- the array entry where this header is to be saved */ @@ -171,7 +171,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, { for (t = HeaderOrderList, x = 0 ; (t) ; t = t->next, x++) { - if (!strncasecmp (buf, t->data, strlen (t->data))) + if (!mutt_strncasecmp (buf, t->data, mutt_strlen (t->data))) { dprint(2, (debugfile, "Reorder: %s matches %s", t->data, buf)); break; @@ -190,7 +190,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, else { safe_realloc ((void **) &headers[x], - strlen (headers[x]) + strlen (buf) + sizeof (char)); + mutt_strlen (headers[x]) + mutt_strlen (buf) + sizeof (char)); strcat (headers[x], buf); } } @@ -202,7 +202,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags, if (headers[x]) { if (flags & CH_DECODE) - rfc2047_decode (headers[x], headers[x], strlen (headers[x])); + rfc2047_decode (headers[x], headers[x], mutt_strlen (headers[x])); /* We couldn't do the prefixing when reading because RFC 2047 * decoding may have concatenated lines. @@ -546,7 +546,7 @@ static BODY *new_deleted_body () char date[SHORT_STRING]; mutt_make_date (date, sizeof (date)); - date[strlen (date) - 1] = 0; /* cut off ending newline character */ + date[mutt_strlen (date) - 1] = 0; /* cut off ending newline character */ p->attribute = safe_strdup ("access-type"); p->value = safe_strdup ("x-mutt-deleted"); diff --git a/curs_lib.c b/curs_lib.c index 817a6dd82..1787c09eb 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -87,7 +87,7 @@ event_t mutt_getch (void) int mutt_get_field (/* const */ char *field, char *buf, size_t buflen, int complete) { int ret; - int len = strlen (field); /* in case field==buffer */ + int len = mutt_strlen (field); /* in case field==buffer */ do { @@ -107,7 +107,7 @@ int mutt_get_password (char *msg, char *buf, size_t buflen) CLEARLINE (LINES-1); addstr (msg); - rc = mutt_enter_string ((unsigned char *) buf, buflen, LINES - 1, strlen (msg), M_PASS); + rc = mutt_enter_string ((unsigned char *) buf, buflen, LINES - 1, mutt_strlen (msg), M_PASS); CLEARLINE (LINES-1); return (rc); } @@ -296,7 +296,7 @@ int mutt_do_pager (const char *banner, { int rc; - if (!Pager || strcmp (Pager, "builtin") == 0) + if (!Pager || mutt_strcmp (Pager, "builtin") == 0) rc = mutt_pager (banner, tempfile, do_color, info); else { @@ -338,7 +338,7 @@ int mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, i } else { - char *pc = safe_malloc (strlen (prompt) + 3); + char *pc = safe_malloc (mutt_strlen (prompt) + 3); sprintf (pc, "%s: ", prompt); mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); @@ -419,7 +419,7 @@ int mutt_multi_choice (char *prompt, char *letters) else if (ch.ch <= '9' && ch.ch > '0') { choice = ch.ch - '0'; - if (choice <= strlen (letters)) + if (choice <= mutt_strlen (letters)) break; } } diff --git a/dotlock.c b/dotlock.c index e1f892b72..d6f6f202d 100644 --- a/dotlock.c +++ b/dotlock.c @@ -434,7 +434,7 @@ dotlock_prepare(char *bn, size_t l, const char *f) dirname = "."; } - if(strlen(basename) + 1 > l) + if(mutt_strlen(basename) + 1 > l) return -1; strfcpy(bn, basename, l); diff --git a/edit.c b/edit.c index 6cf7bd72c..b3824ff44 100644 --- a/edit.c +++ b/edit.c @@ -66,7 +66,7 @@ be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset, if (prefix) { strfcpy (tmp, NONULL(Prefix), sizeof (tmp)); - tmplen = strlen (tmp); + tmplen = mutt_strlen (tmp); p = tmp + tmplen; tmplen = sizeof (tmp) - tmplen; } @@ -75,7 +75,7 @@ be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset, while (bytes > 0) { if (fgets (p, tmplen - 1, f) == NULL) break; - bytes -= strlen (p); + bytes -= mutt_strlen (p); if (*bufmax == *buflen) safe_realloc ((void **)&buf, sizeof (char *) * (*bufmax += 25)); buf[(*buflen)++] = safe_strdup (tmp); @@ -327,7 +327,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur) if (EscChar && tmp[0] == EscChar[0] && tmp[1] != EscChar[0]) { /* remove trailing whitespace from the line */ - p = tmp + strlen (tmp) - 1; + p = tmp + mutt_strlen (tmp) - 1; while (p >= tmp && ISSPACE (*p)) *p-- = 0; @@ -359,8 +359,8 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur) if (!*p && cur) { /* include the current message */ - p = tmp + strlen (tmp) + 1; - snprintf (tmp + strlen (tmp), sizeof (tmp) - strlen (tmp), " %d", + p = tmp + mutt_strlen (tmp) + 1; + snprintf (tmp + mutt_strlen (tmp), sizeof (tmp) - mutt_strlen (tmp), " %d", cur->msgno + 1); } buf = be_include_messages (p, buf, &bufmax, &buflen, @@ -404,7 +404,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur) { buflen--; strfcpy (tmp, buf[buflen], sizeof (tmp)); - tmp[strlen (tmp)-1] = 0; + tmp[mutt_strlen (tmp)-1] = 0; FREE (&buf[buflen]); buf[buflen] = NULL; continue; @@ -443,7 +443,7 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur) break; } } - else if (strcmp (".", tmp) == 0) + else if (mutt_strcmp (".", tmp) == 0) done = 1; else { diff --git a/enter.c b/enter.c index f598a0b75..301de8bfc 100644 --- a/enter.c +++ b/enter.c @@ -88,7 +88,7 @@ int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x, if (redraw == M_REDRAW_INIT) { /* full redraw */ - lastchar = curpos = strlen ((char *) buf); + lastchar = curpos = mutt_strlen ((char *) buf); begin = lastchar - width; } if (begin < 0) @@ -321,7 +321,7 @@ int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x, { buf[curpos] = 0; for (j = curpos - 1; j >= 0 && buf[j] != ' '; j--); - if (strcmp (tempbuf, (char *) buf) == 0) + if (mutt_strcmp (tempbuf, (char *) buf) == 0) { mutt_select_file ((char *) buf + j + 1, buflen - j - 1, 0); set_option (OPTNEEDREDRAW); @@ -373,7 +373,7 @@ int mutt_enter_string (unsigned char *buf, size_t buflen, int y, int x, buf[curpos] = 0; /* see if the path has changed from the last time */ - if (strcmp (tempbuf, (char *) buf) == 0) + if (mutt_strcmp (tempbuf, (char *) buf) == 0) { mutt_select_file ((char *) buf, buflen, 0); set_option (OPTNEEDREDRAW); diff --git a/from.c b/from.c index b426e6901..c8e2d88e8 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 (strncasecmp (s, Months[i], 3) == 0) + if (mutt_strncasecmp (s, Months[i], 3) == 0) return (i); return (-1); /* error */ } @@ -44,10 +44,10 @@ static int is_day_name (const char *s) { int i; - if ((strlen(s) < 3) || !*(s + 3) || !ISSPACE (*(s+3))) + if ((mutt_strlen(s) < 3) || !*(s + 3) || !ISSPACE (*(s+3))) return 0; for (i=0; i<7; i++) - if (strncasecmp (s, Weekdays[i], 3) == 0) + if (mutt_strncasecmp (s, Weekdays[i], 3) == 0) return 1; return 0; } @@ -66,7 +66,7 @@ time_t is_from (const char *s, char *path, size_t pathlen) if (path) *path = 0; - if (strncmp ("From ", s, 5) != 0) + if (mutt_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 6d19bf94e..ff77d4ec8 100644 --- a/getdomain.c +++ b/getdomain.c @@ -29,7 +29,7 @@ int getdnsdomainname (char *s, size_t l) { p = tmp; while (ISSPACE (*p)) p++; - if (strncmp ("domain", p, 6) == 0 || strncmp ("search", p, 6) == 0) + if (mutt_strncmp ("domain", p, 6) == 0 || mutt_strncmp ("search", p, 6) == 0) { p += 6; while (ISSPACE (*p)) p++; diff --git a/gnupgparse.c b/gnupgparse.c index 810db81f5..6ec96a803 100644 --- a/gnupgparse.c +++ b/gnupgparse.c @@ -69,13 +69,13 @@ static KEYINFO *parse_pub_line( char *buf, int *is_subkey ) switch( field ) { case 1: /* record type */ - if( !strcmp(p,"pub") ) + if( !mutt_strcmp(p,"pub") ) ; - else if( !strcmp(p,"sub") ) + else if( !mutt_strcmp(p,"sub") ) *is_subkey = 1; - else if( !strcmp(p,"sec") ) + else if( !mutt_strcmp(p,"sec") ) ; - else if( !strcmp(p,"ssb") ) + else if( !mutt_strcmp(p,"ssb") ) *is_subkey = 1; else return NULL; diff --git a/handler.c b/handler.c index 7a0e2e21c..23a1de5df 100644 --- a/handler.c +++ b/handler.c @@ -319,16 +319,16 @@ void mutt_decode_uuencoded (STATE *s, BODY *b, int istext) { if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) return; - len -= strlen(tmps); - if ((!strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5])) + len -= mutt_strlen(tmps); + if ((!mutt_strncmp (tmps, "begin", 5)) && ISSPACE (tmps[5])) break; } while(len > 0) { if ((fgets(tmps, sizeof(tmps), s->fpin)) == NULL) return; - len -= strlen(tmps); - if (!strncmp (tmps, "end", 3)) + len -= mutt_strlen(tmps); + if (!mutt_strncmp (tmps, "end", 3)) break; pt = tmps; linelen = decode_byte (*pt); @@ -479,7 +479,7 @@ static void enriched_wrap (struct enriched_state *stte) if (stte->s->prefix) { state_puts (stte->s->prefix, stte->s); - stte->indent_len += strlen (stte->s->prefix); + stte->indent_len += mutt_strlen (stte->s->prefix); } if (stte->tag_level[RICH_EXCERPT]) @@ -490,12 +490,12 @@ static void enriched_wrap (struct enriched_state *stte) if (stte->s->prefix) { state_puts (stte->s->prefix, stte->s); - stte->indent_len += strlen (stte->s->prefix); + stte->indent_len += mutt_strlen (stte->s->prefix); } else { state_puts ("> ", stte->s); - stte->indent_len += strlen ("> "); + stte->indent_len += mutt_strlen ("> "); } x--; } @@ -608,7 +608,7 @@ static void enriched_puts (char *s, struct enriched_state *stte) { char *c; - if (stte->buff_len < stte->buff_used + strlen(s)) + if (stte->buff_len < stte->buff_used + mutt_strlen(s)) { stte->buff_len += LONG_STRING; safe_realloc ((void **) &stte->buffer, stte->buff_len + 1); @@ -630,7 +630,7 @@ static void enriched_set_flags (const char *tag, struct enriched_state *stte) tagptr++; for (i = 0, j = -1; EnrichedTags[i].tag_name; i++) - if (strcasecmp (EnrichedTags[i].tag_name,tagptr) == 0) + if (mutt_strcasecmp (EnrichedTags[i].tag_name,tagptr) == 0) { j = EnrichedTags[i].index; break; @@ -648,35 +648,35 @@ static void enriched_set_flags (const char *tag, struct enriched_state *stte) if ((stte->s->flags & M_DISPLAY) && j == RICH_PARAM && stte->tag_level[RICH_COLOR]) { stte->param[stte->param_len] = '\0'; - if (!strcasecmp(stte->param, "black")) + if (!mutt_strcasecmp(stte->param, "black")) { enriched_puts("\033[30m", stte); } - else if (!strcasecmp(stte->param, "red")) + else if (!mutt_strcasecmp(stte->param, "red")) { enriched_puts("\033[31m", stte); } - else if (!strcasecmp(stte->param, "green")) + else if (!mutt_strcasecmp(stte->param, "green")) { enriched_puts("\033[32m", stte); } - else if (!strcasecmp(stte->param, "yellow")) + else if (!mutt_strcasecmp(stte->param, "yellow")) { enriched_puts("\033[33m", stte); } - else if (!strcasecmp(stte->param, "blue")) + else if (!mutt_strcasecmp(stte->param, "blue")) { enriched_puts("\033[34m", stte); } - else if (!strcasecmp(stte->param, "magenta")) + else if (!mutt_strcasecmp(stte->param, "magenta")) { enriched_puts("\033[35m", stte); } - else if (!strcasecmp(stte->param, "cyan")) + else if (!mutt_strcasecmp(stte->param, "cyan")) { enriched_puts("\033[36m", stte); } - else if (!strcasecmp(stte->param, "white")) + else if (!mutt_strcasecmp(stte->param, "white")) { enriched_puts("\033[37m", stte); } @@ -718,7 +718,7 @@ void text_enriched_handler (BODY *a, STATE *s) if (s->prefix) { state_puts (s->prefix, s); - stte.indent_len += strlen (s->prefix); + stte.indent_len += mutt_strlen (s->prefix); } while (state != DONE) @@ -846,7 +846,7 @@ static void alternative_handler (BODY *a, STATE *s) else { wild = 1; - btlen = strlen (t->data); + btlen = mutt_strlen (t->data); } if (a && a->parts) @@ -856,10 +856,10 @@ static void alternative_handler (BODY *a, STATE *s) while (b) { const char *bt = TYPE(b); - if (!strncasecmp (bt, t->data, btlen) && bt[btlen] == 0) + if (!mutt_strncasecmp (bt, t->data, btlen) && bt[btlen] == 0) { /* the basetype matches */ - if (wild || !strcasecmp (t->data + btlen + 1, b->subtype)) + if (wild || !mutt_strcasecmp (t->data + btlen + 1, b->subtype)) { choice = b; } @@ -904,17 +904,17 @@ static void alternative_handler (BODY *a, STATE *s) { if (b->type == TYPETEXT) { - if (! strcasecmp ("plain", b->subtype) && type <= TXTPLAIN) + if (! mutt_strcasecmp ("plain", b->subtype) && type <= TXTPLAIN) { choice = b; type = TXTPLAIN; } - else if (! strcasecmp ("enriched", b->subtype) && type <= TXTENRICHED) + else if (! mutt_strcasecmp ("enriched", b->subtype) && type <= TXTENRICHED) { choice = b; type = TXTENRICHED; } - else if (! strcasecmp ("html", b->subtype) && type <= TXTHTML) + else if (! mutt_strcasecmp ("html", b->subtype) && type <= TXTHTML) { choice = b; type = TXTHTML; @@ -1010,8 +1010,8 @@ int mutt_can_decode (BODY *a) #ifdef _PGPPATH - if (strcasecmp (a->subtype, "signed") == 0 || - strcasecmp (a->subtype, "encrypted") == 0) + if (mutt_strcasecmp (a->subtype, "signed") == 0 || + mutt_strcasecmp (a->subtype, "encrypted") == 0) return (1); else #endif @@ -1060,7 +1060,7 @@ void multipart_handler (BODY *a, STATE *s) b->length = (long) st.st_size; b->parts = mutt_parse_multipart (s->fpin, mutt_get_parameter ("boundary", a->parameter), - (long) st.st_size, strcasecmp ("digest", a->subtype) == 0); + (long) st.st_size, mutt_strcasecmp ("digest", a->subtype) == 0); } else b = a; @@ -1263,7 +1263,7 @@ static void external_body_handler (BODY *b, STATE *s) else expire = -1; - if (!strcasecmp (access_type, "x-mutt-deleted")) + if (!mutt_strcasecmp (access_type, "x-mutt-deleted")) { if (s->flags & M_DISPLAY) { @@ -1335,25 +1335,25 @@ void mutt_body_handler (BODY *b, STATE *s) } else if (b->type == TYPETEXT) { - if (strcasecmp ("plain", b->subtype) == 0) + if (mutt_strcasecmp ("plain", b->subtype) == 0) { /* avoid copying this part twice since removing the transfer-encoding is * the only operation needed. */ plaintext = 1; } - else if (strcasecmp ("enriched", b->subtype) == 0) + else if (mutt_strcasecmp ("enriched", b->subtype) == 0) handler = text_enriched_handler; - else if (strcasecmp ("rfc822-headers", b->subtype) == 0) + else if (mutt_strcasecmp ("rfc822-headers", b->subtype) == 0) plaintext = 1; } else if (b->type == TYPEMESSAGE) { if(mutt_is_message_type(b->type, b->subtype)) handler = message_handler; - else if (!strcasecmp ("delivery-status", b->subtype)) + else if (!mutt_strcasecmp ("delivery-status", b->subtype)) plaintext = 1; - else if (!strcasecmp ("external-body", b->subtype)) + else if (!mutt_strcasecmp ("external-body", b->subtype)) handler = external_body_handler; } else if (b->type == TYPEMULTIPART) @@ -1367,31 +1367,31 @@ void mutt_body_handler (BODY *b, STATE *s) - if (strcasecmp ("alternative", b->subtype) == 0) + if (mutt_strcasecmp ("alternative", b->subtype) == 0) handler = alternative_handler; #ifdef _PGPPATH - else if (strcasecmp ("signed", b->subtype) == 0) + else if (mutt_strcasecmp ("signed", b->subtype) == 0) { p = mutt_get_parameter ("protocol", b->parameter); if (!p) mutt_error _("Error: multipart/signed has no protocol."); - else if (strcasecmp ("application/pgp-signature", p) == 0) + else if (mutt_strcasecmp ("application/pgp-signature", p) == 0) { if (s->flags & M_VERIFY) handler = pgp_signed_handler; } } - else if (strcasecmp ("encrypted", b->subtype) == 0) + else if (mutt_strcasecmp ("encrypted", b->subtype) == 0) { p = mutt_get_parameter ("protocol", b->parameter); if (!p) mutt_error _("Error: multipart/encrypted has no protocol parameter!"); - else if (strcasecmp ("application/pgp-encrypted", p) == 0) + else if (mutt_strcasecmp ("application/pgp-encrypted", p) == 0) handler = pgp_encrypted_handler; } #endif /* _PGPPATH */ diff --git a/hash.c b/hash.c index a52570d91..f7724eb1f 100644 --- a/hash.c +++ b/hash.c @@ -65,7 +65,7 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup) for (tmp = table->table[h], last = NULL; tmp; last = tmp, tmp = tmp->next) { - r = strcmp (tmp->key, key); + r = mutt_strcmp (tmp->key, key); if (r == 0) { FREE (&ptr); @@ -88,7 +88,7 @@ void *hash_find_hash (const HASH * table, int hash, const char *key) struct hash_elem *ptr = table->table[hash]; for (; ptr; ptr = ptr->next) { - if (strcmp (key, ptr->key) == 0) + if (mutt_strcmp (key, ptr->key) == 0) return (ptr->data); } return NULL; @@ -104,7 +104,7 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data /* if `data' is given, look for a matching ->data member. this is required for the case where we have multiple entries with the same key */ - if (data == ptr->data || (!data && strcmp (ptr->key, key) == 0)) + if (data == ptr->data || (!data && mutt_strcmp (ptr->key, key) == 0)) { if (last) last->next = ptr->next; diff --git a/hdrline.c b/hdrline.c index 88b27e52f..97c833bc7 100644 --- a/hdrline.c +++ b/hdrline.c @@ -40,7 +40,7 @@ int mutt_is_mail_list (ADDRESS *addr) if (addr->mailbox) { for (p = MailLists; p; p = p->next) - if (strncasecmp (addr->mailbox, p->data, strlen (p->data)) == 0) + if (mutt_strncasecmp (addr->mailbox, p->data, mutt_strlen (p->data)) == 0) return 1; } return 0; @@ -545,7 +545,7 @@ hdr_format_str (char *dest, case 'T': snprintf (fmt, sizeof (fmt), "%%%sc", prefix); snprintf (dest, destlen, fmt, - (Tochars && ((i = mutt_user_is_recipient (hdr))) < strlen (Tochars)) ? Tochars[i] : ' '); + (Tochars && ((i = mutt_user_is_recipient (hdr))) < mutt_strlen (Tochars)) ? Tochars[i] : ' '); break; case 'u': @@ -606,7 +606,7 @@ hdr_format_str (char *dest, hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), hdr->tagged ? '*' : (hdr->flagged ? '!' : - (Tochars && ((i = mutt_user_is_recipient (hdr)) < strlen (Tochars)) ? Tochars[i] : ' '))); + (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); snprintf (dest, destlen, fmt, buf2); break; diff --git a/headers.c b/headers.c index 24347841b..eb2dd434a 100644 --- a/headers.c +++ b/headers.c @@ -159,9 +159,9 @@ void mutt_edit_headers (const char *editor, * not, remove the references: field later so that we can generate a new * message based upon this one. */ - if (strncasecmp ("in-reply-to:", cur->data, 12) == 0) + if (mutt_strncasecmp ("in-reply-to:", cur->data, 12) == 0) in_reply_to = 1; - else if (fcc && strncasecmp ("fcc:", cur->data, 4) == 0) + else if (fcc && mutt_strncasecmp ("fcc:", cur->data, 4) == 0) { p = cur->data + 4; SKIPWS (p); @@ -172,7 +172,7 @@ void mutt_edit_headers (const char *editor, } keep = 0; } - else if (strncasecmp ("attach:", cur->data, 7) == 0) + else if (mutt_strncasecmp ("attach:", cur->data, 7) == 0) { BODY *body; BODY *parts; @@ -208,7 +208,7 @@ void mutt_edit_headers (const char *editor, #ifdef _PGPPATH - else if (strncasecmp ("pgp:", cur->data, 4) == 0) + else if (mutt_strncasecmp ("pgp:", cur->data, 4) == 0) { msg->pgp = mutt_parse_pgp_hdr (cur->data + 4, 0); keep = 0; diff --git a/help.c b/help.c index 4defe764e..bc9c4dc93 100644 --- a/help.c +++ b/help.c @@ -78,7 +78,7 @@ mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items) buflen -= 2; } mutt_make_help (pbuf, buflen, _(items[i].name), menu, items[i].value); - len = strlen (pbuf); + len = mutt_strlen (pbuf); pbuf += len; buflen -= len; } @@ -176,12 +176,12 @@ static void format_line (FILE *f, int ismacro, { col_a = 12 + (COLS > 83 ? (COLS - 80) >> 2 : 0); col_b = 19 + (COLS > 43 ? (COLS - 16) >> 2 : 0); - col = pad (f, strlen(t1), col_a); + col = pad (f, mutt_strlen(t1), col_a); } if (ismacro > 0) { - if (!strcmp (Pager, "builtin")) + if (!mutt_strcmp (Pager, "builtin")) fputs ("_\010", f); fputs ("M ", f); col += 2; @@ -189,7 +189,7 @@ static void format_line (FILE *f, int ismacro, if (!split) { col += print_macro (f, col_b - col - 4, &t2); - if (strlen (t2) > col_b - col) + if (mutt_strlen (t2) > col_b - col) t2 = "..."; } } @@ -215,7 +215,7 @@ static void format_line (FILE *f, int ismacro, { SKIPWS(t3); - if ((n = strlen (t3)) > COLS - col) + if ((n = mutt_strlen (t3)) > COLS - col) { n = COLS - col; for (col_a = n; col_a > 0 && t3[col_a] != ' '; col_a--) ; @@ -228,7 +228,7 @@ static void format_line (FILE *f, int ismacro, if (*t3) { - if (strcmp (Pager, "builtin")) + if (mutt_strcmp (Pager, "builtin")) { fputc ('\n', f); n = 0; diff --git a/history.c b/history.c index a01cf48c5..bc747db9b 100644 --- a/history.c +++ b/history.c @@ -75,7 +75,7 @@ void mutt_history_add (history_class_t hclass, const char *s) { prev = h->last - 1; if (prev < 0) prev = HistSize - 1; - if (!h->hist[prev] || strcmp (h->hist[prev], s) != 0) + if (!h->hist[prev] || mutt_strcmp (h->hist[prev], s) != 0) { safe_free ((void **) &h->hist[h->last]); h->hist[h->last++] = safe_strdup (s); diff --git a/hook.c b/hook.c index 4df4da962..a0223451f 100644 --- a/hook.c +++ b/hook.c @@ -114,14 +114,14 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) { if (ptr->type == data && ptr->rx.not == not && - !strcmp (pattern.data, ptr->rx.pattern)) + !mutt_strcmp (pattern.data, ptr->rx.pattern)) { if (data & (M_FOLDERHOOK | M_SENDHOOK)) { /* folder-hook and send-hook allow multiple commands with the same pattern, so if we've already seen this pattern/command pair, just ignore it instead of creating a duplicate */ - if (!strcmp (ptr->command, command.data)) + if (!mutt_strcmp (ptr->command, command.data)) { FREE (&command.data); FREE (&pattern.data); diff --git a/imap.c b/imap.c index f266fe722..f1a17e540 100644 --- a/imap.c +++ b/imap.c @@ -170,7 +170,7 @@ static int imap_parse_fetch (IMAP_HEADER_INFO *h, char *s) switch (state) { case 0: - if (strncasecmp ("FLAGS", s, 5) == 0) + if (mutt_strncasecmp ("FLAGS", s, 5) == 0) { s += 5; SKIPWS (s); @@ -186,7 +186,7 @@ static int imap_parse_fetch (IMAP_HEADER_INFO *h, char *s) s++; state = 1; } - else if (strncasecmp ("INTERNALDATE", s, 12) == 0) + else if (mutt_strncasecmp ("INTERNALDATE", s, 12) == 0) { s += 12; SKIPWS (s); @@ -205,7 +205,7 @@ static int imap_parse_fetch (IMAP_HEADER_INFO *h, char *s) *ptmp = 0; h->received = imap_parse_date (tmp); } - else if (strncasecmp ("RFC822.SIZE", s, 11) == 0) + else if (mutt_strncasecmp ("RFC822.SIZE", s, 11) == 0) { s += 11; SKIPWS (s); @@ -230,22 +230,22 @@ static int imap_parse_fetch (IMAP_HEADER_INFO *h, char *s) s++; state = 0; } - else if (strncasecmp ("\\deleted", s, 8) == 0) + else if (mutt_strncasecmp ("\\deleted", s, 8) == 0) { s += 8; h->deleted = 1; } - else if (strncasecmp ("\\flagged", s, 8) == 0) + else if (mutt_strncasecmp ("\\flagged", s, 8) == 0) { s += 8; h->flagged = 1; } - else if (strncasecmp ("\\answered", s, 9) == 0) + else if (mutt_strncasecmp ("\\answered", s, 9) == 0) { s += 9; h->replied = 1; } - else if (strncasecmp ("\\seen", s, 5) == 0) + else if (mutt_strncasecmp ("\\seen", s, 5) == 0) { s += 5; h->read = 1; @@ -318,7 +318,7 @@ static int imap_code (const char *s) { s += SEQLEN; SKIPWS (s); - return (strncasecmp ("OK", s, 2) == 0); + return (mutt_strncasecmp ("OK", s, 2) == 0); } static char *imap_next_word (char *s) @@ -341,7 +341,7 @@ static int imap_handle_untagged (CONTEXT *ctx, char *s) pn = s; s = imap_next_word (s); - if (strncasecmp ("EXISTS", s, 6) == 0) + if (mutt_strncasecmp ("EXISTS", s, 6) == 0) { /* new mail arrived */ count = atoi (pn); @@ -364,12 +364,12 @@ static int imap_handle_untagged (CONTEXT *ctx, char *s) CTX_DATA->newMailCount = count; } } - else if (strncasecmp ("EXPUNGE", s, 7) == 0) + else if (mutt_strncasecmp ("EXPUNGE", s, 7) == 0) { CTX_DATA->status = IMAP_EXPUNGE; } } - else if (strncasecmp ("BYE", s, 3) == 0) + else if (mutt_strncasecmp ("BYE", s, 3) == 0) { /* server shut down our connection */ s += 3; @@ -455,7 +455,7 @@ static int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend) h->number = atoi (pc); dprint (1, (debugfile, "fetching message %d\n", h->number)); pc = imap_next_word (pc); - if (strncasecmp ("FETCH", pc, 5) == 0) + if (mutt_strncasecmp ("FETCH", pc, 5) == 0) { if (!(pc = strchr (pc, '('))) { @@ -496,7 +496,7 @@ static int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend) return (-1); } } - while ((msgno + 1) >= fetchlast && strncmp (seq, buf, SEQLEN) != 0); + while ((msgno + 1) >= fetchlast && mutt_strncmp (seq, buf, SEQLEN) != 0); h->content_length = -bytes; if (imap_parse_fetch (h, fetchbuf) == -1) @@ -644,14 +644,14 @@ static int imap_reopen_mailbox (CONTEXT *ctx, int *index_hint) *pc++ = 0; n = atoi (pn); SKIPWS (pc); - if (strncasecmp ("EXISTS", pc, 6) == 0) + if (mutt_strncasecmp ("EXISTS", pc, 6) == 0) count = n; } else if (imap_handle_untagged (ctx, buf) != 0) return (-1); } } - while (strncmp (seq, buf, strlen (seq)) != 0); + while (mutt_strncmp (seq, buf, mutt_strlen (seq)) != 0); ctx->hdrmax = count; ctx->hdrs = safe_malloc (count * sizeof (HEADER *)); @@ -761,7 +761,7 @@ static int imap_exec (char *buf, size_t buflen, if (buf[0] == '*' && imap_handle_untagged (ctx, buf) != 0) return (-1); } - while (strncmp (buf, seq, SEQLEN) != 0); + while (mutt_strncmp (buf, seq, SEQLEN) != 0); if (!ctx->closing && (CTX_DATA->status == IMAP_NEW_MAIL || CTX_DATA->status == IMAP_EXPUNGE)) @@ -877,7 +877,7 @@ static int imap_open_connection (CONTEXT *ctx, CONNECTION *conn) return (-1); } - if (strncmp ("* OK", buf, 4) == 0) + if (mutt_strncmp ("* OK", buf, 4) == 0) { int r = 1; @@ -941,7 +941,7 @@ static int imap_open_connection (CONTEXT *ctx, CONNECTION *conn) } } } - else if (strncmp ("* PREAUTH", buf, 9) != 0) + else if (mutt_strncmp ("* PREAUTH", buf, 9) != 0) { imap_error ("imap_open_connection()", buf); close (conn->fd); @@ -1006,14 +1006,14 @@ int imap_open_mailbox (CONTEXT *ctx) *pc++ = 0; n = atoi (pn); SKIPWS (pc); - if (strncasecmp ("EXISTS", pc, 6) == 0) + if (mutt_strncasecmp ("EXISTS", pc, 6) == 0) count = n; } else if (imap_handle_untagged (ctx, buf) != 0) return (-1); } } - while (strncmp (seq, buf, strlen (seq)) != 0); + while (mutt_strncmp (seq, buf, mutt_strlen (seq)) != 0); ctx->hdrmax = count; ctx->hdrs = safe_malloc (count * sizeof (HEADER *)); @@ -1157,7 +1157,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) pc = buf; pc = imap_next_word (pc); pc = imap_next_word (pc); - if (strncasecmp ("FETCH", pc, 5) == 0) + if (mutt_strncasecmp ("FETCH", pc, 5) == 0) { if (!(pc = strchr (buf, '{'))) { @@ -1196,7 +1196,7 @@ int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno) return (-1); } } - while (strncmp (buf, seq, SEQLEN) != 0) + while (mutt_strncmp (buf, seq, SEQLEN) != 0) ; mutt_clear_error(); @@ -1260,7 +1260,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) fclose (fp); } } - while ((strncmp (buf, seq, SEQLEN) != 0) && (buf[0] != '+')); + while ((mutt_strncmp (buf, seq, SEQLEN) != 0) && (buf[0] != '+')); if (buf[0] != '+') { @@ -1305,7 +1305,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) if (buf[0] == '*' && imap_handle_untagged (ctx, buf) != 0) return (-1); } - while (strncmp (buf, seq, SEQLEN) != 0); + while (mutt_strncmp (buf, seq, SEQLEN) != 0); if (!imap_code (buf)) { @@ -1341,7 +1341,7 @@ int imap_close_connection (CONTEXT *ctx) if (mutt_socket_read_line_d (buf, sizeof (buf), CTX_DATA->conn) < 0) break; } - while (strncmp (seq, buf, SEQLEN) != 0); + while (mutt_strncmp (seq, buf, SEQLEN) != 0); mutt_clear_error (); } close (CTX_DATA->conn->fd); @@ -1522,10 +1522,10 @@ int imap_buffy_check (char *path) if (buf[0] == '*') { s = imap_next_word (buf); - if (strncasecmp ("STATUS", s, 6) == 0) + if (mutt_strncasecmp ("STATUS", s, 6) == 0) { s = imap_next_word (s); - if (strncmp (mbox, s, strlen (mbox)) == 0) + if (mutt_strncmp (mbox, s, mutt_strlen (mbox)) == 0) { s = imap_next_word (s); s = imap_next_word (s); @@ -1547,7 +1547,7 @@ int imap_buffy_check (char *path) } } } - while ((strncmp (buf, seq, SEQLEN) != 0)); + while ((mutt_strncmp (buf, seq, SEQLEN) != 0)); conn->uses--; diff --git a/init.c b/init.c index 601fd7585..1563b3269 100644 --- a/init.c +++ b/init.c @@ -83,7 +83,7 @@ int mutt_option_index (char *s) int i; for (i = 0; MuttVars[i].option; i++) - if (strcmp (s, MuttVars[i].option) == 0) + if (mutt_strcmp (s, MuttVars[i].option) == 0) return (MuttVars[i].type == DT_SYN ? mutt_option_index ((char *) MuttVars[i].data) : i); return (-1); } @@ -104,7 +104,7 @@ static void add_char (BUFFER *buf, char ch) static void add_str (BUFFER *buf, const char *s) { - size_t slen = strlen (s); + size_t slen = mutt_strlen (s); size_t offset; if (buf->dptr + slen > buf->data + buf->dsize) @@ -241,8 +241,8 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) plus whatever else was left on the original line */ if (expn.data) { - expnlen = strlen (expn.data); - tok->dsize = expnlen + strlen (tok->dptr) + 1; + expnlen = mutt_strlen (expn.data); + tok->dsize = expnlen + mutt_strlen (tok->dptr) + 1; ptr = safe_malloc (tok->dsize); memcpy (ptr, expn.data, expnlen); strcpy (ptr + expnlen, tok->dptr); @@ -300,7 +300,7 @@ void mutt_add_to_list (LIST **list, BUFFER *inp) /* check to make sure the item is not already on this list */ for (last = *list; last; last = last->next) { - if (strcasecmp (buf.data, last->data) == 0) + if (mutt_strcasecmp (buf.data, last->data) == 0) { /* already on the list, so just ignore it */ last = NULL; @@ -338,7 +338,7 @@ static void remove_from_list (LIST **l, BUFFER *inp) { mutt_extract_token (&buf, inp, 0); - if (strcmp ("*", buf.data) == 0) + if (mutt_strcmp ("*", buf.data) == 0) mutt_free_list (l); /* ``unCMD *'' means delete all current entries */ else { @@ -346,7 +346,7 @@ static void remove_from_list (LIST **l, BUFFER *inp) last = NULL; while (p) { - if (strcasecmp (buf.data, p->data) == 0) + if (mutt_strcasecmp (buf.data, p->data) == 0) { safe_free ((void **) &p->data); if (last) @@ -404,7 +404,7 @@ static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er tmp = Aliases; for (tmp = Aliases; tmp; tmp = tmp->next) { - if (strcasecmp (buf->data, tmp->name) == 0) + if (mutt_strcasecmp (buf->data, tmp->name) == 0) { if (last) last->next = tmp->next; @@ -439,7 +439,7 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) /* check to see if an alias with this name already exists */ for (; tmp; tmp = tmp->next) { - if (!strncasecmp (tmp->name, s->dptr, len) && *(tmp->name + len) == 0) + if (!mutt_strncasecmp (tmp->name, s->dptr, len) && *(tmp->name + len) == 0) break; last = tmp; } @@ -479,20 +479,20 @@ parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) do { mutt_extract_token (buf, s, 0); - if (strcmp ("*", buf->data) == 0) + if (mutt_strcmp ("*", buf->data) == 0) mutt_free_list (&UserHeader); else { tmp = UserHeader; last = NULL; - l = strlen (buf->data); + l = mutt_strlen (buf->data); if (buf->data[l - 1] == ':') l--; while (tmp) { - if (strncasecmp (buf->data, tmp->data, l) == 0 && tmp->data[l] == ':') + if (mutt_strncasecmp (buf->data, tmp->data, l) == 0 && tmp->data[l] == ':') { ptr = tmp; if (last) @@ -541,7 +541,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err for (tmp = UserHeader; ; tmp = tmp->next) { /* see if there is already a field by this name */ - if (strncasecmp (buf->data, tmp->data, keylen) == 0) + if (mutt_strncasecmp (buf->data, tmp->data, keylen) == 0) { /* replace the old value */ safe_free ((void **) &tmp->data); @@ -570,13 +570,13 @@ parse_sort (short *val, const char *s, const struct mapping_t *map, BUFFER *err) { int i, flags = 0; - if (strncmp ("reverse-", s, 8) == 0) + if (mutt_strncmp ("reverse-", s, 8) == 0) { s += 8; flags = SORT_REVERSE; } - if (strncmp ("last-", s, 5) == 0) + if (mutt_strncmp ("last-", s, 5) == 0) { s += 5; flags |= SORT_LAST; @@ -646,11 +646,11 @@ static void mutt_restore_default (struct option_t *p) pp->rx = safe_calloc (1, sizeof (regex_t)); pp->pattern = safe_strdup ((char *) p->init); - if (strcmp (p->option, "alternates") == 0) + if (mutt_strcmp (p->option, "alternates") == 0) flags |= REG_ICASE; - else if (strcmp (p->option, "mask") != 0) + else if (mutt_strcmp (p->option, "mask") != 0) flags |= mutt_which_case ((const char *) p->init); - if (strcmp (p->option, "mask") == 0 && *s == '!') + if (mutt_strcmp (p->option, "mask") == 0 && *s == '!') { s++; pp->not = 1; @@ -695,12 +695,12 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) query = 1; s->dptr++; } - else if (strncmp ("no", s->dptr, 2) == 0) + else if (mutt_strncmp ("no", s->dptr, 2) == 0) { s->dptr += 2; unset = !unset; } - else if (strncmp ("inv", s->dptr, 3) == 0) + else if (mutt_strncmp ("inv", s->dptr, 3) == 0) { s->dptr += 3; inv = !inv; @@ -715,7 +715,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) mutt_extract_token (tmp, s, M_TOKEN_EQUAL); if ((idx = mutt_option_index (tmp->data)) == -1 && - !(reset && !strcmp ("all", tmp->data))) + !(reset && !mutt_strcmp ("all", tmp->data))) { snprintf (err->data, err->dsize, _("%s: unknown variable"), tmp->data); return (-1); @@ -736,7 +736,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) return (-1); } - if (!strcmp ("all", tmp->data)) + if (!mutt_strcmp ("all", tmp->data)) { for (idx = 0; MuttVars[idx].option; idx++) mutt_restore_default (&MuttVars[idx]); @@ -808,8 +808,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) break; } - if (option(OPTATTACHMSG) && (!strcmp(MuttVars[idx].option, "alternates") - || !strcmp(MuttVars[idx].option, "reply_regexp"))) + if (option(OPTATTACHMSG) && (!mutt_strcmp(MuttVars[idx].option, "alternates") + || !mutt_strcmp(MuttVars[idx].option, "reply_regexp"))) { snprintf (err->data, err->dsize, "Operation not permitted when in attach-message mode."); r = -1; @@ -821,19 +821,19 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) /* copy the value of the string */ mutt_extract_token (tmp, s, 0); - if (!ptr->pattern || strcmp (ptr->pattern, tmp->data) != 0) + if (!ptr->pattern || mutt_strcmp (ptr->pattern, tmp->data) != 0) { int not = 0; /* $alternates is case-insensitive, $mask is case-sensitive */ - if (strcmp (MuttVars[idx].option, "alternates") == 0) + if (mutt_strcmp (MuttVars[idx].option, "alternates") == 0) flags |= REG_ICASE; - else if (strcmp (MuttVars[idx].option, "mask") != 0) + else if (mutt_strcmp (MuttVars[idx].option, "mask") != 0) flags |= mutt_which_case (tmp->data); p = tmp->data; - if (strcmp (MuttVars[idx].option, "mask") == 0) + if (mutt_strcmp (MuttVars[idx].option, "mask") == 0) { if (*p == '!') { @@ -866,7 +866,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) /* $reply_regexp and $alterantes require special treatment */ if (Context && Context->msgcount && - strcmp (MuttVars[idx].option, "reply_regexp") == 0) + mutt_strcmp (MuttVars[idx].option, "reply_regexp") == 0) { regmatch_t pmatch[1]; int i; @@ -886,7 +886,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) } if(Context && Context->msgcount && - strcmp(MuttVars[idx].option, "alternates") == 0) + mutt_strcmp(MuttVars[idx].option, "alternates") == 0) { int i; @@ -952,13 +952,13 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) *ptr = (short) atoi (tmp->data); /* these ones need a sanity check */ - if (strcmp (MuttVars[idx].option, "history") == 0) + if (mutt_strcmp (MuttVars[idx].option, "history") == 0) { if (*ptr < 0) *ptr = 0; mutt_init_history (); } - else if (strcmp (MuttVars[idx].option, "pager_index_lines") == 0) + else if (mutt_strcmp (MuttVars[idx].option, "pager_index_lines") == 0) { if (*ptr < 0) *ptr = 0; @@ -979,13 +979,13 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) { s->dptr++; mutt_extract_token (tmp, s, 0); - if (strcasecmp ("yes", tmp->data) == 0) + if (mutt_strcasecmp ("yes", tmp->data) == 0) set_quadoption (MuttVars[idx].data, M_YES); - else if (strcasecmp ("no", tmp->data) == 0) + else if (mutt_strcasecmp ("no", tmp->data) == 0) set_quadoption (MuttVars[idx].data, M_NO); - else if (strcasecmp ("ask-yes", tmp->data) == 0) + else if (mutt_strcasecmp ("ask-yes", tmp->data) == 0) set_quadoption (MuttVars[idx].data, M_ASKYES); - else if (strcasecmp ("ask-no", tmp->data) == 0) + else if (mutt_strcasecmp ("ask-no", tmp->data) == 0) set_quadoption (MuttVars[idx].data, M_ASKNO); else { @@ -1139,7 +1139,7 @@ int mutt_parse_rc_line (/* const */ char *line, BUFFER *token, BUFFER *err) memset (&expn, 0, sizeof (expn)); expn.data = expn.dptr = line; - expn.dsize = strlen (line); + expn.dsize = mutt_strlen (line); *err->data = 0; @@ -1156,7 +1156,7 @@ int mutt_parse_rc_line (/* const */ char *line, BUFFER *token, BUFFER *err) mutt_extract_token (token, &expn, 0); for (i = 0; Commands[i].name; i++) { - if (!strcmp (NONULL (token->data), Commands[i].name)) + if (!mutt_strcmp (token->data, Commands[i].name)) { if (Commands[i].func (token, &expn, Commands[i].data, err) != 0) goto finish; @@ -1259,22 +1259,22 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) /* return the completed command */ strncpy (buffer, Completed, len - spaces); } - else if (!strncmp (buffer, "set", 3) - || !strncmp (buffer, "unset", 5) - || !strncmp (buffer, "reset", 5) - || !strncmp (buffer, "toggle", 6)) + else if (!mutt_strncmp (buffer, "set", 3) + || !mutt_strncmp (buffer, "unset", 5) + || !mutt_strncmp (buffer, "reset", 5) + || !mutt_strncmp (buffer, "toggle", 6)) { /* complete variables */ char *prefixes[] = { "no", "inv", "?", "&", 0 }; pt++; /* loop through all the possible prefixes (no, inv, ...) */ - if (!strncmp (buffer, "set", 3)) + if (!mutt_strncmp (buffer, "set", 3)) { for (num = 0; prefixes[num]; num++) { - if (!strncmp (pt, prefixes[num], strlen (prefixes[num]))) + if (!mutt_strncmp (pt, prefixes[num], mutt_strlen (prefixes[num]))) { - pt += strlen (prefixes[num]); + pt += mutt_strlen (prefixes[num]); break; } } @@ -1311,7 +1311,7 @@ int mutt_command_complete (char *buffer, size_t len, int pos, int numtabs) strncpy (pt, Completed, buffer + len - pt - spaces); } - else if (!strncmp (buffer, "exec", 4)) + else if (!mutt_strncmp (buffer, "exec", 4)) { struct binding_t *menu = km_get_table (CurrentMenu); @@ -1381,12 +1381,12 @@ int mutt_var_value_complete (char *buffer, size_t len, int pos) if (*pt == '=') /* abort if no var before the '=' */ return 0; - if (strncmp (buffer, "set", 3) == 0) + if (mutt_strncmp (buffer, "set", 3) == 0) { int idx; strfcpy (var, pt, sizeof (var)); /* ignore the trailing '=' when comparing */ - var[strlen (var) - 1] = 0; + var[mutt_strlen (var) - 1] = 0; if ((idx = mutt_option_index (var)) == -1) return 0; /* no such variable. */ else @@ -1451,7 +1451,7 @@ int mutt_getvaluebyname (const char *name, const struct mapping_t *map) int i; for (i = 0; map[i].name; i++) - if (strcasecmp (map[i].name, name) == 0) + if (mutt_strcasecmp (map[i].name, name) == 0) return (map[i].value); return (-1); } @@ -1576,7 +1576,7 @@ void mutt_init (int skip_sys_rc, LIST *commands) #endif /* DOMAIN */ if (*DOMAIN != '@') { - Fqdn = safe_malloc (strlen (DOMAIN) + strlen (NONULL(Hostname)) + 2); + Fqdn = safe_malloc (mutt_strlen (DOMAIN) + mutt_strlen (Hostname) + 2); sprintf (Fqdn, "%s.%s", NONULL(Hostname), DOMAIN); } else @@ -1666,7 +1666,7 @@ void mutt_init (int skip_sys_rc, LIST *commands) memset (&buf, 0, sizeof (buf)); buf.data = buf.dptr = buffer; - buf.dsize = strlen (buffer); + buf.dsize = mutt_strlen (buffer); memset (&token, 0, sizeof (token)); parse_my_hdr (&token, &buf, 0, &err); diff --git a/keymap.c b/keymap.c index 91bd2a69f..6bc157014 100644 --- a/keymap.c +++ b/keymap.c @@ -231,8 +231,8 @@ static int get_op (struct binding_t *bindings, const char *start, size_t len) for (i = 0; bindings[i].name; i++) { - if (!strncasecmp (start, bindings[i].name, len) && - strlen (bindings[i].name) == len) + if (!mutt_strncasecmp (start, bindings[i].name, len) && + mutt_strlen (bindings[i].name) == len) return bindings[i].op; } @@ -254,7 +254,7 @@ static char *get_func (struct binding_t *bindings, int op) static void push_string (char *s) { - char *pp, *p = s + strlen (s) - 1; + char *pp, *p = s + mutt_strlen (s) - 1; size_t l; int i, op = OP_NULL; @@ -271,7 +271,7 @@ static void push_string (char *s) l = p - pp + 1; for (i = 0; KeyNames[i].name; i++) { - if (!strncasecmp (pp, KeyNames[i].name, l)) + if (!mutt_strncasecmp (pp, KeyNames[i].name, l)) break; } if (KeyNames[i].name) @@ -495,7 +495,7 @@ int km_expand_key (char *s, size_t len, struct keymap_t *map) FOREVER { strfcpy (s, km_keyname (map->keys[p]), len); - len -= (l = strlen (s)); + len -= (l = mutt_strlen (s)); if (++p >= map->len || !len) return (1); @@ -690,7 +690,7 @@ try_bind (char *key, int menu, char *func, struct binding_t *bindings) int i; for (i = 0; bindings[i].name; i++) - if (strcmp (func, bindings[i].name) == 0) + if (mutt_strcmp (func, bindings[i].name) == 0) { km_bindkey (key, menu, bindings[i].op); return (0); @@ -751,7 +751,7 @@ int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) strfcpy (err->data, _("bind: too many arguments"), err->dsize); r = -1; } - else if (strcasecmp ("noop", buf->data) == 0) + else if (mutt_strcasecmp ("noop", buf->data) == 0) km_bindkey (key, menu, OP_NULL); /* the `unbind' command */ else { @@ -840,9 +840,9 @@ int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) && CurrentMenu != MENU_PAGER) bindings = OpGeneric; - ops[nops] = get_op (bindings, command, strlen(command)); + ops[nops] = get_op (bindings, command, mutt_strlen(command)); if (ops[nops] == OP_NULL && CurrentMenu != MENU_PAGER) - ops[nops] = get_op (OpGeneric, command, strlen(command)); + ops[nops] = get_op (OpGeneric, command, mutt_strlen(command)); if (ops[nops] == OP_NULL) { diff --git a/lib.c b/lib.c index dddb45acd..da97222c9 100644 --- a/lib.c +++ b/lib.c @@ -164,7 +164,7 @@ int mutt_matches_ignore (const char *s, LIST *t) { for (; t; t = t->next) { - if (!strncasecmp (s, t->data, strlen (t->data)) || *t->data == '*') + if (!mutt_strncasecmp (s, t->data, mutt_strlen (t->data)) || *t->data == '*') return 1; } return 0; @@ -343,7 +343,7 @@ char *safe_strdup (const char *s) size_t l; if (!s || !*s) return 0; - l = strlen (s) + 1; + l = mutt_strlen (s) + 1; p = (char *)safe_malloc (l); memcpy (p, s, l); return (p); @@ -379,7 +379,7 @@ int mutt_copy_bytes (FILE *in, FILE *out, size_t size) char *mutt_get_parameter (const char *s, PARAMETER *p) { for (; p; p = p->next) - if (strcasecmp (s, p->attribute) == 0) + if (mutt_strcasecmp (s, p->attribute) == 0) return (p->value); return NULL; @@ -392,9 +392,9 @@ int mutt_needs_mailcap (BODY *m) { case TYPETEXT: - if (!strcasecmp ("plain", m->subtype) || - !strcasecmp ("rfc822-headers", m->subtype) || - !strcasecmp ("enriched", m->subtype)) + if (!mutt_strcasecmp ("plain", m->subtype) || + !mutt_strcasecmp ("rfc822-headers", m->subtype) || + !mutt_strcasecmp ("enriched", m->subtype)) return 0; break; @@ -424,7 +424,7 @@ int mutt_is_text_type (int t, char *s) if (t == TYPEMESSAGE) { - if (!strcasecmp ("delivery-status", s)) + if (!mutt_strcasecmp ("delivery-status", s)) return 1; } @@ -433,7 +433,7 @@ int mutt_is_text_type (int t, char *s) #ifdef _PGPPATH if (t == TYPEAPPLICATION) { - if (!strcasecmp ("pgp-keys", s)) + if (!mutt_strcasecmp ("pgp-keys", s)) return 1; } #endif /* _PGPPATH */ @@ -492,20 +492,6 @@ char *mutt_strlower (char *s) return (s); } -/* strcmp() allowing NULL pointers */ -int mutt_strcmp (const char *s1, const char *s2) -{ - if (s1 != NULL) - { - if (s2 != NULL) - return strcmp (s1, s2); - else - return (1); - } - else - return ((s2 == NULL) ? 0 : -1); -} - void mutt_free_alias (ALIAS **p) { ALIAS *t; @@ -544,12 +530,12 @@ void mutt_pretty_mailbox (char *s) } *q = 0; - if (strncmp (s, NONULL (Maildir), (len = strlen (NONULL (Maildir)))) == 0 && s[len] == '/') + if (mutt_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 && s[len] == '/') { *s++ = '='; strcpy (s, s + len); } - else if (strncmp (s, NONULL(Homedir), (len = strlen (NONULL(Homedir)))) == 0 && + else if (mutt_strncmp (s, Homedir, (len = mutt_strlen (Homedir))) == 0 && s[len] == '/') { *s++ = '~'; @@ -609,7 +595,7 @@ void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, const char *s size_t slen; int found = 0; - slen = strlen (src); + slen = mutt_strlen (src); while ((p = strchr (p, '%')) != NULL) { @@ -778,7 +764,7 @@ void mutt_remove_trailing_ws (char *s) { char *p; - for (p = s + strlen (s) - 1 ; p >= s && ISSPACE (*p) ; p--) + for (p = s + mutt_strlen (s) - 1 ; p >= s && ISSPACE (*p) ; p--) *p = 0; } @@ -1011,7 +997,7 @@ void mutt_FormatString (char *dest, /* output buffer */ { count -= wlen; /* how many chars left on this line */ mutt_FormatString (buf, sizeof (buf), src, callback, data, flags); - len = strlen (buf); + len = mutt_strlen (buf); if (count > len) { count -= len; /* how many chars to pad */ @@ -1046,7 +1032,7 @@ void mutt_FormatString (char *dest, /* output buffer */ /* use callback function to handle this case */ src = callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring, data, flags); - if ((len = strlen (buf)) + wlen > destlen) + if ((len = mutt_strlen (buf)) + wlen > destlen) len = (destlen - wlen > 0) ? (destlen - wlen) : 0; memcpy (wptr, buf, len); wptr += len; @@ -1107,7 +1093,7 @@ void mutt_FormatString (char *dest, /* output buffer */ FILE *mutt_open_read (const char *path, pid_t *thepid) { FILE *f; - int len = strlen (path); + int len = mutt_strlen (path); if (path[len - 1] == '|') { @@ -1237,3 +1223,30 @@ void state_prefix_putc(char c, STATE *s) if(c == '\n') state_set_prefix(s); } + +/* NULL-pointer aware string comparison functions */ + +int mutt_strcmp(const char *a, const char *b) +{ + return strcmp(NONULL(a), NONULL(b)); +} + +int mutt_strcasecmp(const char *a, const char *b) +{ + return strcasecmp(NONULL(a), NONULL(b)); +} + +int mutt_strncmp(const char *a, const char *b, size_t l) +{ + return strncmp(NONULL(a), NONULL(b), l); +} + +int mutt_strncasecmp(const char *a, const char *b, size_t l) +{ + return strncasecmp(NONULL(a), NONULL(b), l); +} + +size_t mutt_strlen(const char *a) +{ + return strlen(NONULL(a)); +} diff --git a/main.c b/main.c index 41a44455e..0340f8b1f 100644 --- a/main.c +++ b/main.c @@ -551,7 +551,7 @@ int main (int argc, char **argv) if (infile) { - if (strcmp ("-", infile) == 0) + if (mutt_strcmp ("-", infile) == 0) fin = stdin; else { diff --git a/mbox.c b/mbox.c index 37aea877f..060abea8f 100644 --- a/mbox.c +++ b/mbox.c @@ -116,7 +116,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) break; - if (strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) == 0) + if (mutt_strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) == 0) { loc = ftell (ctx->fp); @@ -159,7 +159,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) { if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 || fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL || - strcmp (ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP, buf) != 0) + mutt_strcmp (ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP, buf) != 0) { if (fseek (ctx->fp, loc, SEEK_SET) != 0) dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n")); @@ -180,7 +180,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) break; lines++; - } while (strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) != 0); + } while (mutt_strcmp (buf, ctx->magic == M_MMDF ? MMDF_SEP : KENDRA_SEP) != 0); hdr->lines = lines; hdr->content->length = loc - hdr->content->offset; @@ -306,7 +306,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) */ if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 || fgets (buf, sizeof (buf), ctx->fp) == NULL || - strncmp ("From ", buf, 5) != 0) + mutt_strncmp ("From ", buf, 5) != 0) { dprint (1, (debugfile, "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n", curhdr->index, curhdr->content->length)); dprint (1, (debugfile, "\tLINE: %s", buf)); @@ -592,9 +592,9 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint) dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n")); if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) { - if ((ctx->magic == M_MBOX && strncmp ("From ", buffer, 5) == 0) || - (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buffer) == 0) || - (ctx->magic == M_KENDRA && strcmp(KENDRA_SEP, buffer) == 0)) + if ((ctx->magic == M_MBOX && mutt_strncmp ("From ", buffer, 5) == 0) || + (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buffer) == 0) || + (ctx->magic == M_KENDRA && mutt_strcmp(KENDRA_SEP, buffer) == 0)) { if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0) dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n")); @@ -749,9 +749,9 @@ int mbox_sync_mailbox (CONTEXT *ctx) * sure we seek to the correct location */ if (ctx->magic == M_MMDF) - offset -= strlen (MMDF_SEP); + offset -= mutt_strlen (MMDF_SEP); else if (ctx->magic == M_KENDRA) - offset -= strlen(KENDRA_SEP); + offset -= mutt_strlen(KENDRA_SEP); /* allocate space for the new offsets */ newOffset = safe_calloc (ctx->msgcount - first, sizeof (struct m_update_t)); @@ -836,9 +836,9 @@ int mbox_sync_mailbox (CONTEXT *ctx) if (fseek (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 && strncmp ("From ", buf, 5) != 0) || - (ctx->magic == M_MMDF && strcmp (MMDF_SEP, buf) != 0) || - (ctx->magic == M_KENDRA && strcmp (KENDRA_SEP, buf) != 0)) + (ctx->magic == M_MBOX && mutt_strncmp ("From ", buf, 5) != 0) || + (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buf) != 0) || + (ctx->magic == M_KENDRA && mutt_strcmp (KENDRA_SEP, buf) != 0)) { dprint (1, (debugfile, "mbox_sync_mailbox: message not in expected position.")); dprint (1, (debugfile, "\tLINE: %s\n", buf)); diff --git a/menu.c b/menu.c index d724d5ce8..17981351f 100644 --- a/menu.c +++ b/menu.c @@ -79,7 +79,7 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color) void menu_pad_string (char *s, size_t l) { #if !defined(HAVE_BKGDSET) && !defined (USE_SLANG_CURSES) - int n = strlen (s); + int n = mutt_strlen (s); #endif int shift = option (OPTARROWCURSOR) ? 3 : 0; diff --git a/mh.c b/mh.c index 50573d1ac..49b0d69aa 100644 --- a/mh.c +++ b/mh.c @@ -77,7 +77,7 @@ static void maildir_parse_flags(HEADER *h, const char *path) h->read = 0; h->replied = 0; - if ((p = strrchr (path, ':')) != NULL && strncmp (p + 1, "2,", 2) == 0) + if ((p = strrchr (path, ':')) != NULL && mutt_strncmp (p + 1, "2,", 2) == 0) { p += 3; while (*p) @@ -227,7 +227,7 @@ static int maildir_parse_dir(CONTEXT *ctx, struct maildir ***last, if(subdir) { snprintf(buf, sizeof(buf), "%s/%s", ctx->path, subdir); - is_old = (strcmp("cur", subdir) == 0) && option(OPTMARKOLD); + is_old = (mutt_strcmp("cur", subdir) == 0) && option(OPTMARKOLD); } else strfcpy(buf, ctx->path, sizeof(buf)); @@ -451,7 +451,7 @@ static int maildir_sync_message (CONTEXT *ctx, int msgno) snprintf (fullpath, sizeof (fullpath), "%s/%s", ctx->path, partpath); snprintf (oldpath, sizeof (oldpath), "%s/%s", ctx->path, h->path); - if (strcmp (fullpath, oldpath) == 0 && !h->attach_del) + if (mutt_strcmp (fullpath, oldpath) == 0 && !h->attach_del) { /* message hasn't really changed */ return 0; diff --git a/mx.c b/mx.c index 446981217..d38c86306 100644 --- a/mx.c +++ b/mx.c @@ -56,7 +56,7 @@ static const char rcsid[]="$Id$"; #endif -#define mutt_is_spool(s) (strcmp (NONULL(Spoolfile), s) == 0) +#define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0) #ifdef USE_DOTLOCK /* parameters: @@ -353,9 +353,9 @@ int mx_get_magic (const char *path) #endif fgets (tmp, sizeof (tmp), f); - if (strncmp ("From ", tmp, 5) == 0) + if (mutt_strncmp ("From ", tmp, 5) == 0) magic = M_MBOX; - else if (strcmp (MMDF_SEP, tmp) == 0) + else if (mutt_strcmp (MMDF_SEP, tmp) == 0) magic = M_MMDF; fclose (f); #ifndef BUFFY_SIZE @@ -384,15 +384,15 @@ int mx_get_magic (const char *path) */ int mx_set_magic (const char *s) { - if (strcasecmp (s, "mbox") == 0) + if (mutt_strcasecmp (s, "mbox") == 0) DefaultMagic = M_MBOX; - else if (strcasecmp (s, "mmdf") == 0) + else if (mutt_strcasecmp (s, "mmdf") == 0) DefaultMagic = M_MMDF; - else if (strcasecmp (s, "mh") == 0) + else if (mutt_strcasecmp (s, "mh") == 0) DefaultMagic = M_MH; - else if (strcasecmp (s, "maildir") == 0) + else if (mutt_strcasecmp (s, "maildir") == 0) DefaultMagic = M_MAILDIR; - else if (strcasecmp (s, "kendra") == 0) + else if (mutt_strcasecmp (s, "kendra") == 0) DefaultMagic = M_KENDRA; else return (-1); diff --git a/pager.c b/pager.c index 3be2ca553..c4ea29d9b 100644 --- a/pager.c +++ b/pager.c @@ -407,7 +407,7 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr, { /* case 1: check the top level nodes */ - if (strncmp (qptr, q_list->prefix, length) == 0) + if (mutt_strncmp (qptr, q_list->prefix, length) == 0) { if (length == q_list->length) return q_list; /* same prefix: return the current class */ @@ -501,7 +501,7 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr, /* case 2: try subclassing the current top level node */ /* tmp != NULL means we already found a shorter prefix at case 1 */ - if (tmp == NULL && strncmp (qptr, q_list->prefix, q_list->length) == 0) + if (tmp == NULL && mutt_strncmp (qptr, q_list->prefix, q_list->length) == 0) { /* ok, it's a subclass somewhere on this branch */ @@ -516,7 +516,7 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr, { if (length <= q_list->length) { - if (strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng) == 0) + if (mutt_strncmp (tail_qptr, (q_list->prefix) + offset, tail_lng) == 0) { /* same prefix: return the current class */ if (length == q_list->length) @@ -604,7 +604,7 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr, else { /* longer than the current prefix: try subclassing it */ - if (tmp == NULL && strncmp (tail_qptr, (q_list->prefix) + offset, + if (tmp == NULL && mutt_strncmp (tail_qptr, (q_list->prefix) + offset, q_list->length - offset) == 0) { /* still a subclass: go down one level */ @@ -720,9 +720,9 @@ resolve_types (char *buf, struct line_t *lineInfo, int n, int last, } } } - else if (strncmp ("[-- ", buf, 4) == 0) + else if (mutt_strncmp ("[-- ", buf, 4) == 0) lineInfo[n].type = MT_COLOR_ATTACHMENT; - else if (strcmp ("-- \n", buf) == 0 || strcmp ("-- \r\n", buf) == 0) + else if (mutt_strcmp ("-- \n", buf) == 0 || mutt_strcmp ("-- \r\n", buf) == 0) { i = n + 1; diff --git a/parse.c b/parse.c index 017ebfc36..cf664e250 100644 --- a/parse.c +++ b/parse.c @@ -55,7 +55,7 @@ static char *read_rfc822_line (FILE *f, char *line, size_t *linelen) return (line); } - buf += strlen (buf) - 1; + buf += mutt_strlen (buf) - 1; if (*buf == '\n') { /* we did get a full line. remove trailing space */ @@ -116,17 +116,17 @@ static LIST *mutt_parse_references (char *s) int mutt_check_encoding (const char *c) { - if (strncasecmp ("7bit", c, sizeof ("7bit")-1) == 0) + if (mutt_strncasecmp ("7bit", c, sizeof ("7bit")-1) == 0) return (ENC7BIT); - else if (strncasecmp ("8bit", c, sizeof ("8bit")-1) == 0) + else if (mutt_strncasecmp ("8bit", c, sizeof ("8bit")-1) == 0) return (ENC8BIT); - else if (strncasecmp ("binary", c, sizeof ("binary")-1) == 0) + else if (mutt_strncasecmp ("binary", c, sizeof ("binary")-1) == 0) return (ENCBINARY); - else if (strncasecmp ("quoted-printable", c, sizeof ("quoted-printable")-1) == 0) + else if (mutt_strncasecmp ("quoted-printable", c, sizeof ("quoted-printable")-1) == 0) return (ENCQUOTEDPRINTABLE); - else if (strncasecmp ("base64", c, sizeof("base64")-1) == 0) + else if (mutt_strncasecmp ("base64", c, sizeof("base64")-1) == 0) return (ENCBASE64); - else if (strncasecmp ("x-uuencode", c, sizeof("x-uuencode")-1) == 0) + else if (mutt_strncasecmp ("x-uuencode", c, sizeof("x-uuencode")-1) == 0) return (ENCUUENCODED); else return (ENCOTHER); @@ -227,19 +227,19 @@ static PARAMETER *parse_parameters (const char *s) int mutt_check_mime_type (const char *s) { - if (strcasecmp ("text", s) == 0) + if (mutt_strcasecmp ("text", s) == 0) return TYPETEXT; - else if (strcasecmp ("multipart", s) == 0) + else if (mutt_strcasecmp ("multipart", s) == 0) return TYPEMULTIPART; - else if (strcasecmp ("application", s) == 0) + else if (mutt_strcasecmp ("application", s) == 0) return TYPEAPPLICATION; - else if (strcasecmp ("message", s) == 0) + else if (mutt_strcasecmp ("message", s) == 0) return TYPEMESSAGE; - else if (strcasecmp ("image", s) == 0) + else if (mutt_strcasecmp ("image", s) == 0) return TYPEIMAGE; - else if (strcasecmp ("audio", s) == 0) + else if (mutt_strcasecmp ("audio", s) == 0) return TYPEAUDIO; - else if (strcasecmp ("video", s) == 0) + else if (mutt_strcasecmp ("video", s) == 0) return TYPEVIDEO; else return TYPEOTHER; @@ -313,9 +313,9 @@ static void parse_content_disposition (char *s, BODY *ct) { PARAMETER *parms; - if (!strncasecmp ("inline", s, 6)) + if (!mutt_strncasecmp ("inline", s, 6)) ct->disposition = DISPINLINE; - else if (!strncasecmp ("form-data", s, 9)) + else if (!mutt_strncasecmp ("form-data", s, 9)) ct->disposition = DISPFORMDATA; else ct->disposition = DISPATTACH; @@ -379,19 +379,19 @@ BODY *mutt_read_mime_header (FILE *fp, int digest) break; } - if (!strncasecmp ("content-", line, 8)) + if (!mutt_strncasecmp ("content-", line, 8)) { - if (!strcasecmp ("type", line + 8)) + if (!mutt_strcasecmp ("type", line + 8)) parse_content_type (c, p); - else if (!strcasecmp ("transfer-encoding", line + 8)) + else if (!mutt_strcasecmp ("transfer-encoding", line + 8)) p->encoding = mutt_check_encoding (c); - else if (!strcasecmp ("disposition", line + 8)) + else if (!mutt_strcasecmp ("disposition", line + 8)) parse_content_disposition (c, p); - else if (!strcasecmp ("description", line + 8)) + else if (!mutt_strcasecmp ("description", line + 8)) { safe_free ((void **) &p->description); p->description = safe_strdup (c); - rfc2047_decode (p->description, p->description, strlen (p->description) + 1); + rfc2047_decode (p->description, p->description, mutt_strlen (p->description) + 1); } } } @@ -436,7 +436,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent) msg->length = 0; if (msg->type == TYPEMULTIPART) - msg->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", msg->parameter), msg->offset + msg->length, strcasecmp ("digest", msg->subtype) == 0); + msg->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", msg->parameter), msg->offset + msg->length, mutt_strcasecmp ("digest", msg->subtype) == 0); else if (msg->type == TYPEMESSAGE) msg->parts = mutt_parse_messageRFC822 (fp, msg); else @@ -480,10 +480,10 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di return (NULL); } - blen = strlen (boundary); + blen = mutt_strlen (boundary); while (ftell (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL) { - len = strlen (buffer); + len = mutt_strlen (buffer); /* take note of the line ending. I'm assuming that either all endings * will use or none will. @@ -492,7 +492,7 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di crlf = 1; if (buffer[0] == '-' && buffer[1] == '-' && - strncmp (buffer + 2, boundary, blen) == 0) + mutt_strncmp (buffer + 2, boundary, blen) == 0) { if (last) { @@ -509,7 +509,7 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di buffer[i] = 0; /* Check for the end boundary */ - if (strcmp (buffer + blen + 2, "--") == 0) + if (mutt_strcmp (buffer + blen + 2, "--") == 0) { final = 1; break; /* done parsing */ @@ -550,17 +550,17 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di { case TYPEMULTIPART: fseek (fp, last->offset, 0); - last->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", last->parameter), last->offset + last->length, strcasecmp ("digest", last->subtype) == 0); + last->parts = mutt_parse_multipart (fp, mutt_get_parameter ("boundary", last->parameter), last->offset + last->length, mutt_strcasecmp ("digest", last->subtype) == 0); break; case TYPEMESSAGE: if (last->subtype) { fseek (fp, last->offset, SEEK_SET); - if (strcasecmp (last->subtype, "rfc822") == 0 || - strcasecmp (last->subtype, "news") == 0) + if (mutt_strcasecmp (last->subtype, "rfc822") == 0 || + mutt_strcasecmp (last->subtype, "news") == 0) last->parts = mutt_parse_messageRFC822 (fp, last); - else if (strcasecmp (last->subtype, "external-body") == 0) + else if (mutt_strcasecmp (last->subtype, "external-body") == 0) last->parts = mutt_read_mime_header (fp, 0); } break; @@ -741,7 +741,7 @@ time_t mutt_parse_date (char *s, HEADER *h) else { for (i = 0; TimeZones[i].tzname; i++) - if (!strcasecmp (TimeZones[i].tzname, ptz)) + if (!mutt_strcasecmp (TimeZones[i].tzname, ptz)) { zhours = TimeZones[i].zhours; zminutes = TimeZones[i].zminutes; @@ -750,11 +750,11 @@ time_t mutt_parse_date (char *s, HEADER *h) } /* ad hoc support for the European MET (now officially CET) TZ */ - if (strcasecmp (t, "MET") == 0) + if (mutt_strcasecmp (t, "MET") == 0) { if ((t = strtok (NULL, " \t")) != NULL) { - if (!strcasecmp (t, "DST")) + if (!mutt_strcasecmp (t, "DST")) zhours++; } } @@ -814,7 +814,7 @@ void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur) if (cur->content->type == TYPEMULTIPART) { if (!cur->content->parts) - cur->content->parts = mutt_parse_multipart (msg->fp, mutt_get_parameter ("boundary", cur->content->parameter), cur->content->offset + cur->content->length, strcasecmp ("digest", cur->content->subtype) == 0); + cur->content->parts = mutt_parse_multipart (msg->fp, mutt_get_parameter ("boundary", cur->content->parameter), cur->content->offset + cur->content->length, mutt_strcasecmp ("digest", cur->content->subtype) == 0); } else { @@ -889,7 +889,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 (strncmp (">From ", line, 6) == 0) + if (mutt_strncmp (">From ", line, 6) == 0) { loc = ftell (f); continue; /* just ignore */ @@ -916,12 +916,12 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) switch (tolower (line[0])) { case 'a': - if (strcasecmp (line+1, "pparently-to") == 0) + if (mutt_strcasecmp (line+1, "pparently-to") == 0) { e->to = rfc822_parse_adrlist (e->to, p); matched = 1; } - else if (strcasecmp (line+1, "pparently-from") == 0) + else if (mutt_strcasecmp (line+1, "pparently-from") == 0) { e->from = rfc822_parse_adrlist (e->from, p); matched = 1; @@ -929,7 +929,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'b': - if (strcasecmp (line+1, "cc") == 0) + if (mutt_strcasecmp (line+1, "cc") == 0) { e->bcc = rfc822_parse_adrlist (e->bcc, p); matched = 1; @@ -937,32 +937,32 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'c': - if (strcasecmp (line+1, "c") == 0) + if (mutt_strcasecmp (line+1, "c") == 0) { e->cc = rfc822_parse_adrlist (e->cc, p); matched = 1; } - else if (strncasecmp (line + 1, "ontent-", 7) == 0) + else if (mutt_strncasecmp (line + 1, "ontent-", 7) == 0) { - if (strcasecmp (line+8, "type") == 0) + if (mutt_strcasecmp (line+8, "type") == 0) { if (hdr) parse_content_type (p, hdr->content); matched = 1; } - else if (strcasecmp (line+8, "transfer-encoding") == 0) + else if (mutt_strcasecmp (line+8, "transfer-encoding") == 0) { if (hdr) hdr->content->encoding = mutt_check_encoding (p); matched = 1; } - else if (strcasecmp (line+8, "length") == 0) + else if (mutt_strcasecmp (line+8, "length") == 0) { if (hdr) hdr->content->length = atoi (p); matched = 1; } - else if (strcasecmp (line+8, "description") == 0) + else if (mutt_strcasecmp (line+8, "description") == 0) { if (hdr) { @@ -970,11 +970,11 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) hdr->content->description = safe_strdup (p); rfc2047_decode (hdr->content->description, hdr->content->description, - strlen (hdr->content->description) + 1); + mutt_strlen (hdr->content->description) + 1); } matched = 1; } - else if (strcasecmp (line+8, "disposition") == 0) + else if (mutt_strcasecmp (line+8, "disposition") == 0) { if (hdr) parse_content_disposition (p, hdr->content); @@ -984,7 +984,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'd': - if (!strcasecmp ("ate", line + 1)) + if (!mutt_strcasecmp ("ate", line + 1)) { safe_free((void **)&e->date); e->date = safe_strdup(p); @@ -995,13 +995,13 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'e': - if (!strcasecmp ("xpires", line + 1) && + if (!mutt_strcasecmp ("xpires", line + 1) && hdr && mutt_parse_date (p, NULL) < time (NULL)) hdr->expired = 1; break; case 'f': - if (!strcasecmp ("rom", line + 1)) + if (!mutt_strcasecmp ("rom", line + 1)) { e->from = rfc822_parse_adrlist (e->from, p); matched = 1; @@ -1009,7 +1009,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'i': - if (!strcasecmp (line+1, "n-reply-to")) + if (!mutt_strcasecmp (line+1, "n-reply-to")) { if (hdr) { @@ -1021,7 +1021,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'l': - if (!strcasecmp (line + 1, "ines")) + if (!mutt_strcasecmp (line + 1, "ines")) { if (hdr) hdr->lines = atoi (p); @@ -1030,29 +1030,29 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'm': - if (!strcasecmp (line + 1, "ime-version")) + if (!mutt_strcasecmp (line + 1, "ime-version")) { if (hdr) hdr->mime = 1; matched = 1; } - else if (!strcasecmp (line + 1, "essage-id")) + else if (!mutt_strcasecmp (line + 1, "essage-id")) { /* We add a new "Message-Id:" when building a message */ safe_free ((void **) &e->message_id); e->message_id = extract_message_id (p); matched = 1; } - else if (!strncasecmp (line + 1, "ail-", 4)) + else if (!mutt_strncasecmp (line + 1, "ail-", 4)) { - if (!strcasecmp (line + 5, "reply-to")) + if (!mutt_strcasecmp (line + 5, "reply-to")) { /* override the Reply-To: field */ rfc822_free_address (&e->reply_to); e->reply_to = rfc822_parse_adrlist (e->reply_to, p); matched = 1; } - else if (!strcasecmp (line + 5, "followup-to")) + else if (!mutt_strcasecmp (line + 5, "followup-to")) { e->mail_followup_to = rfc822_parse_adrlist (e->mail_followup_to, p); matched = 1; @@ -1061,23 +1061,23 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'r': - if (!strcasecmp (line + 1, "eferences")) + if (!mutt_strcasecmp (line + 1, "eferences")) { mutt_free_list (&e->references); e->references = mutt_parse_references (p); matched = 1; } - else if (!strcasecmp (line + 1, "eply-to")) + else if (!mutt_strcasecmp (line + 1, "eply-to")) { e->reply_to = rfc822_parse_adrlist (e->reply_to, p); matched = 1; } - else if (!strcasecmp (line + 1, "eturn-path")) + else if (!mutt_strcasecmp (line + 1, "eturn-path")) { e->return_path = rfc822_parse_adrlist (e->return_path, p); matched = 1; } - else if (!strcasecmp (line + 1, "eceived")) + else if (!mutt_strcasecmp (line + 1, "eceived")) { if (hdr && !hdr->received) { @@ -1090,18 +1090,18 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 's': - if (!strcasecmp (line + 1, "ubject")) + if (!mutt_strcasecmp (line + 1, "ubject")) { if (!e->subject) e->subject = safe_strdup (p); matched = 1; } - else if (!strcasecmp (line + 1, "ender")) + else if (!mutt_strcasecmp (line + 1, "ender")) { e->sender = rfc822_parse_adrlist (e->sender, p); matched = 1; } - else if (!strcasecmp (line + 1, "tatus")) + else if (!mutt_strcasecmp (line + 1, "tatus")) { if (hdr) { @@ -1125,13 +1125,13 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) } matched = 1; } - else if ((!strcasecmp ("upersedes", line + 1) || - !strcasecmp ("upercedes", line + 1)) && hdr) + else if ((!mutt_strcasecmp ("upersedes", line + 1) || + !mutt_strcasecmp ("upercedes", line + 1)) && hdr) e->supersedes = safe_strdup (p); break; case 't': - if (strcasecmp (line+1, "o") == 0) + if (mutt_strcasecmp (line+1, "o") == 0) { e->to = rfc822_parse_adrlist (e->to, p); matched = 1; @@ -1139,7 +1139,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) break; case 'x': - if (strcasecmp (line+1, "-status") == 0) + if (mutt_strcasecmp (line+1, "-status") == 0) { if (hdr) { @@ -1179,7 +1179,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) } else last = e->userhdrs = mutt_new_list (); - line[strlen (line)] = ':'; + line[mutt_strlen (line)] = ':'; last->data = safe_strdup (line); } @@ -1199,7 +1199,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) if (in_reply_to[0] && (p = extract_message_id (in_reply_to)) != NULL) { if (!e->references || - (e->references && strcmp (e->references->data, p) != 0)) + (e->references && mutt_strcmp (e->references->data, p) != 0)) { LIST *tmp = mutt_new_list (); @@ -1224,7 +1224,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) { regmatch_t pmatch[1]; - rfc2047_decode (e->subject, e->subject, strlen (e->subject) + 1); + rfc2047_decode (e->subject, e->subject, mutt_strlen (e->subject) + 1); if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0) e->real_subj = e->subject + pmatch[0].rm_eo; diff --git a/pattern.c b/pattern.c index 513a3f039..d30f86f27 100644 --- a/pattern.c +++ b/pattern.c @@ -207,7 +207,7 @@ msg_search (CONTEXT *ctx, regex_t *rx, char *buf, size_t blen, int op, int msgno match = 1; break; } - lng -= strlen (buf); + lng -= mutt_strlen (buf); } mx_close_message (&msg); @@ -560,7 +560,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err) memset (&ps, 0, sizeof (ps)); ps.dptr = s; - ps.dsize = strlen (s); + ps.dsize = mutt_strlen (s); while (*ps.dptr) { @@ -878,24 +878,24 @@ void mutt_check_simple (char *s, size_t len, const char *simple) if (!strchr (s, '~')) /* yup, so spoof a real request */ { /* convert old tokens into the new format */ - if (strcasecmp ("all", s) == 0 || - !strcmp ("^", s) || !strcmp (".", s)) /* ~A is more efficient */ + if (mutt_strcasecmp ("all", s) == 0 || + !mutt_strcmp ("^", s) || !mutt_strcmp (".", s)) /* ~A is more efficient */ strfcpy (s, "~A", len); - else if (strcasecmp ("del", s) == 0) + else if (mutt_strcasecmp ("del", s) == 0) strfcpy (s, "~D", len); - else if (strcasecmp ("flag", s) == 0) + else if (mutt_strcasecmp ("flag", s) == 0) strfcpy (s, "~F", len); - else if (strcasecmp ("new", s) == 0) + else if (mutt_strcasecmp ("new", s) == 0) strfcpy (s, "~N", len); - else if (strcasecmp ("old", s) == 0) + else if (mutt_strcasecmp ("old", s) == 0) strfcpy (s, "~O", len); - else if (strcasecmp ("repl", s) == 0) + else if (mutt_strcasecmp ("repl", s) == 0) strfcpy (s, "~Q", len); - else if (strcasecmp ("read", s) == 0) + else if (mutt_strcasecmp ("read", s) == 0) strfcpy (s, "~R", len); - else if (strcasecmp ("tag", s) == 0) + else if (mutt_strcasecmp ("tag", s) == 0) strfcpy (s, "~T", len); - else if (strcasecmp ("unread", s) == 0) + else if (mutt_strcasecmp ("unread", s) == 0) strfcpy (s, "~U", len); else { @@ -999,7 +999,7 @@ int mutt_pattern_func (int op, char *prompt) Context->vcount = Context->msgcount; } - else if (strncmp (buf, "~A", 2) != 0) + else if (mutt_strncmp (buf, "~A", 2) != 0) { Context->pattern = simple; simple = NULL; /* don't clobber it */ @@ -1039,7 +1039,7 @@ int mutt_search_command (int cur, int op) strfcpy (temp, buf, sizeof (temp)); mutt_check_simple (temp, sizeof (temp), NONULL (SimpleSearch)); - if (!SearchPattern || strcmp (temp, LastSearchExpn)) + if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn)) { set_option (OPTSEARCHINVALID); strfcpy (LastSearch, buf, sizeof (LastSearch)); diff --git a/pgp.c b/pgp.c index 53da6c75b..a3c41977c 100644 --- a/pgp.c +++ b/pgp.c @@ -163,12 +163,12 @@ struct pgp_vinfo *pgp_get_vinfo(enum pgp_ops op) } } - if (!strcasecmp(version, "default")) + if (!mutt_strcasecmp(version, "default")) version = PgpDefaultVersion; for(i = 0; pgp_vinfo[i].name; i++) { - if(!strcasecmp(pgp_vinfo[i].name, version)) + if(!mutt_strcasecmp(pgp_vinfo[i].name, version)) return &pgp_vinfo[i]; } @@ -209,7 +209,7 @@ static void pgp_current_time (STATE *s) t = time (NULL); strfcpy (p, asctime (localtime (&t)), sizeof (p)); - p[strlen (p) - 1] = 0; /* kill the newline */ + p[mutt_strlen (p) - 1] = 0; /* kill the newline */ state_puts (p, s); state_puts (") --]\n", s); @@ -243,23 +243,23 @@ void application_pgp_handler (BODY *m, STATE *s) if (fgets (buf, sizeof (buf) - 1, s->fpin) == NULL) break; offset = ftell (s->fpin); - bytes -= (offset - last_pos); /* don't rely on strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ last_pos = offset; - if (strncmp ("-----BEGIN PGP ", buf, 15) == 0) + if (mutt_strncmp ("-----BEGIN PGP ", buf, 15) == 0) { clearsign = 0; start_pos = last_pos; - if (strcmp ("MESSAGE-----\n", buf + 15) == 0) + if (mutt_strcmp ("MESSAGE-----\n", buf + 15) == 0) needpass = 1; - else if (strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0) + else if (mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15) == 0) { clearsign = 1; needpass = 0; } else if (!option(OPTDONTHANDLEPGPKEYS) && - strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) + mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15) == 0) { needpass = 0; pgp_keyblock =1; @@ -296,14 +296,14 @@ void application_pgp_handler (BODY *m, STATE *s) while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) { offset = ftell (s->fpin); - bytes -= (offset - last_pos); /* don't rely on strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */ last_pos = offset; fputs (buf, tmpfp); - if ((needpass && strcmp ("-----END PGP MESSAGE-----\n", buf) == 0) || + if ((needpass && mutt_strcmp ("-----END PGP MESSAGE-----\n", buf) == 0) || (!needpass - && (strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0 - || strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0))) + && (mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) == 0 + || mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",buf) == 0))) break; } @@ -410,7 +410,7 @@ void application_pgp_handler (BODY *m, STATE *s) if(complete) { - if (!strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n")) + if (!mutt_strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n")) break; if(armor_header) @@ -438,7 +438,7 @@ void application_pgp_handler (BODY *m, STATE *s) complete = strchr(buf, '\n') != NULL; } - if (complete && !strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n")) + if (complete && !mutt_strcmp(buf, "-----BEGIN PGP SIGNATURE-----\n")) { while(bytes > 0 && fgets(buf, sizeof(buf) - 1, s->fpin) != NULL) { @@ -446,7 +446,7 @@ void application_pgp_handler (BODY *m, STATE *s) bytes -= (offset - last_pos); last_pos = offset; - if(complete && !strcmp(buf, "-----END PGP SIGNATURE-----\n")) + if(complete && !mutt_strcmp(buf, "-----END PGP SIGNATURE-----\n")) break; complete = strchr(buf, '\n') != NULL; @@ -485,9 +485,9 @@ int mutt_is_multipart_signed(BODY *b) char *p; if(!b || b->type != TYPEMULTIPART || - !b->subtype || strcasecmp(b->subtype, "signed") || + !b->subtype || mutt_strcasecmp(b->subtype, "signed") || !(p = mutt_get_parameter("protocol", b->parameter)) || - strcasecmp(p, "application/pgp-signature")) + mutt_strcasecmp(p, "application/pgp-signature")) return 0; return PGPSIGN; @@ -499,9 +499,9 @@ int mutt_is_multipart_encrypted(BODY *b) char *p; if(!b || b->type != TYPEMULTIPART || - !b->subtype || strcasecmp(b->subtype, "encrypted") || + !b->subtype || mutt_strcasecmp(b->subtype, "encrypted") || !(p = mutt_get_parameter("protocol", b->parameter)) || - strcasecmp(p, "application/pgp-encrypted")) + mutt_strcasecmp(p, "application/pgp-encrypted")) return 0; return PGPENCRYPT; @@ -514,26 +514,26 @@ int mutt_is_application_pgp(BODY *m) if (m->type == TYPEAPPLICATION) { - if (!strcasecmp (m->subtype, "pgp") || !strcasecmp (m->subtype, "x-pgp-message")) + if (!mutt_strcasecmp (m->subtype, "pgp") || !mutt_strcasecmp (m->subtype, "x-pgp-message")) { if ((p = mutt_get_parameter ("x-action", m->parameter)) - && (!strcasecmp (p, "sign") || !strcasecmp (p, "signclear"))) + && (!mutt_strcasecmp (p, "sign") || !mutt_strcasecmp (p, "signclear"))) t |= PGPSIGN; else if((p = mutt_get_parameter ("format", m->parameter)) - && !strcasecmp(p, "keys-only")) + && !mutt_strcasecmp(p, "keys-only")) t |= PGPKEY; if ((p = mutt_get_parameter ("format", m->parameter)) && - !strcasecmp (p, "keys-only")) + !mutt_strcasecmp (p, "keys-only")) t |= PGPKEY; if(!t) t |= PGPENCRYPT; /* not necessarily correct, but... */ } - if (!strcasecmp (m->subtype, "pgp-signed")) + if (!mutt_strcasecmp (m->subtype, "pgp-signed")) t |= PGPSIGN; - if (!strcasecmp (m->subtype, "pgp-keys")) + if (!mutt_strcasecmp (m->subtype, "pgp-keys")) t |= PGPKEY; } return t; @@ -588,7 +588,7 @@ void pgp_signed_handler (BODY *a, STATE *s) * multipart/signed body. */ if (a && a->next && a->next->type == TYPEAPPLICATION && a->next->subtype && - strcasecmp (a->next->subtype, "pgp-signature") == 0) + mutt_strcasecmp (a->next->subtype, "pgp-signature") == 0) { if (s->flags & M_DISPLAY) { @@ -877,7 +877,7 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout) */ while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL) { - len = strlen (buf); + len = mutt_strlen (buf); if (len > 1 && buf[len - 2] == '\r') strcpy (buf + len - 2, "\n"); fputs (buf, fpout); @@ -911,7 +911,7 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout) if (tattach->type == TYPEMULTIPART) { fseek (fpout, tattach->offset, 0); - tattach->parts = mutt_parse_multipart (fpout, mutt_get_parameter ("boundary", tattach->parameter), tattach->offset + tattach->length, strcasecmp ("digest", tattach->subtype) == 0); + tattach->parts = mutt_parse_multipart (fpout, mutt_get_parameter ("boundary", tattach->parameter), tattach->offset + tattach->length, mutt_strcasecmp ("digest", tattach->subtype) == 0); } else if (tattach->type == TYPEMESSAGE) { @@ -960,9 +960,9 @@ void pgp_encrypted_handler (BODY *a, STATE *s) a = a->parts; if (!a || a->type != TYPEAPPLICATION || !a->subtype || - strcasecmp ("pgp-encrypted", a->subtype) != 0 || + mutt_strcasecmp ("pgp-encrypted", a->subtype) != 0 || !a->next || a->next->type != TYPEAPPLICATION || !a->next->subtype || - strcasecmp ("octet-stream", a->next->subtype) != 0) + mutt_strcasecmp ("octet-stream", a->next->subtype) != 0) { if (s->flags & M_DISPLAY) state_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s); @@ -1023,7 +1023,7 @@ static void convert_to_7bit (BODY *a) convert_to_7bit (a->parts); } else if (a->type == TYPEMESSAGE - && strcasecmp(a->subtype, "delivery-status")) + && mutt_strcasecmp(a->subtype, "delivery-status")) { if(a->encoding != ENC7BIT) mutt_message_to_7bit(a, NULL); @@ -1095,9 +1095,9 @@ static BODY *pgp_sign_message (BODY *a) */ while (fgets (buffer, sizeof (buffer) - 1, pgpout) != NULL) { - if (strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0) + if (mutt_strcmp ("-----BEGIN PGP MESSAGE-----\n", buffer) == 0) fputs ("-----BEGIN PGP SIGNATURE-----\n", fp); - else if (strcmp("-----END PGP MESSAGE-----\n", buffer) == 0) + else if (mutt_strcmp("-----END PGP MESSAGE-----\n", buffer) == 0) fputs ("-----END PGP SIGNATURE-----\n", fp); else fputs (buffer, fp); @@ -1232,11 +1232,11 @@ char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc) else key = pgp_keyid(k_info); - keylist_size += strlen (key) + 4; + keylist_size += mutt_strlen (key) + 4; safe_realloc ((void **)&keylist, keylist_size); sprintf (keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", key); - keylist_used = strlen (keylist); + keylist_used = mutt_strlen (keylist); } rfc822_free_address (&tmp); pgp_close_keydb (&db); diff --git a/pgpinvoke.c b/pgpinvoke.c index e97640037..5544a6dc1 100644 --- a/pgpinvoke.c +++ b/pgpinvoke.c @@ -471,7 +471,7 @@ pid_t pgp_gpg_invoke_decrypt(struct pgp_vinfo *pgp, static char *gpg_digalg(void) { static char digalg[STRING]; - if(PgpSignMicalg && !strncasecmp(PgpSignMicalg, "pgp-", 4)) + if(PgpSignMicalg && !mutt_strncasecmp(PgpSignMicalg, "pgp-", 4)) strfcpy(digalg, PgpSignMicalg + 4, sizeof(digalg)); else { @@ -593,7 +593,7 @@ pid_t pgp_gpg_invoke_verify_key(struct pgp_vinfo *pgp, snprintf(cmd, sizeof(cmd), "%sm --no-verbose --batch --fingerprint --check-sigs %s%s", - NONULL(binary), (strlen(id)==8 || strlen(id)==16)? "0x":"", id ); + NONULL(binary), (mutt_strlen(id)==8 || mutt_strlen(id)==16)? "0x":"", id ); FREE(&binary); diff --git a/pgpkey.c b/pgpkey.c index 40084150c..10e89bd22 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -102,10 +102,10 @@ static int pgp_compare (const void *a, const void *b) pgp_key_t *s = (pgp_key_t *) a; pgp_key_t *t = (pgp_key_t *) b; - if((r = strcasecmp (s->a->addr, t->a->addr)) != 0) + if((r = mutt_strcasecmp (s->a->addr, t->a->addr)) != 0) return r; else - return strcasecmp(pgp_keyid(s->k), pgp_keyid(t->k)); + return mutt_strcasecmp(pgp_keyid(s->k), pgp_keyid(t->k)); } static KEYINFO *pgp_select_key (struct pgp_vinfo *pgp, @@ -191,7 +191,7 @@ static KEYINFO *pgp_select_key (struct pgp_vinfo *pgp, strfcpy (buf, _("PGP keys matching "), sizeof (buf)); if (p) - strfcpy (buf, p->mailbox, sizeof (buf) - strlen (buf)); + strfcpy (buf, p->mailbox, sizeof (buf) - mutt_strlen (buf)); else strcat (buf, s); menu->title = buf; @@ -301,7 +301,7 @@ char *pgp_ask_for_key (struct pgp_vinfo *pgp, KEYINFO *db, char *tag, char *what { for (l = id_defaults; l; l = l->next) - if (!strcasecmp (whatfor, NONULL(l->what))) + if (!mutt_strcasecmp (whatfor, l->what)) { strcpy (resp, NONULL(l->dflt)); break; @@ -480,14 +480,14 @@ KEYINFO *ki_getkeybyaddr (struct pgp_vinfo *pgp, for(p = r; p && weak_association; p = p->next) { if ((p->mailbox && a->mailbox && - strcasecmp (p->mailbox, a->mailbox) == 0) || + mutt_strcasecmp (p->mailbox, a->mailbox) == 0) || (a->personal && p->personal && - strcasecmp (a->personal, p->personal) == 0)) + mutt_strcasecmp (a->personal, p->personal) == 0)) { match = 1; if(((u->trust & 0x03) == 3) && - (p->mailbox && a->mailbox && !strcasecmp(p->mailbox, a->mailbox))) + (p->mailbox && a->mailbox && !mutt_strcasecmp(p->mailbox, a->mailbox))) weak_association = 0; } } @@ -558,10 +558,10 @@ KEYINFO *ki_getkeybystr (struct pgp_vinfo *pgp, for(; a ; a = a->next) { - if (!*p || strcasecmp (p, pgp_keyid(k)) == 0 || - (!strncasecmp(p, "0x", 2) && !strcasecmp(p+2, pgp_keyid(k))) || - (option(OPTPGPLONGIDS) && !strncasecmp(p, "0x", 2) && - !strcasecmp(p+2, k->keyid+8)) || + if (!*p || mutt_strcasecmp (p, pgp_keyid(k)) == 0 || + (!mutt_strncasecmp(p, "0x", 2) && !mutt_strcasecmp(p+2, pgp_keyid(k))) || + (option(OPTPGPLONGIDS) && !mutt_strncasecmp(p, "0x", 2) && + !mutt_strcasecmp(p+2, k->keyid+8)) || mutt_stristr(((PGPUID *)a->data)->addr,p)) { t = mutt_new_list (); diff --git a/pgppubring.c b/pgppubring.c index 5d25fade9..fb5d135c2 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -110,7 +110,7 @@ const char *pgp_pkalg_to_mic(const char *alg) for(i = 0; pktomic[i].pkalg; i++) { - if(!strcasecmp(pktomic[i].pkalg, alg)) + if(!mutt_strcasecmp(pktomic[i].pkalg, alg)) break; } diff --git a/pop.c b/pop.c index df25f6bfc..7b838a845 100644 --- a/pop.c +++ b/pop.c @@ -131,7 +131,7 @@ void mutt_fetchPopMail (void) if (getLine (s, buffer, sizeof (buffer)) == -1) goto fail; - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { mutt_remove_trailing_ws (buffer); mutt_error (buffer); @@ -139,12 +139,12 @@ void mutt_fetchPopMail (void) } snprintf (buffer, sizeof(buffer), "user %s\r\n", PopUser); - write (s, buffer, strlen (buffer)); + write (s, buffer, mutt_strlen (buffer)); if (getLine (s, buffer, sizeof (buffer)) == -1) goto fail; - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { mutt_remove_trailing_ws (buffer); mutt_error (buffer); @@ -152,15 +152,15 @@ void mutt_fetchPopMail (void) } snprintf (buffer, sizeof(buffer), "pass %s\r\n", NONULL(PopPass)); - write (s, buffer, strlen (buffer)); + write (s, buffer, mutt_strlen (buffer)); if (getLine (s, buffer, sizeof (buffer)) == -1) goto fail; - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { if(PopPass) - memset(PopPass, 0, strlen(PopPass)); + memset(PopPass, 0, mutt_strlen(PopPass)); safe_free((void **) &PopPass); /* void the given password */ mutt_remove_trailing_ws (buffer); @@ -174,7 +174,7 @@ void mutt_fetchPopMail (void) if (getLine (s, buffer, sizeof (buffer)) == -1) goto fail; - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { mutt_remove_trailing_ws (buffer); mutt_error (buffer); @@ -199,7 +199,7 @@ void mutt_fetchPopMail (void) if (getLine (s, buffer, sizeof (buffer)) == -1) goto fail; - if (strncmp (buffer, "+OK", 3) == 0) + if (mutt_strncmp (buffer, "+OK", 3) == 0) sscanf (buffer, "+OK %d", &last); else /* ignore an error here and assume all messages are new */ @@ -214,7 +214,7 @@ void mutt_fetchPopMail (void) for (i = last + 1 ; i <= msgs ; i++) { snprintf (buffer, sizeof(buffer), "retr %d\r\n", i); - write (s, buffer, strlen (buffer)); + write (s, buffer, mutt_strlen (buffer)); if (getLine (s, buffer, sizeof (buffer)) == -1) { @@ -222,7 +222,7 @@ void mutt_fetchPopMail (void) goto fail; } - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { mutt_remove_trailing_ws (buffer); mutt_error (buffer); @@ -251,7 +251,7 @@ void mutt_fetchPopMail (void) /* check to see if we got a full line */ if (buffer[chunk-2] == '\r' && buffer[chunk-1] == '\n') { - if (strcmp(".\r\n", buffer) == 0) + if (mutt_strcmp(".\r\n", buffer) == 0) { /* end of message */ break; @@ -290,11 +290,11 @@ void mutt_fetchPopMail (void) { /* delete the message on the server */ snprintf (buffer, sizeof(buffer), "dele %d\r\n", i); - write (s, buffer, strlen (buffer)); + write (s, buffer, mutt_strlen (buffer)); /* eat the server response */ getLine (s, buffer, sizeof (buffer)); - if (strncmp (buffer, "+OK", 3) != 0) + if (mutt_strncmp (buffer, "+OK", 3) != 0) { err = 1; mutt_remove_trailing_ws (buffer); diff --git a/postpone.c b/postpone.c index dfa55fd84..cdf9a572f 100644 --- a/postpone.c +++ b/postpone.c @@ -230,7 +230,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size for (tmp = hdr->env->userhdrs; tmp; ) { - if (strncasecmp ("X-Mutt-References:", tmp->data, 18) == 0) + if (mutt_strncasecmp ("X-Mutt-References:", tmp->data, 18) == 0) { if (ctx) { @@ -253,7 +253,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size if (*cur) code |= SENDREPLY; } - else if (strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0) + else if (mutt_strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0) { p = tmp->data + 11; SKIPWS (p); @@ -274,7 +274,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size #ifdef _PGPPATH - else if (strncmp ("Pgp:", tmp->data, 4) == 0) + else if (mutt_strncmp ("Pgp:", tmp->data, 4) == 0) { hdr->pgp = mutt_parse_pgp_hdr (tmp->data+4, 1); @@ -412,7 +412,7 @@ int mutt_prepare_edit_message (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr) hdr->content->parts = mutt_parse_multipart (msg->fp, mutt_get_parameter ("boundary", hdr->content->parameter), hdr->content->offset + hdr->content->length, - strcasecmp ("digest", hdr->content->subtype) == 0); + mutt_strcasecmp ("digest", hdr->content->subtype) == 0); } else hdr->content->parts = mutt_parse_messageRFC822 (msg->fp, hdr->content); diff --git a/protos.h b/protos.h index e296cd5e2..e033b58d5 100644 --- a/protos.h +++ b/protos.h @@ -264,6 +264,10 @@ int mutt_save_message (HEADER *, int, int, int, int *); int mutt_search_command (int, int); int mutt_compose_menu (HEADER *, char *, size_t, HEADER *); int mutt_strcmp (const char *, const char *); +int mutt_strcasecmp (const char *, const char *); +int mutt_strncmp (const char *, const char *, size_t); +int mutt_strncasecmp (const char *, const char *, size_t); +size_t mutt_strlen (const char *); int mutt_thread_set_flag (HEADER *, int, int, int); int mutt_user_is_recipient (HEADER *); int mutt_view_attachment (FILE*, BODY *, int); diff --git a/query.c b/query.c index a606ff476..f2265e00a 100644 --- a/query.c +++ b/query.c @@ -108,7 +108,7 @@ static QUERY *run_query (char *s, int quiet) p = strtok(buf, "\t\n"); if (p) { - l = strlen (p); + l = mutt_strlen (p); if (l > SecondColumn) SecondColumn = l; @@ -116,7 +116,7 @@ static QUERY *run_query (char *s, int quiet) p = strtok(NULL, "\t\n"); if (p) { - l = strlen (p); + l = mutt_strlen (p); if (l > FirstColumn) FirstColumn = l; cur->name = safe_strdup (p); @@ -432,14 +432,14 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) { tagged = 1; rfc822_write_address (buf, buflen, result_to_addr(QueryTable[i].data)); - curpos = strlen (buf); + curpos = mutt_strlen (buf); } else if (curpos + 2 < buflen) { strcat (buf, ", "); rfc822_write_address ((char *) buf + curpos + 1, buflen - curpos - 1, result_to_addr(QueryTable[i].data)); - curpos = strlen (buf); + curpos = mutt_strlen (buf); } } } diff --git a/recvattach.c b/recvattach.c index 25fdb403c..f3899c4c4 100644 --- a/recvattach.c +++ b/recvattach.c @@ -78,7 +78,7 @@ void mutt_update_tree (ATTACHPTR **idx, short idxlen) if (idx[x]->tree) { - if (strcmp (idx[x]->tree, buf) != 0) + if (mutt_strcmp (idx[x]->tree, buf) != 0) { safe_free ((void **) &idx[x]->tree); idx[x]->tree = safe_strdup (buf); @@ -262,7 +262,7 @@ int mutt_is_message_type (int type, const char *subtype) return 0; subtype = NONULL(subtype); - return (strcasecmp (subtype, "rfc822") == 0 || strcasecmp (subtype, "news") == 0); + return (mutt_strcasecmp (subtype, "rfc822") == 0 || mutt_strcasecmp (subtype, "news") == 0); } static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr) @@ -494,8 +494,8 @@ static int can_print (BODY *top, int tag) { if (!rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) { - if (strcasecmp ("text/plain", top->subtype) && - strcasecmp ("application/postscript", top->subtype)) + if (mutt_strcasecmp ("text/plain", top->subtype) && + mutt_strcasecmp ("application/postscript", top->subtype)) { if (!mutt_can_decode (top)) { @@ -525,8 +525,8 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top) snprintf (type, sizeof (type), "%s/%s", TYPE (top), top->subtype); if (!option (OPTATTACHSPLIT) && !rfc1524_mailcap_lookup (top, type, NULL, M_PRINT)) { - if (!strcasecmp ("text/plain", top->subtype) || - !strcasecmp ("application/postscript", top->subtype)) + if (!mutt_strcasecmp ("text/plain", top->subtype) || + !mutt_strcasecmp ("application/postscript", top->subtype)) pipe_attachment (fp, top); else if (mutt_can_decode (top)) { diff --git a/rfc1524.c b/rfc1524.c index 5636549d7..dd46d968d 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -207,10 +207,10 @@ static int rfc1524_mailcap_parse (BODY *a, /* check type */ ch = get_field (buf); - if (strcasecmp (buf, type) && - (strncasecmp (buf, type, btlen) || + if (mutt_strcasecmp (buf, type) && + (mutt_strncasecmp (buf, type, btlen) || (buf[btlen] != 0 && /* implicit wild */ - strcmp (buf + btlen, "/*")))) /* wildsubtype */ + mutt_strcmp (buf + btlen, "/*")))) /* wildsubtype */ continue; /* next field is the viewcommand */ @@ -232,53 +232,53 @@ static int rfc1524_mailcap_parse (BODY *a, ch = get_field (ch); dprint (2, (debugfile, "field: %s\n", field)); - if (!strcasecmp (field, "needsterminal")) + if (!mutt_strcasecmp (field, "needsterminal")) { if (entry) entry->needsterminal = TRUE; } - else if (!strcasecmp (field, "copiousoutput")) + else if (!mutt_strcasecmp (field, "copiousoutput")) { copiousoutput = TRUE; if (entry) entry->copiousoutput = TRUE; } - else if (!strncasecmp (field, "composetyped", 12)) + else if (!mutt_strncasecmp (field, "composetyped", 12)) { /* this compare most occur before compose to match correctly */ if (get_field_text (field + 12, entry ? &entry->composetypecommand : NULL, type, filename, line)) composecommand = TRUE; } - else if (!strncasecmp (field, "compose", 7)) + else if (!mutt_strncasecmp (field, "compose", 7)) { if (get_field_text (field + 7, entry ? &entry->composecommand : NULL, type, filename, line)) composecommand = TRUE; } - else if (!strncasecmp (field, "print", 5)) + else if (!mutt_strncasecmp (field, "print", 5)) { if (get_field_text (field + 5, entry ? &entry->printcommand : NULL, type, filename, line)) printcommand = TRUE; } - else if (!strncasecmp (field, "edit", 4)) + else if (!mutt_strncasecmp (field, "edit", 4)) { if (get_field_text (field + 4, entry ? &entry->editcommand : NULL, type, filename, line)) editcommand = TRUE; } - else if (!strncasecmp (field, "nametemplate", 12)) + else if (!mutt_strncasecmp (field, "nametemplate", 12)) { get_field_text (field + 12, entry ? &entry->nametemplate : NULL, type, filename, line); } - else if (!strncasecmp (field, "x-convert", 9)) + else if (!mutt_strncasecmp (field, "x-convert", 9)) { get_field_text (field + 9, entry ? &entry->convert : NULL, type, filename, line); } - else if (!strncasecmp (field, "test", 4)) + else if (!mutt_strncasecmp (field, "test", 4)) { /* * This routine executes the given test command to determine @@ -290,7 +290,7 @@ static int rfc1524_mailcap_parse (BODY *a, if (get_field_text (field + 4, &test_command, type, filename, line) && test_command) { - len = strlen (test_command) + STRING; + len = mutt_strlen (test_command) + STRING; safe_realloc ((void **) &test_command, len); rfc1524_expand_command (a, NULL, type, test_command, len); if (mutt_system (test_command)) @@ -451,7 +451,7 @@ void mutt_adv_mktemp (char *s, size_t l) if (period != NULL) { *period = '.'; - sl = strlen(s); + sl = mutt_strlen(s); strfcpy(s + sl, period, l - sl); } } @@ -548,7 +548,7 @@ int rfc1524_expand_filename (char *nametemplate, rmatch = 1; - for(r = 0, j = strlen(oldfile) - 1, k = strlen(nametemplate) - 1 ; + for(r = 0, j = mutt_strlen(oldfile) - 1, k = mutt_strlen(nametemplate) - 1 ; j >= (lmatch ? i : 0) && k >= i + 2; j--, k--) { diff --git a/rfc2047.c b/rfc2047.c index 5a21399c7..72ea1fd9c 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -37,8 +37,8 @@ static void q_encode_string (char *d, size_t dlen, const unsigned char *s) char *wptr = d; snprintf (charset, sizeof (charset), "=?%s?Q?", - strcasecmp ("us-ascii", NONULL(Charset)) == 0 ? "unknown-8bit" : NONULL(Charset)); - cslen = strlen (charset); + mutt_strcasecmp ("us-ascii", Charset) == 0 ? "unknown-8bit" : NONULL(Charset)); + cslen = mutt_strlen (charset); strcpy (wptr, charset); wptr += cslen; @@ -113,7 +113,7 @@ static void b_encode_string (char *d, size_t dlen, const unsigned char *s) int wordlen; snprintf (charset, sizeof (charset), "=?%s?B?", NONULL(Charset)); - cslen = strlen (charset); + cslen = mutt_strlen (charset); strcpy (wptr, charset); wptr += cslen; wordlen = cslen; @@ -190,13 +190,13 @@ void rfc2047_encode_string (char *d, size_t dlen, const unsigned char *s) return; } - if (strcasecmp("us-ascii", NONULL(Charset)) == 0 || - strncasecmp("iso-8859", NONULL(Charset), 8) == 0) + if (mutt_strcasecmp("us-ascii", Charset) == 0 || + mutt_strncasecmp("iso-8859", Charset, 8) == 0) encoder = q_encode_string; else { /* figure out which encoding generates the most compact representation */ - len = strlen ((char *) s); + len = mutt_strlen ((char *) s); if ((count * 2) + len <= (4 * len) / 3) encoder = q_encode_string; else @@ -205,14 +205,14 @@ void rfc2047_encode_string (char *d, size_t dlen, const unsigned char *s) /* Hack to pull the Re: and Fwd: out of the encoded word for better handling by agents which do not support RFC2047. */ - if (!strncasecmp ("re: ", (char *) s, 4)) + if (!mutt_strncasecmp ("re: ", (char *) s, 4)) { strncpy (d, (char *) s, 4); d += 4; dlen -= 4; s += 4; } - else if (!strncasecmp ("fwd: ", (char *) s, 5)) + else if (!mutt_strncasecmp ("fwd: ", (char *) s, 5)) { strncpy (d, (char *) s, 5); d += 5; @@ -254,7 +254,7 @@ static int rfc2047_decode_word (char *d, const char *s, size_t len) switch (count) { case 2: - if (strcasecmp (pp, NONULL(Charset)) != 0) + if (mutt_strcasecmp (pp, Charset) != 0) { filter = 1; charset = pp; @@ -388,7 +388,7 @@ void rfc2047_decode (char *d, const char *s, size_t dlen) rfc2047_decode_word (d, p, dlen); found_encoded = 1; s = q + 2; - n = strlen (d); + n = mutt_strlen (d); dlen -= n; d += n; } @@ -400,7 +400,7 @@ void rfc2047_decode_adrlist (ADDRESS *a) while (a) { if (a->personal && strstr (a->personal, "=?") != NULL) - rfc2047_decode (a->personal, a->personal, strlen (a->personal) + 1); + rfc2047_decode (a->personal, a->personal, mutt_strlen (a->personal) + 1); a = a->next; } } diff --git a/rfc822.c b/rfc822.c index c8dd104ec..0eaaa913e 100644 --- a/rfc822.c +++ b/rfc822.c @@ -485,7 +485,7 @@ void rfc822_qualify (ADDRESS *addr, const char *host) for (; addr; addr = addr->next) if (!addr->group && addr->mailbox && strchr (addr->mailbox, '@') == NULL) { - p = safe_malloc (strlen (addr->mailbox) + strlen (host) + 2); + p = safe_malloc (mutt_strlen (addr->mailbox) + mutt_strlen (host) + 2); sprintf (p, "%s@%s", addr->mailbox, host); safe_free ((void **) &addr->mailbox); addr->mailbox = p; @@ -536,7 +536,7 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr) if (!buflen) goto done; strfcpy (pbuf, addr->val, buflen); - len = strlen (pbuf); + len = mutt_strlen (pbuf); pbuf += len; buflen -= len; if (addr->group) @@ -583,7 +583,7 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr) if (!buflen) goto done; strfcpy (pbuf, addr->personal, buflen); - len = strlen (pbuf); + len = mutt_strlen (pbuf); pbuf += len; buflen -= len; } @@ -607,7 +607,7 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr) if (!buflen) goto done; strfcpy (pbuf, addr->mailbox, buflen); - len = strlen (pbuf); + len = mutt_strlen (pbuf); pbuf += len; buflen -= len; @@ -648,7 +648,7 @@ done: void rfc822_write_address (char *buf, size_t buflen, ADDRESS *addr) { char *pbuf = buf; - size_t len = strlen (buf); + size_t len = mutt_strlen (buf); buflen--; /* save room for the terminal nul */ @@ -677,7 +677,7 @@ void rfc822_write_address (char *buf, size_t buflen, ADDRESS *addr) /* this should be safe since we always have at least 1 char passed into the above call, which means `pbuf' should always be nul terminated */ - len = strlen (pbuf); + len = mutt_strlen (pbuf); pbuf += len; buflen -= len; diff --git a/score.c b/score.c index 12d6bd2e0..4c818a203 100644 --- a/score.c +++ b/score.c @@ -87,7 +87,7 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) /* look for an existing entry and update the value, else add it to the end of the list */ for (ptr = Score, last = NULL; ptr; last = ptr, ptr = ptr->next) - if (strcmp (pattern, ptr->str) == 0) + if (mutt_strcmp (pattern, ptr->str) == 0) break; if (!ptr) { @@ -143,7 +143,7 @@ int mutt_parse_unscore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) while (MoreArgs (s)) { mutt_extract_token (buf, s, 0); - if (!strcmp ("*", buf->data)) + if (!mutt_strcmp ("*", buf->data)) { for (tmp = Score; tmp; ) { @@ -158,7 +158,7 @@ int mutt_parse_unscore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) { for (tmp = Score; tmp; last = tmp, tmp = tmp->next) { - if (!strcmp (buf->data, tmp->str)) + if (!mutt_strcmp (buf->data, tmp->str)) { if (last) last->next = tmp->next; diff --git a/send.c b/send.c index 86cd2d5b2..f34e62eed 100644 --- a/send.c +++ b/send.c @@ -62,7 +62,7 @@ static int mutt_addrcmp (ADDRESS *a, ADDRESS *b) { if (!a->mailbox || !b->mailbox) return 0; - if (strcasecmp (a->mailbox, b->mailbox)) + if (mutt_strcasecmp (a->mailbox, b->mailbox)) return 0; return 1; } @@ -217,7 +217,7 @@ static int edit_envelope (ENVELOPE *en) buf[0] = 0; for (; uh; uh = uh->next) { - if (strncasecmp ("subject:", uh->data, 8) == 0) + if (mutt_strncasecmp ("subject:", uh->data, 8) == 0) { p = uh->data + 8; SKIPWS (p); @@ -244,11 +244,11 @@ static void process_user_recips (ENVELOPE *env) for (; uh; uh = uh->next) { - if (strncasecmp ("to:", uh->data, 3) == 0) + if (mutt_strncasecmp ("to:", uh->data, 3) == 0) env->to = rfc822_parse_adrlist (env->to, uh->data + 3); - else if (strncasecmp ("cc:", uh->data, 3) == 0) + else if (mutt_strncasecmp ("cc:", uh->data, 3) == 0) env->cc = rfc822_parse_adrlist (env->cc, uh->data + 3); - else if (strncasecmp ("bcc:", uh->data, 4) == 0) + else if (mutt_strncasecmp ("bcc:", uh->data, 4) == 0) env->bcc = rfc822_parse_adrlist (env->bcc, uh->data + 4); } } @@ -264,21 +264,21 @@ static void process_user_header (ENVELOPE *env) for (; uh; uh = uh->next) { - if (strncasecmp ("from:", uh->data, 5) == 0) + if (mutt_strncasecmp ("from:", uh->data, 5) == 0) { /* User has specified a default From: address. Remove default address */ rfc822_free_address (&env->from); env->from = rfc822_parse_adrlist (env->from, uh->data + 5); } - else if (strncasecmp ("reply-to:", uh->data, 9) == 0) + else if (mutt_strncasecmp ("reply-to:", uh->data, 9) == 0) { rfc822_free_address (&env->reply_to); env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9); } - else if (strncasecmp ("to:", uh->data, 3) != 0 && - strncasecmp ("cc:", uh->data, 3) != 0 && - strncasecmp ("bcc:", uh->data, 4) != 0 && - strncasecmp ("subject:", uh->data, 8) != 0) + else if (mutt_strncasecmp ("to:", uh->data, 3) != 0 && + mutt_strncasecmp ("cc:", uh->data, 3) != 0 && + mutt_strncasecmp ("bcc:", uh->data, 4) != 0 && + mutt_strncasecmp ("subject:", uh->data, 8) != 0) { if (last) { @@ -556,7 +556,7 @@ envelope_defaults (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, int flags) if (curenv->real_subj) { - env->subject = safe_malloc (strlen (curenv->real_subj) + 5); + env->subject = safe_malloc (mutt_strlen (curenv->real_subj) + 5); sprintf (env->subject, "Re: %s", curenv->real_subj); } else @@ -776,7 +776,7 @@ static ADDRESS *mutt_default_from (void) if (option (OPTUSEDOMAIN)) { - adr->mailbox = safe_malloc (strlen (NONULL(Username)) + strlen (NONULL(fqdn)) + 2); + adr->mailbox = safe_malloc (mutt_strlen (Username) + mutt_strlen (fqdn) + 2); sprintf (adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn)); } else @@ -1027,7 +1027,7 @@ ci_send_message (int flags, /* send mode */ if (generate_body (tempfp, msg, flags, ctx, cur) == -1) goto cleanup; - if (! (flags & (SENDMAILX | SENDKEY)) && Editor && strcmp (Editor, "builtin") != 0) + if (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0) append_signature (tempfp); } /* wait until now to set the real name portion of our return address so @@ -1079,7 +1079,7 @@ ci_send_message (int flags, /* send mode */ { if (mutt_needs_mailcap (msg->content)) mutt_edit_attachment (msg->content); - else if (!Editor || strcmp ("builtin", Editor) == 0) + else if (!Editor || mutt_strcmp ("builtin", Editor) == 0) mutt_builtin_editor (msg->content->filename, msg, cur); else if (option (OPTEDITHDRS)) mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc)); @@ -1223,7 +1223,7 @@ main_loop: /* save a copy of the message, if necessary. */ mutt_expand_path (fcc, sizeof (fcc)); - if (*fcc && strcmp ("/dev/null", fcc) != 0) + if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0) { BODY *tmpbody = msg->content; #ifdef _PGPPATH @@ -1235,8 +1235,8 @@ main_loop: if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART) { #ifdef _PGPPATH - if (strcmp (msg->content->subtype, "encrypted") == 0 || - strcmp (msg->content->subtype, "signed") == 0) + if (mutt_strcmp (msg->content->subtype, "encrypted") == 0 || + mutt_strcmp (msg->content->subtype, "signed") == 0) { if (save_content->type == TYPEMULTIPART) { diff --git a/sendlib.c b/sendlib.c index 11170c3ea..3e685aba7 100644 --- a/sendlib.c +++ b/sendlib.c @@ -125,7 +125,7 @@ static void encode_quoted (FILE * fin, FILE *fout, int istext) while ((c = fgetc (fin)) != EOF) { /* Escape lines that begin with "the message separator". */ - if (linelen == 5 && !strncmp ("From ", line, 5)) + if (linelen == 5 && !mutt_strncmp ("From ", line, 5)) { strfcpy (line, "=46rom ", sizeof (line)); linelen = 7; @@ -391,7 +391,7 @@ int mutt_write_mime_header (BODY *a, FILE *f) if (a->parameter) { - len = 25 + strlen (a->subtype); /* approximate len. of content-type */ + len = 25 + mutt_strlen (a->subtype); /* approximate len. of content-type */ for(p = a->parameter; p; p = p->next) { @@ -404,7 +404,7 @@ int mutt_write_mime_header (BODY *a, FILE *f) buffer[0] = 0; rfc822_cat (buffer, sizeof (buffer), p->value, MimeSpecials); - tmplen = strlen (buffer) + strlen (p->attribute) + 1; + tmplen = mutt_strlen (buffer) + mutt_strlen (p->attribute) + 1; if (len + tmplen + 2 > 76) { @@ -494,7 +494,7 @@ int mutt_write_mime_body (BODY *a, FILE *f) #ifdef _PGPPATH /* This is pretty gross, but it's the best solution for now... */ - if (a->type == TYPEAPPLICATION && strcmp (a->subtype, "pgp-encrypted") == 0) + if (a->type == TYPEAPPLICATION && mutt_strcmp (a->subtype, "pgp-encrypted") == 0) { fputs ("Version: 1\n", f); return 0; @@ -667,7 +667,7 @@ static int lookup_mime_type (char *d, const char *s) *d = 0; cur_n = TYPEOTHER; cur_sze = 0; - szf = strlen (s); + szf = mutt_strlen (s); for (count = 0 ; count < 3 ; count++) { @@ -711,9 +711,9 @@ static int lookup_mime_type (char *d, const char *s) /* cycle through the file extensions */ while ((p = strtok (p, " \t\n"))) { - sze = strlen (p); + sze = mutt_strlen (p); if ((sze > cur_sze) && (szf >= sze) && - strcasecmp (s + szf - sze, p) == 0 && + mutt_strcasecmp (s + szf - sze, p) == 0 && (szf == sze || s[szf - sze - 1] == '.')) { char *dc; @@ -750,7 +750,7 @@ static char *set_text_charset (CONTENT *info) /* if charset is unknown assume low bytes are ascii compatible */ - if ((Charset == NULL || strcasecmp (Charset, "us-ascii") == 0) + if ((Charset == NULL || mutt_strcasecmp (Charset, "us-ascii") == 0) && info->hibin) return ("unknown-8bit"); @@ -848,7 +848,7 @@ static void transform_to_7bit (BODY *a, FILE *fpin) transform_to_7bit (a->parts, fpin); } - else if (a->type == TYPEMESSAGE && strcasecmp (a->subtype, "delivery-status")) + else if (a->type == TYPEMESSAGE && mutt_strcasecmp (a->subtype, "delivery-status")) { mutt_message_to_7bit (a, fpin); } @@ -1190,7 +1190,7 @@ void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen) adr->next = NULL; buf[0] = 0; rfc822_write_address (buf, sizeof (buf), adr); - len = strlen (buf); + len = mutt_strlen (buf); if (count && linelen + len > 74) { if (count) @@ -1381,7 +1381,7 @@ static void encode_headers (LIST *h) *p++ = 0; SKIPWS (p); snprintf (tmp, sizeof (tmp), "%s: ", h->data); - len = strlen (tmp); + len = mutt_strlen (tmp); rfc2047_encode_string (tmp + len, sizeof (tmp) - len, (unsigned char *) p); safe_free ((void **) &h->data); h->data = safe_strdup (tmp); @@ -1721,8 +1721,8 @@ mutt_invoke_sendmail (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc, /* recips */ string. */ char *mutt_append_string (char *a, const char *b) { - size_t la = strlen (a); - safe_realloc ((void **) &a, la + strlen (b) + 1); + size_t la = mutt_strlen (a); + safe_realloc ((void **) &a, la + mutt_strlen (b) + 1); strcpy (a + la, b); return (a); } @@ -1751,7 +1751,7 @@ char *mutt_quote_string (const char *s) char *r, *pr; size_t rlen; - rlen = strlen (s) + 3; + rlen = mutt_strlen (s) + 3; pr = r = (char *) safe_malloc (rlen); *pr++ = '"'; while (*s) @@ -1868,7 +1868,7 @@ ADDRESS *mutt_remove_duplicates (ADDRESS *addr) tmp = top; do { if (addr->mailbox && tmp->mailbox && - !strcasecmp (addr->mailbox, tmp->mailbox)) + !mutt_strcasecmp (addr->mailbox, tmp->mailbox)) { /* duplicate address, just ignore it */ tmp = addr; diff --git a/snprintf.c b/snprintf.c index 4b9ef9d8b..fcb467383 100644 --- a/snprintf.c +++ b/snprintf.c @@ -383,7 +383,7 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, value = ""; } - for (strln = 0; value[strln]; ++strln); /* strlen */ + for (strln = 0; value[strln]; ++strln); /* mutt_strlen */ padlen = min - strln; if (padlen < 0) padlen = 0; @@ -684,7 +684,7 @@ int vsnprintf (char *str, size_t count, const char *fmt, va_list args) { str[0] = 0; dopr(str, count, fmt, args); - return(strlen(str)); + return(mutt_strlen(str)); } #endif /* !HAVE_VSNPRINTF */ @@ -709,7 +709,7 @@ int snprintf (va_alist) va_dcl VA_SHIFT (fmt, char *); (void) vsnprintf(str, count, fmt, ap); VA_END; - return(strlen(str)); + return(mutt_strlen(str)); } #ifdef TEST_SNPRINTF @@ -760,7 +760,7 @@ int main (void) { snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); sprintf (buf2, fp_fmt[x], fp_nums[y]); - if (strcmp (buf1, buf2)) + if (mutt_strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", fp_fmt[x], buf1, buf2); @@ -774,7 +774,7 @@ int main (void) { snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]); sprintf (buf2, int_fmt[x], int_nums[y]); - if (strcmp (buf1, buf2)) + if (mutt_strcmp (buf1, buf2)) { printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", int_fmt[x], buf1, buf2); diff --git a/socket.c b/socket.c index 1d0330193..8937d5ba0 100644 --- a/socket.c +++ b/socket.c @@ -77,7 +77,7 @@ int mutt_socket_read_line_d (char *buf, size_t buflen, CONNECTION *conn) int mutt_socket_write (CONNECTION *conn, const char *buf) { dprint (1,(debugfile,"mutt_socket_write():%s", buf)); - return (write (conn->fd, buf, strlen (buf))); + return (write (conn->fd, buf, mutt_strlen (buf))); } CONNECTION *mutt_socket_select_connection (char *host, int port, int flags) @@ -89,7 +89,7 @@ CONNECTION *mutt_socket_select_connection (char *host, int port, int flags) conn = Connections; while (conn) { - if (!strcmp (host, conn->server) && (port == conn->port)) + if (!mutt_strcmp (host, conn->server) && (port == conn->port)) return conn; conn = conn->next; } diff --git a/sort.c b/sort.c index 17898ecc2..2370e425f 100644 --- a/sort.c +++ b/sort.c @@ -79,7 +79,7 @@ int compare_subject (const void *a, const void *b) else if (!(*pb)->env->real_subj) rc = 1; else - rc = strcasecmp ((*pa)->env->real_subj, (*pb)->env->real_subj); + rc = mutt_strcasecmp ((*pa)->env->real_subj, (*pb)->env->real_subj); AUXSORT(rc,a,b); return (SORTCODE (rc)); } @@ -110,7 +110,7 @@ int compare_to (const void *a, const void *b) fa = mutt_get_name ((*ppa)->env->to); fb = mutt_get_name ((*ppb)->env->to); - result = strcasecmp (fa, fb); + result = mutt_strcasecmp (fa, fb); AUXSORT(result,a,b); return (SORTCODE (result)); } @@ -124,7 +124,7 @@ int compare_from (const void *a, const void *b) fa = mutt_get_name ((*ppa)->env->from); fb = mutt_get_name ((*ppb)->env->from); - result = strcasecmp (fa, fb); + result = mutt_strcasecmp (fa, fb); AUXSORT(result,a,b); return (SORTCODE (result)); } diff --git a/status.c b/status.c index beffbc961..a84b8a9ba 100644 --- a/status.c +++ b/status.c @@ -211,7 +211,7 @@ status_format_str (char *buf, size_t buflen, char op, const char *src, if (!StChars) buf[0] = 0; - else if (i >= strlen(StChars)) + else if (i >= mutt_strlen(StChars)) buf[0] = StChars[0]; else buf[0] = StChars[i]; diff --git a/strcasecmp.c b/strcasecmp.c index 1a92bc36f..8c582d760 100644 --- a/strcasecmp.c +++ b/strcasecmp.c @@ -4,7 +4,7 @@ static const char rcsid[]="$Id$"; /* UnixWare doesn't have these functions in its standard C library */ -int strncasecmp (char *s1, char *s2, size_t n) +int mutt_strncasecmp (char *s1, char *s2, size_t n) { register int c1, c2, l = 0; @@ -21,7 +21,7 @@ int strncasecmp (char *s1, char *s2, size_t n) return (int) (0); } -int strcasecmp (char *s1, char *s2) +int mutt_strcasecmp (char *s1, char *s2) { register int c1, c2; diff --git a/thread.c b/thread.c index da92cfc2f..3b6e7be05 100644 --- a/thread.c +++ b/thread.c @@ -292,7 +292,7 @@ static HEADER *find_subject (CONTEXT *ctx, HEADER *cur) cur->date_sent >= tmp->date_sent && (!last || (last->date_sent <= tmp->date_sent)) && tmp->env->real_subj && - strcmp (env->real_subj, tmp->env->real_subj) == 0) + mutt_strcmp (env->real_subj, tmp->env->real_subj) == 0) { last = tmp; /* best match so far */ } @@ -443,14 +443,14 @@ static void move_descendants (HEADER **tree, HEADER *cur, sort_t *usefunc) { /* only need to look at the last reference */ if (tmp->env->references && - strcmp (tmp->env->references->data, cur->env->message_id) == 0) + mutt_strcmp (tmp->env->references->data, cur->env->message_id) == 0) { /* remove message from current location */ unlink_message (tree, tmp); tmp->parent = cur; if (cur->env->real_subj && tmp->env->real_subj) - tmp->subject_changed = strcmp (tmp->env->real_subj, cur->env->real_subj) ? 1 : 0; + tmp->subject_changed = mutt_strcmp (tmp->env->real_subj, cur->env->real_subj) ? 1 : 0; else tmp->subject_changed = (cur->env->real_subj || tmp->env->real_subj) ? 1 : 0; tmp->fake_thread = 0; /* real reference */ @@ -541,7 +541,7 @@ void mutt_sort_threads (CONTEXT *ctx, int init) { CUR->parent = tmp; if (CUR->env->real_subj && tmp->env->real_subj) - CUR->subject_changed = strcmp (tmp->env->real_subj, CUR->env->real_subj) ? 1 : 0; + CUR->subject_changed = mutt_strcmp (tmp->env->real_subj, CUR->env->real_subj) ? 1 : 0; else CUR->subject_changed = (CUR->env->real_subj || tmp->env->real_subj) ? 1 : 0; }