Below is a patch for this.

Eric, just in case you are still interested I also have a patch to force
folding in <pre> tags.

---->8-----
From: Rene Kita <m...@rkta.de>
Date: Sun Aug 25 15:43:35 CEST 2024
Subject: Do not override cols option value
Patch: patches/Do-not-override-cols-option-value.patch

Fixes Debian BTS #825790, Debian BTS #941335, GitHub Issue #253.

Fixes: https://todo.sr.ht/~rkta/w3m/23
---
 main.c  |   13 +++++--------
 terms.c |    3 +++
 2 files changed, 8 insertions(+), 8 deletions(-)

--- a/main.c
+++ b/main.c
@@ -132,6 +132,7 @@ static int searchKeyNum(void);
 #define usage() fusage(stderr, 1)
 
 int enable_inline_image;
+extern int opt_cols;
 
 static void
 fversion(FILE * f)
@@ -713,7 +714,7 @@ main(int argc, char **argv)
            else if (!strcmp("-cols", argv[i])) {
                if (++i >= argc)
                    usage();
-               COLS = atoi(argv[i]);
+               opt_cols = atoi(argv[i]);
            }
            else if (!strcmp("-ppc", argv[i])) {
                double ppc;
@@ -904,14 +905,10 @@ main(int argc, char **argv)
        CookieFile = rcFile(COOKIE_FILE);
 #endif
 
-    if (!isatty(1) && !w3m_dump) {
-       /* redirected output */
+    if (!isatty(1) && !w3m_dump) /* redirected output */
        w3m_dump = DUMP_BUFFER;
-    }
-    if (w3m_dump) {
-       if (COLS == 0)
-           COLS = DEFAULT_COLS;
-    }
+    if (w3m_dump)
+       COLS = opt_cols ? opt_cols : DEFAULT_COLS;
 
 #ifdef USE_BINMODE_STREAM
     setmode(fileno(stdout), O_BINARY);
--- a/terms.c
+++ b/terms.c
@@ -426,6 +426,7 @@ char *T_cd, *T_ce, *T_kr, *T_kl, *T_cr,
     *T_ti, *T_te, *T_nd, *T_as, *T_ae, *T_eA, *T_ac, *T_op;
 
 int LINES, COLS;
+int opt_cols;
 #if defined(__CYGWIN__)
 int LASTLINE;
 #endif                         /* defined(__CYGWIN__) */
@@ -1255,6 +1256,8 @@ setlinescols(void)
        LINES = tgetnum("li");  /* number of line */
     if (COLS <= 0)
        COLS = tgetnum("co");   /* number of column */
+    if (opt_cols && COLS > opt_cols)
+       COLS = opt_cols;
 #if defined(__CYGWIN__)
     LASTLINE = LINES - (isWinConsole == TERM_CYGWIN_RESERVE_IME ? 2 : 1);
 #endif                         /* defined(__CYGWIN__) */

Reply via email to