if (list_empty(Incoming) || !path || !*path)
return (-1);
for (i = 0; i < Incoming->length; i++) {
- if (safe_strcmp (((BUFFY*) Incoming->data[i])->path, path) == 0)
+ if (str_eq (((BUFFY*) Incoming->data[i])->path, path) )
return (i);
}
return (-1);
mutt_extract_token (path, s, 0);
strfcpy (buf, path->data, sizeof (buf));
- if (data == M_UNMAILBOXES && safe_strcmp (buf, "*") == 0) {
+ if (data == M_UNMAILBOXES && str_eq (buf, "*") == 0) {
list_del (&Incoming, buffy_free);
return 0;
}
/* check to see if the folder is the currently selected folder
* before polling */
if (!Context || !Context->path || (local ? (sb.st_dev != contex_sb.st_dev ||
- sb.st_ino != contex_sb.st_ino) :
- safe_strcmp (tmp->path, Context->path))) {
+ sb.st_ino != contex_sb.st_ino) :
+ !str_eq (tmp->path, Context->path))) {
switch (tmp->magic) {
case M_MBOX:
case M_MMDF:
i = 1 + buffy_lookup (s);
for (l=0; l < Incoming->length; l++) {
c = (l+i) % Incoming->length;
- if (((BUFFY*) Incoming->data[c])->new > 0)
+ if ((!Context || !Context->path || !str_eq (((BUFFY*) Incoming->data[c])->path, Context->path)) &&
+ ((BUFFY*) Incoming->data[c])->new > 0)
break;
}
if (l >= Incoming->length) {
if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0
&& buf[0]) {
FREE (&msg->env->newsgroups);
- mutt_remove_trailing_ws (buf);
- msg->env->newsgroups = safe_strdup (mutt_skip_whitespace (buf));
+ str_skip_trailws (buf);
+ msg->env->newsgroups = safe_strdup (str_skip_initws (buf));
move (HDR_TO, HDR_XOFFSET);
clrtoeol ();
if (msg->env->newsgroups)
if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0
&& buf[0]) {
FREE (&msg->env->followup_to);
- mutt_remove_trailing_ws (buf);
- msg->env->followup_to = safe_strdup (mutt_skip_whitespace (buf));
+ str_skip_trailws (buf);
+ msg->env->followup_to = safe_strdup (str_skip_initws (buf));
move (HDR_CC, HDR_XOFFSET);
clrtoeol ();
if (msg->env->followup_to)
else
#endif
mutt_expand_path (buf, sizeof (buf));
- sidebar_set_current (buf);
if (mx_get_magic (buf) <= 0) {
mutt_error (_("%s is not a mailbox."), buf);
break;
}
else
menu->current = 0;
+ sidebar_set_current (buf);
#ifdef USE_NNTP
/* buffy_check() must be done with mail-reader mode! */
int i;
int nsup;
char ctmp;
- int nns;
+ int nns = 0;
char *cur_folder;
short showparents = 0;
int noselect;
if (mutt_bit_isset (idata->rights, ACL_WRITE))
imap_add_keywords (flags, hdr, idata->flags, sizeof (flags));
- mutt_remove_trailing_ws (flags);
+ str_skip_trailws (flags);
/* UW-IMAP is OK with null flags, Cyrus isn't. The only solution is to
* explicitly revoke all system flags (if we have permission) */
imap_set_flag (idata, ACL_WRITE, 1, "\\Answered ", flags, sizeof (flags));
imap_set_flag (idata, ACL_DELETE, 1, "\\Deleted ", flags, sizeof (flags));
- mutt_remove_trailing_ws (flags);
+ str_skip_trailws (flags);
mutt_buffer_addstr (cmd, " -FLAGS.SILENT (");
} else
char *mutt_concat_path (char *, const char *, const char *, size_t);
char *mutt_read_line (char *, size_t *, FILE *, int *);
-char *mutt_skip_whitespace (char *);
const char *mutt_basename (const char *);
size_t mutt_quote_filename (char *, size_t, const char *);
void mutt_nocurses_error (const char *, ...);
-void mutt_remove_trailing_ws (char *);
void mutt_sanitize_filename (char *, short);
void mutt_unlink (const char *);
return NULL;
}
-char *mutt_skip_whitespace (char *p)
-{
- SKIPWS (p);
- return p;
+int str_eq (const char* s1, const char* s2) {
+ int l = safe_strlen (s1);
+
+ if (l != safe_strlen (s2))
+ return (0);
+ return (safe_strncmp (s1, s2, l) == 0);
}
-void mutt_remove_trailing_ws (char *s)
-{
+char* str_skip_initws (char* s) {
+ SKIPWS (s);
+ return (s);
+}
+
+void str_skip_trailws (char *s) {
char *p;
for (p = s + safe_strlen (s) - 1; p >= s && ISSPACE (*p); p--)
char *str_substrdup (const char*, const char*);
void str_replace (char**, const char*);
void str_adjust (char**);
+int str_eq (const char*, const char*);
const char *str_isstr (const char*, const char*);
+char* str_skip_initws (char*);
+void str_skip_trailws (char*);
#endif /* !_LIB_STR_H */
mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
else {
mutt_socket_close (conn);
- mutt_remove_trailing_ws (buf);
+ str_skip_trailws (buf);
mutt_error ("%s", buf);
sleep (2);
return -1;
#ifdef USE_NNTP
else if (!safe_strcasecmp (line + 1, "ollowup-to")) {
if (!e->followup_to) {
- mutt_remove_trailing_ws (p);
- e->followup_to = safe_strdup (mutt_skip_whitespace (p));
+ str_skip_trailws (p);
+ e->followup_to = safe_strdup (str_skip_initws (p));
}
matched = 1;
}
case 'n':
if (!safe_strcasecmp (line + 1, "ewsgroups")) {
FREE (&e->newsgroups);
- mutt_remove_trailing_ws (p);
- e->newsgroups = safe_strdup (mutt_skip_whitespace (p));
+ str_skip_trailws (p);
+ e->newsgroups = safe_strdup (str_skip_initws (p));
matched = 1;
}
break;
break;
if (armor_header) {
- char *p = mutt_skip_whitespace (buf);
+ char *p = str_skip_initws (buf);
if (*p == '\0')
armor_header = 0;
FILE *f;
int index;
pop_query_status ret;
- cmd_status status;
long length;
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX];
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/debug.h"
+#include "lib/str.h"
#include <string.h>
#include <unistd.h>
}
strfcpy (t, c, sizeof (pop_data->err_msg) - strlen (pop_data->err_msg));
- mutt_remove_trailing_ws (pop_data->err_msg);
+ str_skip_trailws (pop_data->err_msg);
}
/* Parse CAPA output */
break;
}
}
- mutt_remove_trailing_ws (s);
+ str_skip_trailws (s);
return ch;
}
static int get_field_text (char *field, char **entry,
char *type, char *filename, int line)
{
- field = mutt_skip_whitespace (field);
+ field = str_skip_initws (field);
if (*field == '=') {
if (entry) {
field++;
- field = mutt_skip_whitespace (field);
+ field = str_skip_initws (field);
str_replace (entry, field);
}
return 1;
char tmp[SHORT_STRING];
BUFFY* b = (BUFFY*) Incoming->data[data];
int opt = flags & M_FORMAT_OPTIONAL;
- int c = Context && safe_strcmp (Context->path, b->path) == 0;
+ int c = Context && str_eq (Context->path, b->path);
switch (op) {
case 'c':
SidebarWidth = COLS;
if (option (OPTSIDEBARNEWMAILONLY) && box && Context && Context->path &&
- safe_strcmp (Context->path, box) != 0 &&
- ((BUFFY*) Incoming->data[idx])->new == 0)
+ !str_eq (Context->path, box) && ((BUFFY*) Incoming->data[idx])->new == 0)
/* if $sidebar_newmail_only is set, don't display the
* box only if it's not the currently opened
* (i.e. always display the currently opened) */