[macruby-changes] [4197] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 3 11:56:41 PDT 2010


Revision: 4197
          http://trac.macosforge.org/projects/ruby/changeset/4197
Author:   martinlagardette at apple.com
Date:     2010-06-03 11:56:39 -0700 (Thu, 03 Jun 2010)
Log Message:
-----------
Macruby is not serving Ruby 1.9.2!

 - Backported a ruby 1.9.2 change to allow hexadecimal strings in `Float` constructor (like `Float("0xA")`)

Modified Paths:
--------------
    MacRuby/trunk/object.c
    MacRuby/trunk/util.c
    MacRuby/trunk/version.h

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2010-06-03 18:21:54 UTC (rev 4196)
+++ MacRuby/trunk/object.c	2010-06-03 18:56:39 UTC (rev 4197)
@@ -2595,11 +2595,19 @@
     double d;
     const char *ellipsis = "";
     int w;
-#define OutOfRange() (((w = end - p) > 20) ? (w = 20, ellipsis = "...") : (ellipsis = ""))
+    enum {max_width = 20};
+#define OutOfRange() ((end - p > max_width) ? \
+		      (w = max_width, ellipsis = "...") : \
+		      (w = (int)(end - p), ellipsis = ""))
 
     if (!p) return 0.0;
     q = p;
     while (ISSPACE(*p)) p++;
+
+    if (!badcheck && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+	return 0.0;
+    }
+
     d = strtod(p, &end);
     if (errno == ERANGE) {
 	OutOfRange();
@@ -2638,6 +2646,11 @@
 	}
 	*n = '\0';
 	p = buf;
+
+	if (!badcheck && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+	    return 0.0;
+	}
+
 	d = strtod(p, &end);
 	if (errno == ERANGE) {
 	    OutOfRange();
@@ -2657,7 +2670,6 @@
     }
     return d;
 }
-
 double
 rb_str_to_dbl(VALUE str, int badcheck)
 {

Modified: MacRuby/trunk/util.c
===================================================================
--- MacRuby/trunk/util.c	2010-06-03 18:21:54 UTC (rev 4196)
+++ MacRuby/trunk/util.c	2010-06-03 18:56:39 UTC (rev 4197)
@@ -2212,10 +2212,45 @@
         }
 break2:
     if (*s == '0') {
-        nz0 = 1;
-        while (*++s == '0') ;
-        if (!*s)
-            goto ret;
+      if (s[1] == 'x' || s[1] == 'X') {
+	  static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
+	  s0 = ++s;
+	  adj = 0;
+
+	  while (*++s && (s1 = strchr(hexdigit, *s))) {
+	      adj *= 16;
+	      adj += (s1 - hexdigit) & 15;
+	  }
+
+	  if (*s == '.') {
+	      aadj = 1.;
+	      while (*++s && (s1 = strchr(hexdigit, *s))) {
+		  aadj /= 16;
+		  adj += aadj * ((s1 - hexdigit) & 15);
+	      }
+	  }
+
+	  if (*s == 'P' || *s == 'p') {
+	      dsign = 0x2C - *++s; /* +: 2B, -: 2D */
+	      if (abs(dsign) == 1) s++;
+	      else dsign = 1;
+
+	      for (nd = 0; (c = *s) >= '0' && c <= '9'; s++) {
+		  nd *= 10;
+		  nd += c;
+		  nd -= '0';
+	      }
+	      dval(rv) = ldexp(adj, nd * dsign);
+	  }
+	  else {
+	      dval(rv) = adj;
+	  }
+	  goto ret;
+      }
+      nz0 = 1;
+      while (*++s == '0') ;
+      if (!*s)
+	  goto ret;
     }
     s0 = s;
     y = z = 0;

Modified: MacRuby/trunk/version.h
===================================================================
--- MacRuby/trunk/version.h	2010-06-03 18:21:54 UTC (rev 4196)
+++ MacRuby/trunk/version.h	2010-06-03 18:56:39 UTC (rev 4197)
@@ -1,7 +1,7 @@
 #define RUBY_ENGINE 		"macruby"
 #define MACRUBY_VERSION 	"0.7"
 
-#define RUBY_VERSION 		"1.9.0"
+#define RUBY_VERSION 		"1.9.2"
 #define RUBY_RELEASE_DATE 	"2008-06-03"
 #define RUBY_VERSION_CODE 	190
 #define RUBY_RELEASE_CODE 	20080603
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100603/c8461788/attachment.html>


More information about the macruby-changes mailing list