0001-Fix-pager-trigger-in-print.c-by-using-linecount-help.patch
text/x-patch
Filename: 0001-Fix-pager-trigger-in-print.c-by-using-linecount-help.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Fix pager trigger in print.c by using linecount() helper for accurate line calculation
| File | + | − |
|---|---|---|
| src/fe_utils/print.c | 21 | 1 |
From f903ecc2aeb820f461d9caf06ac3c9731e81aff1 Mon Sep 17 00:00:00 2001
From: Lakshmi <bharatdbpg@gmail.com>
Date: Fri, 10 Oct 2025 11:57:05 +0530
Subject: [PATCH] Fix pager trigger in print.c by using linecount() helper for
accurate line calculation
Signed-off-by: Lakshmi <bharatdbpg@gmail.com>
---
src/fe_utils/print.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 4af0f32f2f..43dcd3a87a 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -266,6 +266,25 @@ static const unicodeStyleFormat unicode_style = {
/* Local functions */
static int strlen_max_width(unsigned char *str, int *target_width, int encoding);
+/* >>> INSERT helper function here <<< */
+static int
+linecount(const char *s)
+{
+ int count = 0;
+
+ if (s == NULL || *s == '\0')
+ return 0;
+
+ while (*s)
+ {
+ if (*s == '\n')
+ count++;
+ s++;
+ }
+ return count + 1;
+}
+
+
static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool expanded,
FILE **fout, bool *is_pager);
@@ -3421,7 +3440,8 @@ IsPagerNeeded(const printTableContent *cont, int extra_lines, bool expanded,
* footers, not the number of lines in them.
*/
for (f = cont->footers; f; f = f->next)
- lines++;
+ lines += linecount(f->data);
+
}
*fout = PageOutput(lines + extra_lines, cont->opt);
--
2.39.5