# Upgrading path from 1.8 to 1.9

**URL:** <https://www.ruby-forum.com/t/upgrading-path-from-1-8-to-1-9/124183>\
**Category:** Development\
**Created:** [December 26, 2007, 7:18am UTC](https://www.ruby-forum.com/t/upgrading-path-from-1-8-to-1-9/124183 "2007-12-26T07:18:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [December 26, 2007, 7:18am UTC](https://www.ruby-forum.com/t/upgrading-path-from-1-8-to-1-9/124183/1 "2007-12-26T07:18:53Z")

</div>

e$B$J$+$@$G$9!#e(B

1.9e$B$GDI2C$5$l$?5!G=$N$&$A!“e(BString#linese$B$He(BString#bytese$B$re(B1.8e$B$K$bDIe(B  
e$B2C$7$F$\*$$$F$O$I$&$G$7$g$&$+!#$H$j$”$($:e(Beach\_linee$B$He(Beach\_bytee$B$K$Oe(B  
e$B\<j$rF~$l$F$$$^$;$s!#e(B

e$B$b$&0l$D!"e(BRSTRING\_PTR()e$B$de(BRSTRING\_LEN()e$B$HF1MM!“e(Brb\_str\_set\_len()e$B$be(B  
e$B$”$C$?$[$&$,$$$$$H;W$$$^$9!#e(B

# Index: string.c

— string.c (revision 14573)  
+++ string.c (working copy)  
@@ -672,4 +672,11 @@ rb\_str\_unlocktmp(str)  
}

+void  
+rb\_str\_set\_len(VALUE str, long len)  
+{

- RSTRING(str)-\>len = len;
- RSTRING(str)-\>ptr[len] = ‘\0’;  
+}
- 

VALUE  
rb\_str\_resize(str, len)  
@@ -3756,4 +3763,95 @@ rb\_str\_each\_byte(str)

+static VALUE str\_enumerator \_((VALUE, VALUE, int, VALUE \*));  
+static VALUE  
+str\_enumerator(str, sym, argc, argv)

- VALUE str, sym;
- int argc;
- VALUE \*argv;  
+{
- static VALUE enumerator;
- static ID new;
- int nargc;
- VALUE \*nargv, result;
- volatile VALUE args;
- 
- if (!enumerator) {
- rb\_require(“enumerator”);
- enumerator = rb\_path2class(“Enumerable::Enumerator”);
- new = rb\_intern(“new”);
- }
- args = rb\_ary\_new2(nargc = argc + 2);
- RBASIC(args)-\>klass = 0;
- nargv = RARRAY\_PTR(args);
- nargv[0] = str;
- nargv[1] = sym;
- MEMCPY(nargv + 2, argv, VALUE, argc);
- result = rb\_funcall2(enumerator, new, nargc, nargv);
- rb\_ary\_clear(args);
- return result;  
+}
- 
- 

+/\*

- 
  - Document-method: lines

- 
  - call-seq:

- 
  - 

```
str.lines(separator=$/) => anEnumerator

```

- 
  - 

```
str.lines(separator=$/) {|substr| block } => str

```

- 
  - 

- 
  - Returns an enumerator that gives each line in the string. If a  
block is

- 
  - given, it iterates over each line in the string.

- 
  - 

- 
  - 

```
"foo\nbar\n".lines.to_a #=> ["foo\n", "bar\n"]

```

- 
  - 

```
"foo\nb ar".lines.sort #=> ["b ar", "foo\n"]

```

- \*/
- 

+static VALUE  
+rb\_str\_lines(argc, argv, str)

- int argc;
- VALUE \*argv;
- VALUE str;  
+{
- if (rb\_block\_given\_p()) {
- return rb\_str\_each\_line(argc, argv, str);
- }
- else {
- static VALUE each\_line;
- 
- if (!each\_line) each\_line = ID2SYM(rb\_intern(“each\_line”));
- return str\_enumerator(str, each\_line, argc, argv);
- }  
+}
- 
- 

+/\*

- 
  - Document-method: bytes

- 
  - call-seq:

- 
  - 

```
str.bytes => anEnumerator

```

- 
  - 

```
str.bytes {|fixnum| block } => str

```

- 
  - 

- 
  - Returns an enumerator that gives each byte in the string. If a  
block is

- 
  - given, it iterates over each byte in the string.

- 
  - 

- 
  - 

```
"hello".bytes.to_a #=> [104, 101, 108, 108, 111]

```

- \*/
- 

+static VALUE  
+rb\_str\_bytes(argc, argv, str)

- int argc;
- VALUE \*argv;
- VALUE str;  
+{
- if (rb\_block\_given\_p()) {
- return rb\_str\_each\_byte(argc, argv, str);
- }
- else {
- static VALUE each\_byte;
- 
- if (!each\_byte) each\_byte = ID2SYM(rb\_intern(“each\_byte”));
- return str\_enumerator(str, each\_byte, argc, argv);
- }  
+}
- 
- 

/\*

- call-seq:  
@@ -4748,4 +4846,7 @@ Init\_String()  
rb\_define\_method(rb\_cString, “each\_byte”, rb\_str\_each\_byte, 0);

- rb\_define\_method(rb\_cString, “lines”, rb\_str\_lines, -1);
- rb\_define\_method(rb\_cString, “bytes”, rb\_str\_bytes, -1);
- rb\_define\_method(rb\_cString, “sum”, rb\_str\_sum, -1);

# Index: intern.h

— intern.h (revision 14573)  
+++ intern.h (working copy)  
@@ -425,4 +425,5 @@ VALUE rb\_str\_substr \_((VALUE, long, long  
void rb\_str\_modify \_((VALUE));  
VALUE rb\_str\_freeze \_((VALUE));  
+void rb\_str\_set\_len \_((VALUE, long));  
VALUE rb\_str\_resize \_((VALUE, long));  
VALUE rb\_str\_cat \_((VALUE, const char\*, long));

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [December 26, 2007, 10:55pm UTC](https://www.ruby-forum.com/t/upgrading-path-from-1-8-to-1-9/124183/2 "2007-12-26T22:55:16Z")

</div>

At Wed, 26 Dec 2007 15:18:06 +0900,  
Nobuyoshi N. wrote:

> 1.9ã§è¿½åŠ ã•ã‚ŒãŸæ©Ÿèƒ½ã®ã†ã¡ã€String#linesã¨String#bytesã‚’1.8ã«ã‚‚è¿½  
> åŠ ã—ã¦ãŠã„ã¦ã¯ã©ã†ã§ã—ã‚‡ã†ã‹ã€‚ã¨ã‚Šã‚ãˆãšeach\_lineã¨each\_byteã«ã¯  
> æ‰‹ã‚’å…¥ã‚Œã¦ã„ã¾ã›ã‚“ã€‚

ã€€ãã†ã§ã™ã­ã€‚IRCã§ã¤ã¶ã‚„ã„ãŸé€šã‚Šã€ 1.9 ã§ã® String#to\_a å»ƒæ­¢ã«  
ã‚ˆã£ã¦ String ã‚’è¡Œåˆ†å‰²ã™ã‚‹ãƒãƒ¼ã‚¿ãƒ–ãƒ«ã§ç°¡æ½”ãªæ‰‹æ®µã‚’å¤±ã£ãŸã®ã§ã€  
æ—©ã€…ã« lines ã‚’ãƒãƒƒã‚¯ãƒãƒ¼ãƒˆã—ãŸã„ã¨è€ƒãˆã¦ã„ã¾ã—ãŸã€‚commit ã—ã¦  
ãã ã•ã„ã€‚

ã€€ãã®ãƒ‘ãƒƒãƒã§ã‚‚è‡ªå‹•ã§ rb\_require(“enumerator”) ã—ã¦ã„ã¾ã™ãŒã€  
1.8 ã§ã‚‚ Enumerator ã‚’çµ„ã¿è¾¼ã¿åŒ–ã—ã€ RETURN\_ENUMERATOR() ã‚‚æŽ¡ç”¨  
ã™ã‚‹æ–¹å‘ã§è€ƒãˆã¦ã„ã¾ã™ã€‚each\_line/each\_byte ã¯ãã®ã¨ãã«ã€‚

ã€€ãªãŠã€ generator (1.9 ã§ã¯ fiber ã§å®Ÿè£…)éƒ¨åˆ†ã«ã¤ã„ã¦ã¯ã€æ€§èƒ½ã¯  
ã•ã¦ãŠãå®Ÿè£…é¢ã§æŠ˜ã‚Šåˆã„ãŒä»˜ãã‹ã©ã†ã‹ã§ã™ã­ã€‚ãƒãƒ£ãƒ¬ãƒ³ã‚¸ãƒ£ãƒ¼å‹Ÿé›†ã€‚

> ã‚‚ã†ä¸€ã¤ã€RSTRING\_PTR()ã‚„RSTRING\_LEN()ã¨åŒæ§˜ã€rb\_str\_set\_len()ã‚‚  
> ã‚ã£ãŸã»ã†ãŒã„ã„ã¨æ€ã„ã¾ã™ã€‚

ã€€ã“ã¡ã‚‰ã‚‚ãŠé¡˜ã„ã—ã¾ã™ã€‚

ã€€1.9.0 ãŒå‡ºãŸã®ã§ã€éžäº’æ›æ€§ã‚„å®Ÿè£…ä¸Šã®éšœå®³ãŒãªã„æ©Ÿèƒ½ã¯ã©ã‚“ã©ã‚“  
1.8 ã«ãƒãƒƒã‚¯ãƒãƒ¼ãƒˆã—ã¦ã„ãã¾ã™ã€‚ç©æ¥µçš„ã«è¦æœ›ãƒ»ææ¡ˆã‚’ãã ã•ã„ã€‚

–  
/  
/\_\_ \_\_ [Akinori.org](http://Akinori.org) / [MUSHA.org](http://MUSHA.org)  
/ ) ) ) ) / [FreeBSD.org](http://FreeBSD.org) / [Ruby-lang.org](http://Ruby-lang.org)  
Akinori MUSHA aka / (\_ / ( (\_\_( @ [iDaemons.org](http://iDaemons.org) / and.or.jp

“Different eyes see different things,  
Different hearts beat on different strings –  
But there are times for you and me when all such things agree”

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [December 28, 2007, 5:38am UTC](https://www.ruby-forum.com/t/upgrading-path-from-1-8-to-1-9/124183/3 "2007-12-28T05:38:57Z")

</div>

e$B@\>;3OB9-$G$9!#e(B

At Thu, 27 Dec 2007 06:54:54 +0900,  
Akinori MUSHA wrote:

> e$B!!e(B1.9.0 e$B$,=P$?$N$G!"Hs8\_49@-$de$N\>c32$,$J$$5!G=$O$I$s$I$se(B  
> 1.8 e$B$K%P%C%/%]!\<%H$7$F$$$-$^$9!#@Q6KE\*$KMWK\>!&Ds0F$r$/$@$5$$!#e(B

1.8.6e$B$KF~$j$=$&$GF~$i$J$+$C$?e(Bnet/smtp.rbe$B$He(Bnet/pop.rbe$B$Ne(BSSLe$BBP1~$re(B  
e$B4uK\>$7$^$9!#e(B

GC.stress, GC.stress= e$B$b4uK\>$7$^$9!#e(B
