summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-11-04 17:32:27 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-11-04 17:32:27 +0000
commite911e9546240c128f1dcf33f1a6abda7e223a182 (patch)
tree1690a6b7c0324581ea92065c5bfff28e550bf488
parent3210a3a4fd9f5bf52f702435abe05d157894b627 (diff)
downloadmailutils-e911e9546240c128f1dcf33f1a6abda7e223a182.tar.gz
mailutils-e911e9546240c128f1dcf33f1a6abda7e223a182.tar.bz2
(print_string): Pad right if necessary.
-rw-r--r--mh/mh_format.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/mh/mh_format.c b/mh/mh_format.c
index c5c89bdc8..64851243a 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -165,26 +165,36 @@ compress_ws (char *str, size_t *size)
/* Print len bytes from str into mach->outbuf */
static void
-print_string (struct mh_machine *mach, size_t width, char *str, size_t len)
+print_string (struct mh_machine *mach, size_t width, char *str, size_t fmtlen)
{
- size_t rest;
-
+ size_t rest, len;
+
if (!str)
- {
- str = "";
- len = 0;
- }
+ str = "";
- rest = strlen (str);
- if (len > rest)
- len = rest;
if (!width)
width = mach->width;
- rest = mach->width - mach->ind;
+ len = strlen (str);
+ rest = width - mach->ind;
if (len > rest)
- len = rest;
+ {
+ if (fmtlen >= len)
+ fmtlen = rest;
+ len = rest;
+ }
+
+ if (fmtlen < len)
+ len = fmtlen;
+
memcpy (mach->outbuf + mach->ind, str, len);
mach->ind += len;
+
+ if (fmtlen > len)
+ {
+ fmtlen -= len;
+ memset (mach->outbuf + mach->ind, ' ', fmtlen);
+ mach->ind += fmtlen;
+ }
}
static void

Return to:

Send suggestions and report system problems to the System administrator.