Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 199820 - sys-apps/less-409 searching broken when content contains ANSI color escape codes
Summary: sys-apps/less-409 searching broken when content contains ANSI color escape codes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-20 20:50 UTC by sfp-a7x
Modified: 2008-01-03 18:25 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch provided by upstream (search-ansi-color.patch,802 bytes, patch)
2007-12-08 01:10 UTC, sfp-a7x
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sfp-a7x 2007-11-20 20:50:33 UTC
When viewing files with ANSI escape sequences, less-409 has problems searching.  Examples:

===== BEGIN a.txt =====
This is a test.
Original line here.
Testing.
====== END a.txt ======

===== BEGIN b.txt =====
This is a test.
Changed line here.
Testing.
====== END b.txt ======

When examining the output of colordiff, searching using the '^' or '$' anchors fails to match anything:

$ colordiff -u a.txt b.txt | less -R '+/^(\+|-|diff)'

Also notice an offset-by-one bug:

$ colordiff -u a.txt b.txt | less -R '+/This'

colordiff outputs ANSI escape sequences at the beginning and end of every line, which is probably why the anchors don't work.

sys-apps/less-415 does not have the offset-by-one problem, but searching is still broken.


Reproducible: Always
Comment 1 sfp-a7x 2007-11-20 20:59:16 UTC
$ paludis --info sys-apps/less

paludis 0.26.0_alpha4
Paludis build information:
    Compiler:
        CXX:                   i686-pc-linux-gnu-g++ 4.1.2 (Gentoo 4.1.2 p1.0.2)
        CXXFLAGS:              -O2 -march=pentium-m -pipe
        LDFLAGS:               -Wl,--as-needed
        DATE:                  2007-11-20T13:12:12-0500

    Libraries:
        C++ Library:           GNU libstdc++ 20070214

    Reduced Privs:
        reduced_uid:           107
        reduced_uid->name:     paludisbuild
        reduced_uid->dir:      /dev/null
        reduced_gid:           444
        reduced_gid->name:     paludisbuild

    Paths:
        DATADIR:               /usr/share
        LIBDIR:                /usr/lib
        LIBEXECDIR:            /usr/libexec
        SYSCONFDIR:            /etc
        PYTHONINSTALLDIR:      /usr/lib/python2.4/site-packages
        RUBYINSTALLDIR:        

Repository virtuals:
    format:                    virtuals

Repository installed-virtuals:
    root:                      /
    format:                    installed_virtuals

Repository gentoo:
    format:                    ebuild
    layout:                    traditional
    location:                  /var/paludis/repositories/gentoo
    profiles:                  /var/paludis/repositories/gentoo/profiles/default-linux/x86/2007.0/desktop
    cache:                     /var/paludis/repositories/gentoo/metadata/cache
    write_cache:               /var/empty
    append_repository_name_to_write_cache: true
    ignore_deprecated_profiles: false
    names_cache:               /var/paludis/repositories/gentoo/.cache/names
    distdir:                   /var/paludis/repositories/gentoo/distfiles
    eclassdirs:                /var/paludis/repositories/gentoo/eclass
    securitydir:               /var/paludis/repositories/gentoo/metadata/glsa
    setsdir:                   /var/paludis/repositories/gentoo/sets
    newsdir:                   /var/paludis/repositories/gentoo/metadata/news
    sync:                      rsync://rsync.us.gentoo.org/gentoo-portage/ rsync://rsync.namerica.gentoo.org/gentoo-portage/ rsync://rsync.gentoo.org/gentoo-portage/
    sync_options:              
    builddir:                  /var/tmp/paludis
    eapi_when_unknown:         0
    eapi_when_unspecified:     0
    profile_eapi:              0

    Package information:
        app-admin/eselect-compiler: (none)
        app-shells/bash:       3.2_p17
        dev-java/java-config:  1.3.7 2.1.2-r1
        dev-lang/python:       2.4.4-r6
        dev-python/pycrypto:   2.0.1-r6
        dev-util/ccache:       2.4-r7
        dev-util/confcache:    (none)
        sys-apps/baselayout:   1.12.9-r2
        sys-apps/sandbox:      1.2.18.1-r2
        sys-devel/autoconf:    2.13 2.61-r1
        sys-devel/automake:    1.10 1.4_p6 1.5 1.6.3 1.7.9-r1 1.8.5-r3 1.9.6-r2
        sys-devel/binutils:    2.18-r1
        sys-devel/gcc-config:  1.3.16
        sys-devel/libtool:     1.5.24
        virtual/os-headers:    2.6.22-r2 (for sys-kernel/linux-headers::installed)

Repository installed:
    location:                  /var/db/pkg
    root:                      /
    format:                    vdb
    world:                     /var/db/pkg/world
    provides_cache:            /var/db/pkg/.cache/provides
    names_cache:               /var/db/pkg/.cache/names
    builddir:                  /var/tmp/paludis

Package sys-apps/less-409::installed:

        >>> Running ebuild phases infovars info as paludisbuild:paludisbuild...
        >>> Starting builtin_infovars
        ACCEPT_KEYWORDS=x86
        CFLAGS=-O2 -march=pentium-m -pipe
        CBUILD=i686-pc-linux-gnu
        CHOST=i686-pc-linux-gnu
        CONFIG_PROTECT=/usr/share/X11/xkb /usr/kde/3.5/share/config /usr/kde/3.5/env /usr/kde/3.5/shutdown /usr/share/config /etc 
        CONFIG_PROTECT_MASK=/etc/env.d/java/ /etc/udev/rules.d /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/texmf/web2c /etc/revdep-rebuild /etc/splash /etc/env.d /etc/gconf /etc/init.d
        CPPFLAGS=
        CTARGET=
        CXXFLAGS=-O2 -march=pentium-m -pipe
        DISTDIR=/var/db/pkg/sys-apps/less-409
        FEATURES=sandbox sfperms
        GENTOO_MIRRORS=
        INSTALL_MASK=
        LANG=
        LC_ALL=
        LINGUAS=en en_US
        LDFLAGS=-Wl,--as-needed
        MAKEOPTS=-j3
        PORTAGE_COMPRESS=
        PORTAGE_COMPRESS_FLAGS=
        PORTAGE_TMPDIR=/var/tmp/paludis
        PORTDIR=/var/db/pkg
        PORTDIR_OVERLAY=
        SYNC=
        USE=unicode x86 elibc_glibc video_cards_fbdev video_cards_radeon video_cards_vesa lirc_devices_sir lcd_devices_bayrad lcd_devices_cfontz lcd_devices_cfontz633 lcd_devices_glk lcd_devices_hd44780 lcd_devices_lb216 lcd_devices_lcdm001 lcd_devices_mtxorb lcd_devices_ncurses lcd_devices_text kernel_linux userland_GNU linguas_en linguas_en_US alsa_pcm_plugins_adpcm alsa_pcm_plugins_alaw alsa_pcm_plugins_asym alsa_pcm_plugins_copy alsa_pcm_plugins_dmix alsa_pcm_plugins_dshare alsa_pcm_plugins_dsnoop alsa_pcm_plugins_empty alsa_pcm_plugins_extplug alsa_pcm_plugins_file alsa_pcm_plugins_hooks alsa_pcm_plugins_iec958 alsa_pcm_plugins_ioplug alsa_pcm_plugins_ladspa alsa_pcm_plugins_lfloat alsa_pcm_plugins_linear alsa_pcm_plugins_meter alsa_pcm_plugins_mulaw alsa_pcm_plugins_multi alsa_pcm_plugins_null alsa_pcm_plugins_plug alsa_pcm_plugins_rate alsa_pcm_plugins_route alsa_pcm_plugins_share alsa_pcm_plugins_shm alsa_pcm_plugins_softvol alsa_cards_intel8x0 alsa_cards_intel8x0m input_devices_evdev input_devices_keyboard input_devices_mouse input_devices_synaptics 
        PORTAGE_RSYNC_OPTS=
        PORTAGE_RSYNC_EXTRA_OPTS=
        >>> Done builtin_infovars
        >>> Starting pkg_info
        No additional information available
        >>> Done pkg_info
        >>> Completed ebuild phases infovars info

Comment 2 SpanKY gentoo-dev 2007-11-21 04:07:06 UTC
dont use colordiff then
Comment 3 sfp-a7x 2007-11-29 21:22:32 UTC
(In reply to comment #2)
> dont use colordiff then

Sorry -- I'm confused.  How does not using colordiff fix a bug in less?  Less appears to have a problem with searching text containing ANSI escape sequences; I was trying to use colordiff to illustrate the bug.  I don't think that colordiff has a bug.

Here's a different example, not using colordiff:

$ echo -e "testing1\033[1mtesting2\033[mtesting3\ntesting1testing2testing3"|less -R +/ing1test

Note how the second "ing1test" string is matched but not the first (in >=sys-apps/less-408).  This works fine in =sys-apps/less-406.

Should I report this upstream instead of here?

Thanks!
Comment 4 SpanKY gentoo-dev 2007-11-30 05:33:41 UTC
it isnt a bug as escape sequences are something the terminal driver interprets, not less.  less seems the escape sequences exactly as typed.

feel free to send an e-mail to the upstream less developer but i dont see it as a bug.
Comment 5 sfp-a7x 2007-12-07 03:18:27 UTC
(In reply to comment #4)
> it isnt a bug as escape sequences are something the terminal driver interprets,
> not less.  less seems the escape sequences exactly as typed.

Except when the '-R' command-line argument is given.  '-R' causes less to interpret ANSI color escape codes (it passes them on to the terminal, but it is supposed to pretend as if the characters were never part of the input when performing operations such as searching or calculating line numbers).

> feel free to send an e-mail to the upstream less developer but i dont see it as
> a bug.

I have reported the bug upstream and will report back if/when it is resolved.
Comment 6 sfp-a7x 2007-12-08 01:10:33 UTC
Created attachment 137986 [details, diff]
patch provided by upstream

(In reply to comment #5)
> I have reported the bug upstream and will report back if/when it is resolved.

Upstream provided the attached patch for me to test.  I applied it to less-416 and it seems to work well.
Comment 7 SpanKY gentoo-dev 2008-01-03 18:25:42 UTC
newer versions of less are in portage which should include this fix