[packages/poldek] Rel 7; COLUMNS/LINES fallback

arekm arekm at pld-linux.org
Tue Apr 14 19:04:25 CEST 2026


commit bc65ece0e44178bb7c6a1b59b1088514e4e58bfa
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Apr 14 19:04:08 2026 +0200

    Rel 7; COLUMNS/LINES fallback

 poldek-env-columns-lines.patch | 65 ++++++++++++++++++++++++++++++++++++++++++
 poldek.spec                    |  4 ++-
 2 files changed, 68 insertions(+), 1 deletion(-)
---
diff --git a/poldek.spec b/poldek.spec
index 1e5b8e7..ed5777a 100644
--- a/poldek.spec
+++ b/poldek.spec
@@ -22,7 +22,7 @@
 %define		ver_rpm		1:4.14
 %endif
 
-%define		rel	6
+%define		rel	7
 Summary:	RPM packages management helper tool
 Summary(hu.UTF-8):	RPM csomagkezelést segítő eszköz
 Summary(pl.UTF-8):	Pomocnicze narzędzie do zarządzania pakietami RPM
@@ -55,6 +55,7 @@ Patch3:		%{name}-search-i-opt.patch
 Patch4:		%{name}-nocolor-cmp.patch
 Patch5:		%{name}-multilib-bare-name-install.patch
 Patch6:		%{name}-dup-sources.patch
+Patch7:		%{name}-env-columns-lines.patch
 URL:		http://poldek.pld-linux.org/
 %{?with_rpm5:BuildRequires:	%{db_pkg}-devel >= %{ver_db}}
 BuildRequires:	autoconf >= 2.63
@@ -234,6 +235,7 @@ Moduły języka Python dla poldka.
 %patch -P4 -p1
 %patch -P5 -p1
 %patch -P6 -p1
+%patch -P7 -p1
 
 %{__rm} doc/poldek.info
 %{__rm} m4/libtool.m4 m4/lt*.m4
diff --git a/poldek-env-columns-lines.patch b/poldek-env-columns-lines.patch
new file mode 100644
index 0000000..89198e5
--- /dev/null
+++ b/poldek-env-columns-lines.patch
@@ -0,0 +1,65 @@
+commit bcf31cc1653155c93ad4b2b1a17d2301ac70d36b
+Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
+Date:   Tue Apr 14 17:45:51 2026 +0200
+
+    Use $COLUMNS as fallback when ioctl fails to get terminal width
+    
+    When stdout is not a tty (e.g. piped output), ioctl TIOCGWINSZ fails
+    and terminal width falls back to 80 columns, causing unnecessary URL
+    truncation. Check $COLUMNS environment variable before falling back
+    to the default.
+
+diff --git a/poldek_term.c b/poldek_term.c
+index 9d4f9a87..6fbf7d82 100644
+--- a/poldek_term.c
++++ b/poldek_term.c
+@@ -245,15 +245,34 @@ static void update_term_width(void)
+ 
+     if (winch_reached) {
+         char tmp[256];
++        term_width  = TERM_DEFAULT_WIDTH;
++        term_height = TERM_DEFAULT_HEIGHT;
++
+         if (ioctl(1, TIOCGWINSZ, &ws) == 0) {
+             term_width  = ws.ws_col;
+             term_height = ws.ws_row;
+ 
+         } else {
+-            term_width  = TERM_DEFAULT_WIDTH;
+-            term_height = TERM_DEFAULT_HEIGHT;
++            const char *cols = getenv("COLUMNS");
++            if (cols) {
++                int n = atoi(cols);
++                if (n > 0)
++                    term_width = n;
++            }
++
++            const char *rows = getenv("LINES");
++            if (rows) {
++                int n = atoi(rows);
++                if (n > 0)
++                    term_height = n;
++            }
+         }
+ 
++        if (term_width < TERM_MIN_WIDTH)
++            term_width = TERM_MIN_WIDTH;
++        if (term_height < TERM_MIN_HEIGHT)
++            term_height = TERM_MIN_HEIGHT;
++
+         //https://www.gnu.org/software/libc/manual/html_node/Argp-User-Customization.html
+         snprintf(tmp, sizeof(tmp), "no-dup-args-note,rmargin=%d", term_width - 1);
+         setenv("ARGP_HELP_FMT", tmp, 1);
+diff --git a/poldek_term.h b/poldek_term.h
+index 80e6d5a6..2b1db740 100644
+--- a/poldek_term.h
++++ b/poldek_term.h
+@@ -25,6 +25,8 @@
+ 
+ #define TERM_DEFAULT_WIDTH  80
+ #define TERM_DEFAULT_HEIGHT 24
++#define TERM_MIN_WIDTH      40
++#define TERM_MIN_HEIGHT      4
+ 
+ #include <stddef.h>           /* for size_t     */
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/poldek.git/commitdiff/bc65ece0e44178bb7c6a1b59b1088514e4e58bfa



More information about the pld-cvs-commit mailing list