[#7872] Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...>

All, I needed a nonblocking socket connect for my asynchronous-event

18 messages 2006/05/14
[#7873] Re: Nonblocking socket-connect — Tanaka Akira <akr@...17n.org> 2006/05/14

In article <3a94cf510605140559l7baa0205le341dac4f47d424b@mail.gmail.com>,

[#7874] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

How about introducing the method Socket#set_nonblocking, or alternatively

[#7875] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

[#7876] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

Well, it's ok then. I'm comfortable adding in the nonblocking

[#7877] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

[ ruby-Bugs-4361 ] StringScanner#scan() fails on zero-length matches at eos

From: noreply@...
Date: 2006-05-04 21:52:53 UTC
List: ruby-core #7822
Bugs item #4361, was opened at 2006-05-04 21:52
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=4361&group_id=426

Category: Core
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Mitchell Charity (mcharity)
Assigned to: Nobody (None)
Summary: StringScanner#scan() fails on zero-length matches at eos

Initial Comment:
ruby 1.8.4 (2005-12-24) [x86_64-linux]
ruby 1.9.0 (2006-04-08) [x86_64-linux]
ruby 1.9.0 (2006-05-01) [x86_64-linux]

StringScanner's scan() incorrectly returns nil for successful zero-length matches at eos.

 StringScanner.new("").scan(//)
 => nil

Only at eos.  This
 StringScanner.new("x").scan(//)
 => ""
works correctly.

The documentation says scan() "Tries to match with pattern at the current position. If there’s a match, the scanner advances the "scan pointer" and returns the matched string. Otherwise, the scanner returns nil.".  Instead, if there's a (necessarily zero-length) match at eos, you get nil.  Oops.

To get the documented and desirable behavior, one currently needs to write
  ss.scan(re) || (ss.eos? && "" =~ re && "")
instead of simply
  ss.scan(re)
whenever there is a chance the re might do a zero-length match.
Which is unfortunate, and a source of bugs.

Example test:
% ruby -r strscan -e 'p StringScanner.new("").scan(//)'


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=4361&group_id=426

In This Thread

Prev Next