#endif
#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
#include <lib-lib/macros.h>
+#include <lib-lib/file.h>
#include "mutt.h"
#include "enter.h"
#include "pager.h"
#include "mbyte.h"
-#include "lib/str.h"
#include "lib/debug.h"
#include <wchar.h>
answer_string = p_new(char, COLS + 1);
snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
def == M_YES ? no : yes);
- answer_string_len = str_len (answer_string);
+ answer_string_len = m_strlen(answer_string);
printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
p_delete(&answer_string);
- FOREVER {
+ for (;;) {
mutt_refresh ();
ch = mutt_getch ();
if (CI_is_return (ch.ch))
curs_set (1);
if (Timeout)
timeout (-1); /* restore blocking operation */
- if (mutt_yesorno (_("Exit Mutt-ng?"), M_YES) == M_YES) {
+ if (mutt_yesorno (_("Exit Madmutt?"), M_YES) == M_YES) {
mutt_endwin (NULL);
exit (1);
}
set_option (OPTMSGERR);
}
-#ifdef USE_SOCKET
void mutt_progress_bar (progress_t* progress, long pos) {
char posstr[SHORT_STRING];
mutt_message ("%s %s", progress->msg, posstr);
}
}
-#endif
void mutt_curses_message (const char *fmt, ...)
{
{
int rc;
- if (!Pager || str_cmp (Pager, "builtin") == 0)
+ if (!Pager || m_strcmp(Pager, "builtin") == 0)
rc = mutt_pager (banner, tempfile, do_color, info);
else {
char cmd[STRING];
*redraw = REDRAW_FULL;
}
else {
- char *pc = p_new(char, str_len(prompt) + 3);
+ char *pc = p_new(char, m_strlen(prompt) + 3);
sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */
mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
mvaddstr (LINES - 1, 0, prompt);
clrtoeol ();
- FOREVER {
+ for (;;) {
mutt_refresh ();
ch = mutt_getch ();
if (ch.ch == -1 || CI_is_return (ch.ch)) {
}
else if (ch.ch <= '9' && ch.ch > '0') {
choice = ch.ch - '0';
- if (choice <= str_len (letters))
+ if (choice <= m_strlen(letters))
break;
}
}
mbstate_t mbstate;
size_t n1, n2;
- memset (&mbstate, 0, sizeof (mbstate));
+ p_clear(&mbstate, 1);
if ((n1 = wcrtomb (buf, wc, &mbstate)) == (size_t) (-1) ||
(n2 = wcrtomb (buf + n1, 0, &mbstate)) == (size_t) (-1))
return -1; /* ERR */
* when printed.
*/
-void mutt_format_string (char *dest, size_t destlen,
+void mutt_format_string (char *dest, ssize_t destlen,
int min_width, int max_width,
int right_justify, char m_pad_char,
- const char *s, size_t n, int arboreal)
+ const char *s, ssize_t n, int arboreal)
{
char *p;
wchar_t wc;
char scratch[MB_LEN_MAX];
mbstate_t mbstate1, mbstate2;
- memset (&mbstate1, 0, sizeof (mbstate1));
- memset (&mbstate2, 0, sizeof (mbstate2));
+ p_clear(&mbstate1, 1);
+ p_clear(&mbstate2, 1);
--destlen;
p = dest;
for (; n && (k = mbrtowc (&wc, s, n, &mbstate1)); s += k, n -= k) {
destlen -= k2;
}
}
- w = (int) destlen < min_width ? destlen : min_width;
+ w = destlen < min_width ? destlen : min_width;
if (w <= 0)
*p = '\0';
else if (right_justify) {
}
mutt_format_string (dest, destlen, min_width, max_width,
- right_justify, ' ', s, str_len (s), arboreal);
+ right_justify, ' ', s, m_strlen(s), arboreal);
}
void mutt_format_s (char *dest,
wchar_t wc;
int w;
size_t k;
- size_t len = str_len (s);
+ size_t len = m_strlen(s);
mbstate_t mbstate;
- memset (&mbstate, 0, sizeof (mbstate));
+ p_clear(&mbstate, 1);
for (; len && (k = mbrtowc (&wc, s, len, &mbstate)); s += k, len -= k) {
if (k == (size_t) (-1) || k == (size_t) (-2)) {
k = (k == (size_t) (-1)) ? 1 : len;
}
/*
- * mutt_strwidth is like str_len except that it returns the width
+ * mutt_strwidth is like m_strlenexcept that it returns the width
* refering to the number of characters cells.
*/
if (!s)
return 0;
- n = str_len (s);
+ n = m_strlen(s);
- memset (&mbstate, 0, sizeof (mbstate));
+ p_clear(&mbstate, 1);
for (w = 0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k) {
if (k == (size_t) (-1) || k == (size_t) (-2)) {
k = (k == (size_t) (-1)) ? 1 : n;