Revision
176
Author
lsansonetti@apple.com
Date
2008-04-27 14:22:59 -0700 (Sun, 27 Apr 2008)

Log Message

fixing some regressions

Modified Paths

Diff

Modified: MacRuby/trunk/parse.y (175 => 176)


--- MacRuby/trunk/parse.y	2008-04-26 00:29:11 UTC (rev 175)
+++ MacRuby/trunk/parse.y	2008-04-27 21:22:59 UTC (rev 176)
@@ -7571,6 +7571,7 @@
 		      rb_enc_name(rb_enc_get(head)),
 		      rb_enc_name(rb_enc_get(tail)));
     }
+    RSTRING_SYNC(head);
     rb_str_buf_append(head, tail);
 }
 

Modified: MacRuby/trunk/string.c (175 => 176)


--- MacRuby/trunk/string.c	2008-04-26 00:29:11 UTC (rev 175)
+++ MacRuby/trunk/string.c	2008-04-27 21:22:59 UTC (rev 176)
@@ -208,6 +208,7 @@
 	CFIndex datalen;
 	const UInt8 *dataptr;
 	CFStringRef bytestr;
+	const char *strptr;
 
 	data = (CFDataRef)s->cfdata;
 	datalen = CFDataGetLength(data);
@@ -220,8 +221,11 @@
 		false,
 		kCFAllocatorNull);
 	CFStringReplaceAll((CFMutableStringRef)str, (CFStringRef)bytestr);
-        if (memcmp((const char *)dataptr, (const char *)RSTRING_CPTR(str), 
-	    datalen) == 0) {
+	strptr = RSTRING_CPTR(str);
+	if ((const char *)dataptr == strptr
+	    || dataptr == NULL 
+	    || strptr == NULL
+	    || memcmp((const char *)dataptr, strptr, datalen) == 0) {
 	    s->cfdata = NULL;
 	}
     }
@@ -5125,6 +5129,8 @@
 trans_replace(CFMutableStringRef str, const CFRange *result_range, 
 	      CFStringRef substr, CFRange *search_range, int sflag)
 {
+    assert(result_range->location + result_range->length 
+	<= CFStringGetLength((CFStringRef)str));
     if (sflag == 0) {
 	long n;
 	for (n = result_range->location; 
@@ -5134,9 +5140,8 @@
     }
     else {
 	CFStringReplace(str, *result_range, substr);
-	search_range->length -= result_range->length 
-	    + (result_range->location - search_range->location) - 1;
 	search_range->location = result_range->location + 1;
+	search_range->length = RSTRING_CLEN(str) - search_range->location;
     }	    
 }
 
@@ -5253,7 +5258,7 @@
     
     if (RSTRING_CLEN(str) == 0)
        return Qnil;
-   
+  
     rb_str_modify(str);
 
     _ctx.orepl = repl;