• Bug#1105738: xterm: double-click can incorrectly add the preceding spac

    From Vincent Lefevre@21:1/5 to All on Wed May 14 02:10:02 2025
    XPost: linux.debian.maint.x

    Package: xterm
    Version: 398-1
    Severity: normal

    When I double-click on a word at the beginning of a line such that
    this word is preceded by spaces, one space is incorrectly included
    in the selection.

    For instance, type

    printf "%$((COLUMNS+1))syz\n" x

    which gives a line full of spaces and the word "xyz" on the next
    physical line. If I double-click on the word "xyz", only "xyz"
    is highlighted as expected, but if I paste the selection with
    the middle-button, I get " xyz", i.e. with a preceding space.

    -- System Information:
    Debian Release: trixie/sid
    APT prefers unstable-debug
    APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'proposed-updates-debug'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
    Architecture: amd64 (x86_64)

    Kernel: Linux 6.12.27-amd64 (SMP w/16 CPU threads; PREEMPT)
    Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    Versions of packages xterm depends on:
    ii libc6 2.41-7
    ii libfontconfig1 2.15.0-2.3
    ii libfreetype6 2.13.3+dfsg-1
    ii libice6 2:1.1.1-1
    ii libtinfo6 6.5+20250216-2
    ii libutempter0 1.2.1-4
    ii libx11-6 2:1.8.12-1
    ii libxaw7 2:1.0.16-1
    ii libxext6 2:1.3.4-1+b3
    ii libxft2 2.3.6-1+b4
    ii libxinerama1 2:1.1.4-3+b4
    ii libxmu6 2:1.1.3-3+b4
    ii libxpm4 1:3.5.17-1+b3
    ii libxt6t64 1:1.2.1-1.2+b2
    ii xbitmaps 1.1.1-2.2

    Versions of packages xterm recommends:
    ii luit [luit] 2.0.20240910-1
    ii x11-utils 7.7+7

    Versions of packages xterm suggests:
    pn xfonts-cyrillic <none>

    -- no debconf information

    --
    Vincent LefΦvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to Vincent Lefevre on Wed May 14 02:20:01 2025
    XPost: linux.debian.maint.x

    On 2025-05-14 01:59:38 +0200, Vincent Lefevre wrote:
    Package: xterm
    Version: 398-1
    Severity: normal

    When I double-click on a word at the beginning of a line such that
    this word is preceded by spaces, one space is incorrectly included
    in the selection.

    For instance, type

    printf "%$((COLUMNS+1))syz\n" x

    which gives a line full of spaces and the word "xyz" on the next
    physical line. If I double-click on the word "xyz", only "xyz"
    is highlighted as expected, but if I paste the selection with
    the middle-button, I get " xyz", i.e. with a preceding space.

    Note that this is a regression in the latest version.
    Version 397-1 did not have this issue.

    --
    Vincent LefΦvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Dickey@21:1/5 to Vincent Lefevre on Fri May 16 01:30:01 2025
    XPost: linux.debian.maint.x

    On Wed, May 14, 2025 at 02:10:51AM +0200, Vincent Lefevre wrote:
    On 2025-05-14 01:59:38 +0200, Vincent Lefevre wrote:
    Package: xterm
    Version: 398-1
    Severity: normal

    When I double-click on a word at the beginning of a line such that
    this word is preceded by spaces, one space is incorrectly included
    in the selection.

    For instance, type

    printf "%$((COLUMNS+1))syz\n" x

    which gives a line full of spaces and the word "xyz" on the next
    physical line. If I double-click on the word "xyz", only "xyz"
    is highlighted as expected, but if I paste the selection with
    the middle-button, I get " xyz", i.e. with a preceding space.

    Note that this is a regression in the latest version.
    Version 397-1 did not have this issue.

    That was from

    * fix several minor issues reported by Coverity.

    but in addressing a warning about overflow, I overlooked the special case
    where lastcol is one past the right margin, in this function:

    static int
    Length(TScreen *screen,
    int row,
    int scol,
    int ecol)
    {
    CLineData *ld = GET_LINEDATA(screen, row);
    const int lastcol = LastTextCol(screen, ld, row);

    if (ecol > lastcol)
    ecol = lastcol;
    if (ecol < scol) /* scol is less than lastcol in this instance */
    ecol = scol;
    return (ecol - scol + 1);
    }

    I'll amend that to ensure the function returns a positive value...

    --
    Thomas E. Dickey <dickey@invisible-island.net>
    https://invisible-island.net

    -----BEGIN PGP SIGNATURE-----

    iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmgmdfkACgkQzCr0RyFn vgP/xgv9Hifpo3PmZBA8X+34NuOhvtoC/uhlpn+ot5RA2m2lm8uN28yu27LYIdPM +sCv6fNQMDXpQddWFtXLVRCyXFT6gDKgx9DfWJkEqu0yw4VTij6DqiMB28pjJIWv ZF4OHGDnrx2zNl+iV/p96ZgQL6x4GMcJr44e2w+/WlT2GCF9W5OwYI5qRvl3fvTD n0Rlq2Y17fKozYUZX/60pzYLryjokBqQ1ulGChg7k9/ZLbmn7zov16vVK9FmUotE WaXNds9SqDEIHjnhMbAlspMBEFA/W8u+RshhJoennIp6NVJ4+vs7I+ienSBV90+l /lfW/rHws3KtXjcBI+4dLYVrzJV8z5rSg7p6QIqQYyoQ9s1aEDu0aFnxG2GkVfOj xTxb8kaePHk0nqCFx+zYynQ8zJM6XeocEznlXg+GnpchOjIFdKMoVPttvf838HtS uZRUMFI2qRaTshGbrth9WX+Uipfb7jQKG+V9AIdAeLmJPzTkk1fzG7ur2bmFmB7b
    yWulaeYZ
    =6c/W
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)