[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35178] Re: [Ruby 1.9-Bug#4386] encoding: directive does not affect regex expressions

From: Eric Hodel <drbrain@...7.net>
Date: 2011-02-10 00:06:22 UTC
List: ruby-core #35178
This regexp has US-ASCII-only characters:

> puts /.*/.encoding

This regexp is has UTF-8 characters so is in UTF-8 encoding:

$ ruby -ve '# coding: UTF-8' -e 'p /π/.encoding'
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
-e:2: warning: ambiguous first argument; put parentheses or even spaces
#<Encoding:UTF-8>

Of course, you can't mix:

$ ~/.multiruby/install/1.9.2-p136/bin/ruby -ve '# coding: US-ASCII' -e 'p /π/.encoding'
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
-e:2: warning: ambiguous first argument; put parentheses or even spaces
-e:2: invalid multibyte char (US-ASCII)
-e:2: invalid multibyte char (US-ASCII)

But you can force:

$ ~/.multiruby/install/1.9.2-p136/bin/ruby -ve '# coding: UTF-8' -e 'p /.*/u.encoding'
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
-e:2: warning: ambiguous first argument; put parentheses or even spaces
#<Encoding:UTF-8>

See also `ri Regexp` in the Encoding section:

> A regexp can be matched against a string when they either share an encoding,
> or the regexp's encoding is US-ASCII and the string's encoding is
> ASCII-compatible.

A US-ASCII regexp matches a UTF-8 string correctly:

$ ~/.multiruby/install/1.9.2-p136/bin/ruby -ve '# coding: UTF-8' -e 'r = /my ./; p r.encoding, r =~ "my π", $&'
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
#<Encoding:US-ASCII>
0
"my π"

'.' matches a UTF-8 character even though the regexp is in US-ASCII which has only one-byte characters.

In This Thread