[#8815] Segfault in libc strlen, via rb_str_new2 — "Sean E. Russell" <ser@...>

Howdy,

12 messages 2006/09/09
[#8817] Re: Segfault in libc strlen, via rb_str_new2 — Eric Hodel <drbrain@...7.net> 2006/09/09

On Sep 8, 2006, at 10:10 PM, Sean E. Russell wrote:

Re: The %? .. ? Operator

From: Eric Hodel <drbrain@...7.net>
Date: 2006-09-29 21:08:12 UTC
List: ruby-core #8961
On Sep 29, 2006, at 12:41 PM, James Edward Gray II wrote:

> On Sep 29, 2006, at 1:52 PM, Eric Hodel wrote:
>
>> On Sep 29, 2006, at 9:56 AM, James Edward Gray II wrote:
>>
>>> I'm needing to know the full list of characters that can (or  
>>> cannot) be used in the following Ruby construct:
>>>
>>>   %?special Ruby String literal?
>>>
>>> What are all the legal choices for the ?s above?
>>>
>>> I did browse parse.y a little, but couldn't find an obvious  
>>> answer there.
>>
>> It looks like the rule is something like:
>>
>> /%[QqWwxrs]?(.).*\1/
>>
>> Where QqWwxrs define what type of special literal it is (string,  
>> array, exec (`), regex or symbol) and following that is the  
>> terminating character which may be any character (but ([<{ must be  
>> balanced).
>
> This is interesting.  The operators do differ slightly when you  
> omit the letter though (because they are matched by different  
> grammar rules, I assume).  For example:
>
> $ ruby -e 'p % test '
> -e:1:in `test': wrong number of arguments (ArgumentError)
>         from -e:1
> $ ruby -e 'p %Q test '
> "test"

Yes, for a bare string ' ' will work, but not when % is a method call.

> And of course, %= .. = is out because %= is the Ruby operator  
> for .. = .. % ...

ruby -e 'p [%=x=]'
["x"]

>> See parse.y around line 4162, "case '%':"
>
> Yes, I see it now.  Thank you for pointing me in the right direction.

-- 
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com



In This Thread