flags '--column' and '--context' together produce an error

22 views
Skip to first unread message

Pavlos Vinieratos

unread,
Oct 25, 2012, 10:54:01 AM10/25/12
to ack-...@googlegroups.com
Hello. Im new here.

I tried executing 'ack --column -C 3 PHPUnit_TestF' and get something like this

cache-manager/php_src/PHPUnit-1.3.2/PHPUnit/TestResult.php
111-32-     * @access public
112-32-     */
113-32-    function addError(&$test, &$t) {
114:32:        $this->_errors[] = new PHPUnit_TestFailure($test, $t);
115-1-
Use of uninitialized value $match_start in addition (+) at /usr/local/bin/ack line 2208, <$__ANONIO__> line 116.
116-1-        for ($i = 0; $i < sizeof($this->_listeners); $i++) {
Use of uninitialized value $match_start in addition (+) at /usr/local/bin/ack line 2208, <$__ANONIO__> line 117.
117-1-            $this->_listeners[$i]->addError($test, $t);


I didn't know what this $match_start was, or the reason for that message. I tried 'ack -C 3 PHPUnit_TestF', the same without the '--column' flag, and I got this:
cache-manager/php_src/PHPUnit-1.3.2/PHPUnit/TestResult.php
111-     * @access public
112-     */
113-    function addError(&$test, &$t) {
114:        $this->_errors[] = new PHPUnit_TestFailure($test, $t);
115-
116-        for ($i = 0; $i < sizeof($this->_listeners); $i++) {
117-            $this->_listeners[$i]->addError($test, $t);

which is the right output.
could you fix that?
the column flag should print the column number only on the line that the search pattern exists.

Andy Lester

unread,
Oct 25, 2012, 10:59:33 AM10/25/12
to ack-...@googlegroups.com

On Oct 25, 2012, at 9:54 AM, Pavlos Vinieratos <pvi...@gmail.com> wrote:

which is the right output.
could you fix that?
the column flag should print the column number only on the line that the search pattern exists.

Thanks for submitting this as https://github.com/petdance/ack/issues/240

If anyone wants to take a stab at it, that would be great.  Even better would be if a .t file came out of it that we could copy over to the ack2 project.

xoxo,
Andy

Rob Hoelz

unread,
Oct 26, 2012, 9:16:41 AM10/26/12
to ack-...@googlegroups.com
This currently works in ack2. \o/

However, a test to prevent future regressions would be most welcome.

Also, should the column number be printed on all context lines, or just the line number
in which the match occurs?  I'm seeing this with ack2:

    PHPUnit/Framework/TestFailure.php
    54-7- * @link       http://www.phpunit.de/
    55-7- * @since      Class available since Release 2.0.0
    56-7- */
    57:7:class PHPUnit_Framework_TestFailure
    58-7-{
    59-7-    /**
    60-7-     * @var    PHPUnit_Framework_Test

Pavlos Vinieratos

unread,
Oct 28, 2012, 2:35:15 PM10/28/12
to ack-...@googlegroups.com
well i made a pull request and i think it should be fine. please review it :)

i think the best solution would be to have the column number show up only on the lines that the match occurs. what do you think?

Andy Lester

unread,
Oct 28, 2012, 3:16:07 PM10/28/12
to ack-...@googlegroups.com

On Oct 28, 2012, at 1:35 PM, Pavlos Vinieratos <pvi...@gmail.com> wrote:

> well i made a pull request and i think it should be fine. please review it :)
>
> i think the best solution would be to have the column number show up only on the lines that the match occurs. what do you think?

Yes, that's what I think we should do. I've started a branch working on the problem.

Thanks,
xoa
Reply all
Reply to author
Forward
0 new messages