grep problem under NetBeans 6.1 Windows

View: New views
3 Messages — Rating Filter:   Alert me  

grep problem under NetBeans 6.1 Windows

by wrishel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is this the right forum to post problems?

The following 3-line script fails under NetBeans (returns Nil) but works when running Ruby from the console or in SciTE (returns ["a", "b"]).

x = ["fa"]
p = /^f(.+)$/
puts x.grep(p){|z| Regexp.last_match(1)}

However this script works the same in all the environments (returns ["fa", "fb"]).

x = ["fa", "fb"]
p = /^f(.+)$/
puts x.grep(p){|z| z}

I have tried this with both Ruby platforms in NetBeans and the result is the same. It also doesn't matter whether I am running in Debug mode or Run mode. I installed the JDK freshly for the NetBeans install.

Any suggestions on what else I should try?

I am on Windows XP Pro, SP2

Can others duplicate the problem?

Re: grep problem under NetBeans 6.1 Windows

by Martin Krauskopf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

wrishel wrote:

> Is this the right forum to post problems?
>
> The following 3-line script fails under NetBeans but works when running Ruby
> from the console or in SciTE
>
> x = ["fa"]
> p = /^f(.+)$/
> #puts x[0], x[0] =~ p
> puts x.grep(p){|z| Regexp.last_match(1)}
>
> If you uncomment the commented line, then the script works in NetBeans.
>
> I have tried this with both Ruby platforms in NetBeans and the result is the
> same. It also doesn't matter whether I am running in Debug mode or Run mode.
> I installed the JDK freshly for the NetBeans install.
>
> Any suggestions on what else I should try?
>
> Can others duplicate the problem?

If you mean by the 'fail' that from within NetBeans it prints 'nil' and
from CLI it prints 'a' it is probable that you are using bundled JRuby
from within the NetBeans which itself causes this bug
So it is a bug in broken JRuby's Regexp.last_match implementation when
called from within the Enumerable.grep's block (likely).

I've filed:
http://jira.codehaus.org/browse/JRUBY-2489

If it is not the case, let me know.

Regards,
        m.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: grep problem under NetBeans 6.1 Windows

by wrishel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gosh.

I *though* I had tried this in both Jruby and CRuby but after reading your note I went back and realized that I had misunderstood the directions for changing platforms.

With my newbie error corrected, it is clear that the problem is associated with JRuby.

Thanks for your timely response.

Martin Krauskopf wrote:
wrishel wrote:
> Is this the right forum to post problems?
>
> The following 3-line script fails under NetBeans but works when running Ruby
> from the console or in SciTE
>
> x = ["fa"]
> p = /^f(.+)$/
> #puts x[0], x[0] =~ p
> puts x.grep(p){|z| Regexp.last_match(1)}
>
> If you uncomment the commented line, then the script works in NetBeans.
>
> I have tried this with both Ruby platforms in NetBeans and the result is the
> same. It also doesn't matter whether I am running in Debug mode or Run mode.
> I installed the JDK freshly for the NetBeans install.
>
> Any suggestions on what else I should try?
>
> Can others duplicate the problem?

If you mean by the 'fail' that from within NetBeans it prints 'nil' and
from CLI it prints 'a' it is probable that you are using bundled JRuby
from within the NetBeans which itself causes this bug
So it is a bug in broken JRuby's Regexp.last_match implementation when
called from within the Enumerable.grep's block (likely).

I've filed:
http://jira.codehaus.org/browse/JRUBY-2489

If it is not the case, let me know.

Regards,
        m.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@ruby.netbeans.org
For additional commands, e-mail: users-help@ruby.netbeans.org