X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=curs_lib.c;h=d987b5167755ce10b7cea53fa04588c0a53fb6da;hp=0678d28ac327021bc2c67406a706a573c9bccc39;hb=9d2f1c9b6d2984bb6ee3e0a6c1709a678a801776;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/curs_lib.c b/curs_lib.c index 0678d28..d987b51 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -1,20 +1,14 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996-2002 Michael R. Elkins * Copyright (C) 2004 g10 Code GmbH - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * + * Parts were written/modified by: + * Nico Golde + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ #if HAVE_CONFIG_H @@ -27,6 +21,11 @@ #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 @@ -145,7 +144,7 @@ int mutt_get_password (char *msg, char *buf, size_t buflen) CLEARLINE (LINES - 1); addstr (msg); set_option (OPTUNBUFFEREDINPUT); - rc = mutt_enter_string (buf, buflen, LINES - 1, mutt_strlen (msg), M_PASS); + rc = mutt_enter_string (buf, buflen, LINES - 1, safe_strlen (msg), M_PASS); unset_option (OPTUNBUFFEREDINPUT); CLEARLINE (LINES - 1); return (rc); @@ -219,7 +218,7 @@ int mutt_yesorno (const char *msg, int def) answer_string = safe_malloc (COLS + 1); snprintf (answer_string, COLS + 1, " ([%s]/%s): ", def == M_YES ? yes : no, def == M_YES ? no : yes); - answer_string_len = strlen (answer_string); + answer_string_len = safe_strlen (answer_string); printw ("%.*s%s", COLS - answer_string_len, msg, answer_string); FREE (&answer_string); @@ -295,7 +294,7 @@ void mutt_curses_error (const char *fmt, ...) vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap); va_end (ap); - dprint (1, (debugfile, "%s\n", Errorbuf)); + debug_print (1, ("%s\n", Errorbuf)); mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf), 0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0); snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf); /* overkill */ @@ -363,13 +362,12 @@ void mutt_endwin (const char *msg) } } -void mutt_perror (const char *s) +void _mutt_perror (const char *s, const char* filename, int line) { char *p = strerror (errno); - dprint (1, (debugfile, "%s: %s (errno = %d)\n", s, - p ? p : "unknown error", errno)); - mutt_error ("%s: %s (errno = %d)", s, p ? p : _("unknown error"), errno); + debug_print (1, ("%s: %s (errno = %d)\n", s, p ? p : "unknown error", errno)); + mutt_error ("%s: %s (errno = %d) from %s:%i", s, p ? p : _("unknown error"), errno, filename, line); } int mutt_any_key_to_continue (const char *s) @@ -405,7 +403,7 @@ int mutt_do_pager (const char *banner, { int rc; - if (!Pager || mutt_strcmp (Pager, "builtin") == 0) + if (!Pager || safe_strcmp (Pager, "builtin") == 0) rc = mutt_pager (banner, tempfile, do_color, info); else { char cmd[STRING]; @@ -450,7 +448,7 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, *redraw = REDRAW_FULL; } else { - char *pc = safe_malloc (mutt_strlen (prompt) + 3); + char *pc = safe_malloc (safe_strlen (prompt) + 3); sprintf (pc, "%s: ", prompt); /* __SPRINTF_CHECKED__ */ mutt_ungetch (ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); @@ -530,7 +528,7 @@ int mutt_multi_choice (char *prompt, char *letters) } else if (ch.ch <= '9' && ch.ch > '0') { choice = ch.ch - '0'; - if (choice <= mutt_strlen (letters)) + if (choice <= safe_strlen (letters)) break; } } @@ -650,7 +648,7 @@ static void mutt_format_s_x (char *dest, } mutt_format_string (dest, destlen, min_width, max_width, - right_justify, ' ', s, mutt_strlen (s), arboreal); + right_justify, ' ', s, safe_strlen (s), arboreal); } void mutt_format_s (char *dest, @@ -675,7 +673,7 @@ void mutt_paddstr (int n, const char *s) wchar_t wc; int w; size_t k; - size_t len = mutt_strlen (s); + size_t len = safe_strlen (s); mbstate_t mbstate; memset (&mbstate, 0, sizeof (mbstate)); @@ -699,7 +697,7 @@ void mutt_paddstr (int n, const char *s) } /* - * mutt_strwidth is like mutt_strlen except that it returns the width + * mutt_strwidth is like safe_strlen except that it returns the width * refering to the number of characters cells. */ @@ -713,7 +711,7 @@ int mutt_strwidth (const char *s) if (!s) return 0; - n = mutt_strlen (s); + n = safe_strlen (s); memset (&mbstate, 0, sizeof (mbstate)); for (w = 0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k) {