From 7b9b6ebc969dda77ef6991ad80e9091fa301e0d2 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Wed, 28 Aug 2024 10:14:06 -0400 Subject: [PATCH] Preserve %_ newlines in "-C" mode. --- src/calendar.c | 4 ++-- src/dosubst.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calendar.c b/src/calendar.c index ab63b226..79c8b3d2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -1412,7 +1412,7 @@ static int WriteOneColLine(int col) /* Find the last space char within the column. */ width = 0; while (width <= ColSpaces) { - if (!*ws) { + if (!*ws || *ws == '\n') { wspace = ws; break; } @@ -1518,7 +1518,7 @@ static int WriteOneColLine(int col) /* Find the last space char within the column. */ while (s - e->pos <= ColSpaces) { - if (!*s) {space = s; break;} + if (!*s || *s == '\n') {space = s; break;} if (isspace(*s)) space = s; s++; } diff --git a/src/dosubst.c b/src/dosubst.c index b469b020..9317dc97 100644 --- a/src/dosubst.c +++ b/src/dosubst.c @@ -797,7 +797,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, break; case '_': - if (PsCal == PSCAL_LEVEL2 || PsCal == PSCAL_LEVEL3 || (mode != CAL_MODE && mode != ADVANCE_MODE && !(MsgCommand && *MsgCommand))) { + if (PsCal == PSCAL_LEVEL2 || PsCal == PSCAL_LEVEL3 || DoCalendar || (mode != CAL_MODE && mode != ADVANCE_MODE && !(MsgCommand && *MsgCommand))) { snprintf(s, sizeof(s), "%s", NL); } else { snprintf(s, sizeof(s), " ");