From: Thomas Roessler Date: Tue, 12 Feb 2002 21:54:41 +0000 (+0000) Subject: Improve %l's behaviour. X-Git-Tag: mutt-1-5-1-rel~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8accd022f676c6841eff028dc51a5d9c1af99a3;p=mutt Improve %l's behaviour. --- diff --git a/hdrline.c b/hdrline.c index 619d57cf..e46c6aca 100644 --- a/hdrline.c +++ b/hdrline.c @@ -445,9 +445,21 @@ hdr_format_str (char *dest, case 'l': if (!optional) - { - snprintf (fmt, sizeof (fmt), "%%%sd", prefix); - snprintf (dest, destlen, fmt, (int) hdr->lines); + { + if (hdr->lines >= 0) + { + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); + snprintf (dest, destlen, fmt, (int) hdr->lines); + } + else + { + int i; + int len = atoi (prefix); + for (i = 0; i < len && i < destlen - 1; i++) + dest[i] = '?'; + + dest[i] = '\0'; + } } else { diff --git a/muttlib.c b/muttlib.c index 58637801..cff93a04 100644 --- a/muttlib.c +++ b/muttlib.c @@ -50,6 +50,14 @@ #include #include +HEADER *mutt_new_header (void) +{ + HEADER *hdr = safe_calloc (1, sizeof (HEADER)); + hdr->lines = -1; + return hdr; +} + + BODY *mutt_new_body (void) { BODY *p = (BODY *) safe_calloc (1, sizeof (BODY)); @@ -1320,4 +1328,3 @@ const char *mutt_make_version (void) MUTT_VERSION, ReleaseDate); return vstring; } - diff --git a/protos.h b/protos.h index 895e6616..5e7f8bb8 100644 --- a/protos.h +++ b/protos.h @@ -59,7 +59,6 @@ int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag); #define mutt_new_parameter() safe_calloc (1, sizeof (PARAMETER)) -#define mutt_new_header() safe_calloc (1, sizeof (HEADER)) #define mutt_new_envelope() safe_calloc (1, sizeof (ENVELOPE)) #define mutt_new_enter_state() safe_calloc (1, sizeof (ENTER_STATE)) @@ -85,6 +84,8 @@ ADDRESS *mutt_remove_duplicates (ADDRESS *); ADDRESS *mutt_expand_aliases (ADDRESS *); ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *); +HEADER *mutt_new_header(void); + BODY *mutt_make_file_attach (const char *); BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int); BODY *mutt_remove_multipart (BODY *);