Jcode.rb ruby-1.9

e$BEOJUE/Li$G$9!#e(B

jcode.rb e$B$G%(%i!<$,$G$^$7$?$N$G!"$$7$i$;$7$Fe(B
e$B$
$-$^$9!#e(B


$ ruby -v
ruby 1.9.0 (2006-07-07) [i686-linux]

e$B$K$F!"<!$N%9%/%j%W%H$rF0$+$9$He(B


#! /usr/local/bin/ruby -Ke

e$B%F%9%H;~$Oe(B EUC-kanji e$B$G9T$J$$$^$7$?e(B

require ‘jcode’

p ‘abc’.tr(‘a-z’, ‘e$B#ae(B-e$B#ze(B’)


e$B<!$N%(%i!<$,$G$^$9!#e(B


$ ruby -Ke jcode1.rb
/t/lib/ruby/1.9/jcode.rb:83:in String#+': can't convert Fixnum into String (TypeError) from /t/lib/ruby/1.9/jcode.rb:83:inString#succ!’
from /t/lib/ruby/1.9/jcode.rb:93:in succ' from /t/lib/ruby/1.9/jcode.rb:111:in_expand_ch’
from /t/lib/ruby/1.9/jcode.rb:100:in _expand_ch' from /t/lib/ruby/1.9/jcode.rb:120:inexpand_ch_hash’
from /t/lib/ruby/1.9/jcode.rb:141:in String#tr!' from /t/lib/ruby/1.9/jcode.rb:147:inString#tr’
from jcode1.rb:10
zsh: 15666 exit 1 ruby jcode1.rb

[email protected]$G$9!#e(B

At Fri, 7 Jul 2006 15:16:01 +0900,
WATANABE Tetsuya wrote in [ruby-dev:28979]:

from /t/lib/ruby/1.9/jcode.rb:141:in String#tr!' from /t/lib/ruby/1.9/jcode.rb:147:inString#tr’
from jcode1.rb:10

String#[]e$B$,0lJ8;z$Ne(BStringe$B$rJV$9$h$&$K$J$C$?1F6A$G$9$M!#e(B

e$B$b$&$R$H$D!"e(BMSBe$B$NN)$C$F$$$kJ8;z$K$D$$$Fe(BString#orde$B$,Ii$NCM$rJV$7e(B
e$B$F$$$^$9!#e(B

$ ./ruby -v -e ‘p “e$B#ae(B”[-1].ord’
ruby 1.9.0 (2006-07-07) [i686-linux]
-31

1.8e$B$Ne(BString#[]e$B$G$O%^%9%/$5$l$F$$$^$9!#e(B

$ ./i486-linux/miniruby -v -e ‘p “e$B#ae(B”[-1]’
ruby 1.8.5 (2006-07-07) [i686-linux]
225

Index: string.c

RCS file: /cvs/ruby/src/ruby/string.c,v
retrieving revision 1.252
diff -p -u -2 -r1.252 string.c
— string.c 3 Jul 2006 20:07:09 -0000 1.252
+++ string.c 7 Jul 2006 07:03:17 -0000
@@ -4071,5 +4071,5 @@ rb_str_ord(VALUE s)
RSTRING(s)->len);
}

  • c = RSTRING(s)->ptr[0];
  • c = RSTRING(s)->ptr[0] & 0xff;
    return INT2NUM©;
    }
    Index: lib/jcode.rb
    ===================================================================
    RCS file: /cvs/ruby/src/ruby/lib/jcode.rb,v
    retrieving revision 1.27
    diff -p -u -2 -r1.27 jcode.rb
    — lib/jcode.rb 9 Jun 2006 21:20:02 -0000 1.27
    +++ lib/jcode.rb 7 Jul 2006 06:48:06 -0000
    @@ -80,7 +80,10 @@ class String
    if self =~ reg
    succ_table = SUCC[$KCODE[0,1].downcase]
  •  last1 = self[-1].ord
    
  •  last2 = self[-2].ord
     begin
    
  • self[-1] += succ_table[self[-1]]
  • self[-2] += 1 if self[-1] == 0
  • last1 += succ_table[last1]
  • last2 += 1 if last1 == 0
  • self[-2…-1] = [last2, last1].pack(“C*”)
    end while self !~ reg
    self

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:28980] Re: jcode.rb ruby-1.9”
on Fri, 7 Jul 2006 16:12:01 +0900, [email protected] writes:
|At Fri, 7 Jul 2006 15:16:01 +0900,
|WATANABE Tetsuya wrote in [ruby-dev:28979]:
|> e$B<!$N%(%i!<$,$G$^$9!#e(B
|> $ ruby -Ke jcode1.rb
|> /t/lib/ruby/1.9/jcode.rb:83:in `String#+’: can’t convert Fixnum into String (TypeError)

|String#[]e$B$,0lJ8;z$Ne(BStringe$B$rJV$9$h$&$K$J$C$?1F6A$G$9$M!#e(B
|
|e$B$b$&$R$H$D!"e(BMSBe$B$NN)$C$F$$$kJ8;z$K$D$$$Fe(BString#orde$B$,Ii$NCM$rJV$7e(B
|e$B$F$$$^$9!#e(B

|— string.c 3 Jul 2006 20:07:09 -0000 1.252
|+++ string.c 7 Jul 2006 07:03:17 -0000

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs