X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=curs_lib.c;h=ddac70ba799ef830f5a0acd5aa1180e1cd106461;hp=46f6d307290cddd4c4105b873351aaf671587ff9;hb=1dc7032b59cc5b91d70076ed228bda8caf65a7f3;hpb=b25e26b05ff3172041861e032cb839871367a480 diff --git a/curs_lib.c b/curs_lib.c index 46f6d30..ddac70b 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -15,6 +15,9 @@ # include "config.h" #endif +#include +#include + #include "mutt.h" #include "enter.h" #include "mutt_menu.h" @@ -22,11 +25,10 @@ #include "pager.h" #include "mbyte.h" -#include "lib/mem.h" -#include "lib/intl.h" #include "lib/str.h" #include "lib/debug.h" +#include #include #include #include @@ -114,7 +116,7 @@ event_t mutt_getch (void) 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; @@ -156,19 +158,6 @@ void mutt_clear_error (void) 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]; @@ -177,7 +166,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); - fix_end_of_file (data); keypad (stdscr, TRUE); clearok (stdscr, TRUE); } @@ -214,12 +202,12 @@ int mutt_yesorno (const char *msg, int def) * 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); answer_string_len = str_len (answer_string); printw ("%.*s%s", COLS - answer_string_len, msg, answer_string); - mem_free (&answer_string); + p_delete(&answer_string); FOREVER { mutt_refresh (); @@ -318,8 +306,9 @@ void mutt_progress_bar (progress_t* progress, long pos) { if (!NetInc) mutt_message (progress->msg); else { - mutt_pretty_size (progress->sizestr, sizeof (progress->sizestr), - progress->size); + if (progress->size) + mutt_pretty_size (progress->sizestr, sizeof (progress->sizestr), + progress->size); progress->pos = 0; } } @@ -331,7 +320,10 @@ void mutt_progress_bar (progress_t* progress, long pos) { progress->pos = pos; pos = pos / (NetInc << 10) * (NetInc << 10); mutt_pretty_size (posstr, sizeof (posstr), pos); - mutt_message ("%s %s/%s", progress->msg, posstr, progress->sizestr); + if (progress->size) + mutt_message ("%s %s/%s", progress->msg, posstr, progress->sizestr); + else + mutt_message ("%s %s", progress->msg, posstr); } } #endif @@ -473,7 +465,7 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, *redraw = REDRAW_FULL; } else { - char *pc = mem_malloc (str_len (prompt) + 3); + char *pc = p_new(char, str_len(prompt) + 3); sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */ mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); @@ -483,7 +475,7 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, != 0) buf[0] = 0; MAYBE_REDRAW (*redraw); - mem_free (&pc); + p_delete(&pc); } return 0; @@ -497,7 +489,7 @@ void mutt_ungetch (int ch, int op) tmp.op = op; if (UngetCount >= UngetBufLen) - mem_realloc (&KeyEvent, (UngetBufLen += 128) * sizeof (event_t)); + p_realloc(&KeyEvent, UngetBufLen += 128); KeyEvent[UngetCount++] = tmp; }