[#4745] Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...>

Having taken upon me the task to provide a Windows build for

24 messages 2005/04/20
[#4746] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Austin Ziegler <halostatue@...> 2005/04/20

On 4/20/05, Erik Huelsmann <ehuels@gmail.com> wrote:

[#4747] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/20

Hi Austin,

[#4762] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — nobu.nokada@... 2005/04/24

Hi,

[#4783] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/25

On 4/24/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:

[#4787] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — nobu.nokada@... 2005/04/25

Hi,

[#4794] Re: Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...> 2005/04/25

> > > Ruby is just using AC_TYPE_UID_T. So, using typedef for them,

[#4751] Illegal regexp causes segfault — Andrew Walrond <andrew@...>

irb(main):058:0> a = /\[([^]]*)\]/

13 messages 2005/04/22

[PATCH] for [ #1823 ] NUM2UINT and rb_num2ull do not rase RangeError for negative Fixnum

From: Michael Schonberg <mschonberg@...>
Date: 2005-04-29 21:41:21 UTC
List: ruby-core #4820
All,

I submitted bug 1823 while anonymous CVS was unavailable; however, now
that I can access CVS, I went ahead and applied the fix that I proposed
and it works well with my extension.

To summarize, the problem is that NUM2UINT and rb_num2ull accept
negative Fixnum's while unsigned ints and long longs can not be less
than zero. For numbers that are larger than the largest unsigned int or
long long these methods correctly raise a RangeError. For the sake of
consistency and correctness they should raise a RangeError when the
value is less than 0 as well.

It is simple enough to work around this problem in my extension;
however, the fact that everything behaves so predictably is one of the
aspects of writing Ruby extensions that impresses me the most. I am just
getting started with Ruby and writing extensions, and this is the only
problem to date.

Regards,
Michael Schonberg
mschonberg@pacbell.net

Attachments (2)

numeric_patch (708 Bytes, text/plain)
--- numeric.c.orig	2005-04-29 21:27:54.000000000 +0000
+++ numeric.c	2005-04-29 21:27:35.000000000 +0000
@@ -1536,6 +1536,10 @@
 {
     if (TYPE(val) == T_BIGNUM) {
 	return rb_big2ulong(val);
+    }
+    /* Check the sign bit */
+    else if (FIXNUM_P(val) && (val & 0x04000000)) {
+	rb_raise( rb_eRangeError, "unsigned int can not be less than 0" );
     }
     return (unsigned long)rb_num2long(val);
 }
@@ -1697,6 +1701,10 @@
     if (TYPE(val) == T_BIGNUM) {
 	return rb_big2ull(val);
     }
+    /* Check the sign bit */
+    else if (FIXNUM_P(val) && (val & 0x04000000)) {
+	rb_raise( rb_eRangeError, "unsigned int can not be less than 0" );
+    }
     return (unsigned LONG_LONG)rb_num2ll(val);
 }

signature.asc (251 Bytes, application/pgp-signature)

In This Thread