projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add more encoding arrays
[apps/madmutt.git]
/
curs_lib.c
diff --git
a/curs_lib.c
b/curs_lib.c
index
e73d4f5
..
3e9f31a
100644
(file)
--- a/
curs_lib.c
+++ b/
curs_lib.c
@@
-15,6
+15,11
@@
# include "config.h"
#endif
# include "config.h"
#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 "mutt_menu.h"
#include "mutt.h"
#include "enter.h"
#include "mutt_menu.h"
@@
-22,11
+27,9
@@
#include "pager.h"
#include "mbyte.h"
#include "pager.h"
#include "mbyte.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
#include "lib/debug.h"
#include "lib/debug.h"
+#include <wchar.h>
#include <termios.h>
#include <sys/types.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/types.h>
#include <fcntl.h>
@@
-114,7
+117,7
@@
event_t mutt_getch (void)
return (ch == ctrl ('G') ? err : ret);
}
return (ch == ctrl ('G') ? err : ret);
}
-int _mutt_get_field (
/* const */
char *field, char *buf, size_t buflen,
+int _mutt_get_field (
const
char *field, char *buf, size_t buflen,
int complete, int multiple, char ***files, int *numfiles)
{
int ret;
int complete, int multiple, char ***files, int *numfiles)
{
int ret;
@@
-156,19
+159,6
@@
void mutt_clear_error (void)
CLEARLINE (LINES - 1);
}
CLEARLINE (LINES - 1);
}
-static void fix_end_of_file (const char *data)
-{
- FILE *fp;
- int c;
-
- if ((fp = safe_fopen (data, "a+")) == NULL)
- return;
- fseek (fp, -1, SEEK_END);
- if ((c = fgetc (fp)) != '\n')
- fputc ('\n', fp);
- safe_fclose (&fp);
-}
-
void mutt_edit_file (const char *editor, const char *data)
{
char cmd[LONG_STRING];
void mutt_edit_file (const char *editor, const char *data)
{
char cmd[LONG_STRING];
@@
-177,7
+167,6
@@
void mutt_edit_file (const char *editor, const char *data)
mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
if (mutt_system (cmd) == -1)
mutt_error (_("Error running \"%s\"!"), cmd);
mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
if (mutt_system (cmd) == -1)
mutt_error (_("Error running \"%s\"!"), cmd);
- fix_end_of_file (data);
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
}
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
}
@@
-214,14
+203,14
@@
int mutt_yesorno (const char *msg, int def)
* ensure there is enough room for the answer and truncate the question
* to fit.
*/
* ensure there is enough room for the answer and truncate the question
* to fit.
*/
- answer_string =
mem_malloc (
COLS + 1);
+ answer_string =
p_new(char,
COLS + 1);
snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no,
def == M_YES ? no : yes);
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);
printw ("%.*s%s", COLS - answer_string_len, msg, answer_string);
-
mem_free
(&answer_string);
+
p_delete
(&answer_string);
-
FOREVER
{
+
for (;;)
{
mutt_refresh ();
ch = mutt_getch ();
if (CI_is_return (ch.ch))
mutt_refresh ();
ch = mutt_getch ();
if (CI_is_return (ch.ch))
@@
-432,7
+421,7
@@
int mutt_do_pager (const char *banner,
{
int rc;
{
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];
rc = mutt_pager (banner, tempfile, do_color, info);
else {
char cmd[STRING];
@@
-477,7
+466,7
@@
int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
*redraw = REDRAW_FULL;
}
else {
*redraw = REDRAW_FULL;
}
else {
- char *pc =
mem_malloc (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);
sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */
mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0);
@@
-487,7
+476,7
@@
int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
!= 0)
buf[0] = 0;
MAYBE_REDRAW (*redraw);
!= 0)
buf[0] = 0;
MAYBE_REDRAW (*redraw);
-
mem_free
(&pc);
+
p_delete
(&pc);
}
return 0;
}
return 0;
@@
-501,7
+490,7
@@
void mutt_ungetch (int ch, int op)
tmp.op = op;
if (UngetCount >= UngetBufLen)
tmp.op = op;
if (UngetCount >= UngetBufLen)
-
mem_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t)
);
+
p_realloc(&KeyEvent, UngetBufLen += 128
);
KeyEvent[UngetCount++] = tmp;
}
KeyEvent[UngetCount++] = tmp;
}
@@
-542,7
+531,7
@@
int mutt_multi_choice (char *prompt, char *letters)
mvaddstr (LINES - 1, 0, prompt);
clrtoeol ();
mvaddstr (LINES - 1, 0, prompt);
clrtoeol ();
-
FOREVER
{
+
for (;;)
{
mutt_refresh ();
ch = mutt_getch ();
if (ch.ch == -1 || CI_is_return (ch.ch)) {
mutt_refresh ();
ch = mutt_getch ();
if (ch.ch == -1 || CI_is_return (ch.ch)) {
@@
-557,7
+546,7
@@
int mutt_multi_choice (char *prompt, char *letters)
}
else if (ch.ch <= '9' && ch.ch > '0') {
choice = ch.ch - '0';
}
else if (ch.ch <= '9' && ch.ch > '0') {
choice = ch.ch - '0';
- if (choice <=
str_len
(letters))
+ if (choice <=
m_strlen
(letters))
break;
}
}
break;
}
}
@@
-578,7
+567,7
@@
int mutt_addwch (wchar_t wc)
mbstate_t mbstate;
size_t n1, n2;
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 */
if ((n1 = wcrtomb (buf, wc, &mbstate)) == (size_t) (-1) ||
(n2 = wcrtomb (buf + n1, 0, &mbstate)) == (size_t) (-1))
return -1; /* ERR */
@@
-606,8
+595,8
@@
void mutt_format_string (char *dest, size_t destlen,
char scratch[MB_LEN_MAX];
mbstate_t mbstate1, mbstate2;
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;
p = dest;
for (; n && (k = mbrtowc (&wc, s, n, &mbstate1)); s += k, n -= k) {
@@
-677,7
+666,7
@@
static void mutt_format_s_x (char *dest,
}
mutt_format_string (dest, destlen, min_width, max_width,
}
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,
}
void mutt_format_s (char *dest,
@@
-702,10
+691,10
@@
void mutt_paddstr (int n, const char *s)
wchar_t wc;
int w;
size_t k;
wchar_t wc;
int w;
size_t k;
- size_t len =
str_len
(s);
+ size_t len =
m_strlen
(s);
mbstate_t mbstate;
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;
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;
@@
-726,7
+715,7
@@
void mutt_paddstr (int n, const char *s)
}
/*
}
/*
- * mutt_strwidth is like
str_len
except that it returns the width
+ * mutt_strwidth is like
m_strlen
except that it returns the width
* refering to the number of characters cells.
*/
* refering to the number of characters cells.
*/
@@
-740,9
+729,9
@@
int mutt_strwidth (const char *s)
if (!s)
return 0;
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;
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;