[macruby-changes] [168] MacRuby/trunk/re.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 23 19:53:43 PDT 2008


Revision: 168
          http://trac.macosforge.org/projects/ruby/changeset/168
Author:   lsansonetti at apple.com
Date:     2008-04-23 19:53:42 -0700 (Wed, 23 Apr 2008)

Log Message:
-----------
fixing #quote

Modified Paths:
--------------
    MacRuby/trunk/re.c

Modified: MacRuby/trunk/re.c
===================================================================
--- MacRuby/trunk/re.c	2008-04-24 01:21:55 UTC (rev 167)
+++ MacRuby/trunk/re.c	2008-04-24 02:53:42 UTC (rev 168)
@@ -2649,13 +2649,14 @@
 rb_reg_quote(VALUE str)
 {
     rb_encoding *enc = rb_enc_get(str);
-    char *s, *send, *t;
+    const char *s, *send;
+    char *t;
     VALUE tmp;
     int c, clen;
     int ascii_only = rb_enc_str_asciionly_p(str);
 
-    s = RSTRING_PTR(str);
-    send = s + RSTRING_LEN(str);
+    s = RSTRING_CPTR(str);
+    send = s + RSTRING_CLEN(str);
     while (s < send) {
         c = rb_enc_ascget(s, send, &clen, enc);
 	if (c == -1) {
@@ -2680,7 +2681,7 @@
     return str;
 
   meta_found:
-    tmp = rb_str_new(0, RSTRING_LEN(str)*2);
+    tmp = rb_str_new(0, RSTRING_CLEN(str)*2);
     if (ascii_only) {
         rb_enc_associate(tmp, rb_usascii_encoding());
     }
@@ -2689,8 +2690,8 @@
     }
     t = RSTRING_PTR(tmp);
     /* copy upto metacharacter */
-    memcpy(t, RSTRING_PTR(str), s - RSTRING_PTR(str));
-    t += s - RSTRING_PTR(str);
+    memcpy(t, RSTRING_CPTR(str), s - RSTRING_CPTR(str));
+    t += s - RSTRING_CPTR(str);
 
     while (s < send) {
         c = rb_enc_ascget(s, send, &clen, enc);
@@ -2738,6 +2739,7 @@
 	*t++ = c;
     }
     rb_str_resize(tmp, t - RSTRING_PTR(tmp));
+    RSTRING_SYNC(tmp);
     OBJ_INFECT(tmp, str);
     return tmp;
 }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080423/68d29861/attachment.html


More information about the macruby-changes mailing list