[MacRuby] #1016: Regular expression 'negative look-ahead' not working properly
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- I'm not sure if I'm doing this properly, but let me try. It's hard to describe, but there seems to be a bug in regular expression negative look-ahead (?! ). The regular expression below might not be optimal, but what it tries to do is a wild card text search for expressions with 0-2 words in between "it is" and "interesting" excluding "not". {{{ text = "It is interesting. It is very interesting. It is very very interesting. It is not interesting. It is not very interesting." p text.scan(/it is(?:\ *(?!\bnot\b)\w+)?(?:\ *(?!\bnot\b)\w+)? interesting/i) }}} Results Ruby 1.8.7/RubyCocoa {{{ => ["It is interesting", "It is very interesting", "It is very very interesting"] }}} MacRuby 0.7.1 {{{ => ["It is interesting", "It is very interesting"] }}} If I don't use negative look-ahead, both return the same array. {{{ text = "It is interesting. It is very interesting. It is very very interesting. It is not interesting. It is not very interesting." p text.scan(/\bit is(?:\ *\w+)?(?:\ *\w+)? interesting\b/i) }}} Result - Ruby 1.8.7/RubyCocoa, MacRuby {{{ => ["It is interesting", "It is very interesting", "It is very very interesting", "It is not interesting", "It is not very interesting"] }}} I also tried this at http://demo.icu-project.org/icu-bin/redemo and the result was the same as Ruby 1.8.7/RubyCocoa. -- Ticket URL: <http://www.macruby.org/trac/ticket/1016> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): I guess that this issue is cause of ICU 4.0 which installed in Mac OS X 10.6.[[BR]] When I used the ICU 4.4.2, this issue does not appear. Build the ICU {{{ $ curl -O http://download.icu-project.org/files/icu4c/4.4.2/icu4c- 4_4_2-src.tgz $ tar xvzf icu4c-4_4_2-src.tgz $ cd icu/source/ $ ./runConfigureICU MacOSX --disable-renaming $ make $ sudo make install }}} Build the MacRuby {{{ #!diff diff --git a/rakelib/builder/options.rb b/rakelib/builder/options.rb index b7d4980..271007a 100644 --- a/rakelib/builder/options.rb +++ b/rakelib/builder/options.rb @@ -154,7 +154,7 @@ class BuilderConfig archflags = archs.map { |x| "-arch #{x}" }.join(' ') @cflags = "-std=c99 -I. -I./include -fno-common -pipe -g -Wall -fexceptions -O#{OPTZ_LEVEL} -Wno-deprecated-declarations -Werror #{archflags}" @cxxflags = "-I. -I./include -g -Wall -Wno-deprecated-declarations -Werror #{archflags}" - @ldflags = '-lpthread -ldl -lxml2 -lobjc -licucore -framework Foundation' + @ldflags = '-lpthread -ldl -lxml2 -lobjc -L/usr/local/lib -licudata -licui18n -licuio -licule -liculx -licutu -licuuc -framework Foundation' @ldflags << " -lauto" if has_libauto if opt.delete(:static) @cflags << ' -DMACRUBY_STATIC' }}} {{{ $ RC_ARCHS=x86_64 rake jobs=2 }}} Result {{{ $ cat ~/tmp/r1.rb text = "It is interesting. It is very interesting. It is very very interesting. It is not interesting. It is not very interesting." p text.scan(/it is(?:\ *(?!\bnot\b)\w+)?(?:\ *(?!\bnot\b)\w+)? interesting/i) $ DYLD_LIBRARY_PATH=. ./macruby ~/tmp/r1.rb ["It is interesting", "It is very interesting", "It is very very interesting"] $ ruby19 ~/tmp/r1.rb ["It is interesting", "It is very interesting", "It is very very interesting"] }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:1> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): You're right! It works as expected in my environment, which has a newer system ICU. {{{ $ ruby t.rb ["It is interesting", "It is very interesting", "It is very very interesting"] $ ./miniruby t.rb ["It is interesting", "It is very interesting", "It is very very interesting"] }}} However, I believe it's not a good idea to link MacRuby with a newer ICU, as symbols might collide when requiring Cocoa, which links against the system version of ICU. -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:2> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * milestone: => MacRuby 1.0 Comment: Screening for 1.0. It may be possible to compile statically against a newer ICU and hide all symbols at link time, to permit MacRuby to load frameworks using the system ICU. -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:3> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): I have been trying to statically link ICU into the macruby runtime, but I was unsuccessful. In the meantime, I committed my work in a branch on subversion, called icu-embedded. {{{ $ svn co http://svn.macosforge.org/repository/ruby/MacRuby/branches/icu- embedded }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:4> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby Later Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * milestone: MacRuby 1.0 => MacRuby Later Comment: I no longer think this should be done for 1.0. Moving to Later. -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:5> MacRuby <http://macruby.org/>
#1016: Regular expression 'negative look-ahead' not working properly ----------------------------------+----------------------------------------- Reporter: yasuimao@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby Later Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): The system default ICU is 4.6 on Lion. So, this issue reproduce on Snow Leopard, but not reproduce on Lion. -- Ticket URL: <http://www.macruby.org/trac/ticket/1016#comment:6> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby