Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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")`)



git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4197 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit 4f575319b44abb1cbbe6cd156542bb2f7860a815 1 parent 0f85d83
Thibault Martin-Lagardette authored
Showing with 54 additions and 7 deletions.
  1. +14 −2 object.c
  2. +39 −4 util.c
  3. +1 −1  version.h
View
16 object.c
@@ -2595,11 +2595,19 @@ rb_cstr_to_dbl(const char *p, int badcheck)
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 @@ rb_cstr_to_dbl(const char *p, int badcheck)
}
*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 @@ rb_cstr_to_dbl(const char *p, int badcheck)
}
return d;
}
-
double
rb_str_to_dbl(VALUE str, int badcheck)
{
View
43 util.c
@@ -2212,10 +2212,45 @@ ruby_strtod(const char *s00, char **se)
}
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;
View
2  version.h
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.