[#6363] Re: rescue clause affecting IO loop behavior — ts <decoux@...>

>>>>> "D" == David Alan Black <dblack@candle.superlink.net> writes:

17 messages 2000/11/14
[#6367] Re: rescue clause affecting IO loop behavior — David Alan Black <dblack@...> 2000/11/14

Hello again --

[#6582] best way to interleaf arrays? — David Alan Black <dblack@...>

Hello --

15 messages 2000/11/26

[#6646] RE: Array Intersect (&) question — Aleksi Niemel<aleksi.niemela@...>

Ross asked something about widely known and largely ignored language (on

23 messages 2000/11/29
[#6652] RE: Array Intersect (&) question — rpmohn@... (Ross Mohn) 2000/11/29

aleksi.niemela@cinnober.com (Aleksi Niemel) wrote in

[#6723] Re: Array Intersect (&) question — Mathieu Bouchard <matju@...> 2000/12/01

> >Use a hash. Here's code to do both and more. It assumes that

[#6656] printing/accessing arrays and hashes — raja@... (Raja S.)

I'm coming to Ruby with a Python & Common Lisp background.

24 messages 2000/11/30

[ruby-talk:6238] Regular expression puzzle: user error or bug?

From: "Conrad Schneiker/Austin/Contr/IBM" <schneik@...>
Date: 2000-11-10 01:42:22 UTC
List: ruby-talk #6238
Hi,

Is this another case of overlooking something obvious? (Besides the 
obvious fact that there are better ways to do this.)

It is case3 below that causes the problem. Case1 and case2 are 2 variants 
of case3 that differ as follows: In case1, the "*" underlined by 
"...--X---..." was inserted (with the successful aim of making the 
preceding RE match as much as possible rather than a character at a time, 
yet still produce the same overall result), and in case2, the "(.*/)*" 
underlined by "...++++++..." was deleted (which changes what the overall 
RE matches in the general case, but which unexpectedly stopped the stack 
overflow error).

==========================================
#!/usr/bin/env ruby

puts "==== Case 1 ===="
p1 = Regexp.new("^(.*/)*(((?:[^./]*|[.](?=[^./]*[.]))*)([.][^./]*)*)$")
#                 ++++++   -------X----------------
m1 = p1.match("myfile.txt.sav")
m1.to_a.each { |x| puts x }

puts "==== Case 2 ===="
p2 = Regexp.new("^(((?:[^./]|[.](?=[^./]*[.]))*)([.][^./]*)*)$")
#                    -----------------------
m2 = p2.match("myfile.txt.sav")
m2.to_a.each { |x| puts x }

puts "==== Case 3 ===="
p3 = Regexp.new("^(.*/)*(((?:[^./]|[.](?=[^./]*[.]))*)([.][^./]*)*)$")
#                 ++++++   -----------------------
m3 = p3.match("myfile.txt.sav")
m3.to_a.each { |x| puts x }
==========================================

produces this output:

==========================================
# ./parse_path.rb
==== Case 1 ====
myfile.txt.sav
nil
myfile.txt.sav
myfile.txt
.sav
==== Case 2 ====
myfile.txt.sav
myfile.txt.sav
myfile.txt
.sav
==== Case 3 ====
./parse_path.rb:18:in `match': Stack overflow in regexp matcher: 
/^(.*\/)*(((?:[^.\/]|[.](?=[^.\/]*[.]))*)([.][^.\/]*)*)$/ (RegexpError)
        from ./parse_path.rb:18
==========================================

using ruby 1.6.2 (2000-10-12) [rs6000-aix4.3.2.0].

However this doesn't fail for ruby 1.6.1 (2000-10-05) [i386-cygwin].

Conrad Schneiker
(This note is unofficial and subject to improvement without notice.)

In This Thread

Prev Next