[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strange error in jcode.rb when converting range to array

Hammed Malik

9/27/2006 9:42:00 PM

In my rails app I've line with the following code:

("a".."z").to_a

Simple enough and it's been working for a while. Last night this line
started throwing the following error:

undefined method `[]' for nil:NilClass
/usr/local/lib/ruby/1.8/jcode.rb:83:in `succ!'
/usr/local/lib/ruby/1.8/jcode.rb:94

I looked up jcode.rb and the comments for this file say that it's "#
jcode.rb - ruby code to handle japanese (EUC/SJIS) string"

This is the part of jcode.rb that throws the error (line 83)

78 def succ!
79 reg = end_regexp
80 if self =~ reg
81 succ_table = SUCC[$KCODE[0,1].downcase]
83 begin
84 self[-1] += succ_table[self[-1]]
85 self[-2] += 1 if self[-1] == 0
86 end while self !~ reg
87 self
88 else
89 original_succ!
90 end
91 end

Debugging is difficult because if I restart the app, the problem goes
away..for a while. Has anyone else encountered this error before?

It's obviously being caused by something I've added to my app
recently. I just can't figure out what.

ruby -v
ruby 1.8.4 (2005-12-24) [i686-darwin8.5.2]

Thanks

Hammed

4 Answers

Manfred Stienstra

9/28/2006 5:15:00 PM

0

Hammed Malik wrote:
> In my rails app I've line with the following code:
>
> ("a".."z").to_a

When I try this with jcode loaded it immediately breaks. It looks like
other people have noticed it too and there is a fix:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...

I guess you will have to work around it for now.

Yukihiro Matsumoto

9/29/2006 12:16:00 AM

0

Hi,

In message "Re: Strange error in jcode.rb when converting range to array"
on Fri, 29 Sep 2006 02:20:18 +0900, "Manfred Stienstra" <manfred@gmail.com> writes:

|Hammed Malik wrote:
|> In my rails app I've line with the following code:
|>
|> ("a".."z").to_a
|
|When I try this with jcode loaded it immediately breaks. It looks like
|other people have noticed it too and there is a fix:
|
|http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...

No, it's about 1.9 and the OP was using 1.8.4. I will examine it
later.

matz.

Hammed Malik

9/29/2006 12:49:00 AM

0

Hi Matz,

The perplexing part for me was why jcode.rb was even being used by my
code. A bit embarrasing to admit on a mailing list but somehow the
line include "jcode" got included in one of my less used rails
controller. I don't have any need for Japanese characters in my app so
I can't imagine adding that line myself. I'm suspecting Textmate has a
hotkey for inserting that line that I pressed inadvertantly.

Hammed

On 9/29/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Strange error in jcode.rb when converting range to array"
> on Fri, 29 Sep 2006 02:20:18 +0900, "Manfred Stienstra" <manfred@gmail.com> writes:
>
> |Hammed Malik wrote:
> |> In my rails app I've line with the following code:
> |>
> |> ("a".."z").to_a
> |
> |When I try this with jcode loaded it immediately breaks. It looks like
> |other people have noticed it too and there is a fix:
> |
> |http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby...
>
> No, it's about 1.9 and the OP was using 1.8.4. I will examine it
> later.
>
> matz.
>
>

Yukihiro Matsumoto

9/29/2006 3:28:00 AM

0

Hi,

In message "Re: Strange error in jcode.rb when converting range to array"
on Fri, 29 Sep 2006 09:49:03 +0900, "Hammed Malik" <hammed@gmail.com> writes:

|The perplexing part for me was why jcode.rb was even being used by my
|code. A bit embarrasing to admit on a mailing list but somehow the
|line include "jcode" got included in one of my less used rails
|controller. I don't have any need for Japanese characters in my app so
|I can't imagine adding that line myself. I'm suspecting Textmate has a
|hotkey for inserting that line that I pressed inadvertantly.

I've heard Rails uses jcode to handle UTF-8.

I was telling the article in the ruby-dev list has nothing related to
your problem. It is caused by a bug in jcode.rb, and is just fixed in
the CVS.

matz.