summaryrefslogtreecommitdiffstats
path: root/hdrline.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2002-02-12 21:54:41 +0000
committerThomas Roessler <roessler@does-not-exist.org>2002-02-12 21:54:41 +0000
commitb8accd022f676c6841eff028dc51a5d9c1af99a3 (patch)
tree19ff17aafc3d2a0de665a84f2864a21a1a32f615 /hdrline.c
parent89ebfe01e1466560cb77323ea3634f6b399e8eb6 (diff)
Improve %l's behaviour.
Diffstat (limited to 'hdrline.c')
-rw-r--r--hdrline.c18
1 files changed, 15 insertions, 3 deletions
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
{