summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2010-05-02 17:52:59 -0700
committerRuss Allbery <rra@stanford.edu>2010-05-02 17:52:59 -0700
commit00a10fbee30015435364fb39ac71479ab87e8003 (patch)
tree27dfe085af038f86fcde7d3e3a68aa1f32c82a17 /ruby
parent40f23e6445961c356d266e15d63b08eaac277946 (diff)
Add support for Ruby 1.9.1
The signature of rb_cvar_set has changed between 1.8 and 1.9.1. Prefer the 1.9.1 version and use a hack to try to detect Ruby 1.8 and add the fourth argument when building against that version.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/README4
-rw-r--r--ruby/remctl.c18
2 files changed, 16 insertions, 6 deletions
diff --git a/ruby/README b/ruby/README
index 4c10691..f6469ed 100644
--- a/ruby/README
+++ b/ruby/README
@@ -14,8 +14,8 @@ OVERVIEW
REQUIREMENTS
- The module has been tested with Ruby 1.8 and may not work with older
- (or newer) versions of Ruby.
+ The module has been tested with Ruby 1.8 and 1.9.1 and may not work with
+ older (or newer) versions of Ruby.
SIMPLIFIED INTERFACE
diff --git a/ruby/remctl.c b/ruby/remctl.c
index be4456f..5718b35 100644
--- a/ruby/remctl.c
+++ b/ruby/remctl.c
@@ -44,6 +44,16 @@
#undef PACKAGE_BUGREPORT
#include <ruby.h>
+/*
+ * Ruby 1.9 changed the call signature for rb_cvar_set. Ruby 1.8 used to
+ * define useful variables like RUBY_VERSION_MAJOR, but of course Ruby 1.9
+ * removed them all, so we use this hack instead; hopefully it will work for
+ * all the versions that people care about.
+ */
+#ifndef HAVE_RUBY_DEFINES_H
+# define rb_cvar_set(a, b, c) rb_cvar_set((a), (b), (c), 0)
+#endif
+
/* Our public interface. */
void Init_remctl(void);
@@ -188,7 +198,7 @@ rb_remctl_default_port_set(VALUE self UNUSED, VALUE new)
if (port > 65535)
rb_raise(rb_eArgError, "Port number %u out of range", port);
else
- rb_cvar_set(cRemctl, AAdefault_port, new, 0);
+ rb_cvar_set(cRemctl, AAdefault_port, new);
return rb_cvar_get(cRemctl, AAdefault_port);
}
@@ -215,7 +225,7 @@ rb_remctl_default_principal_get(VALUE self UNUSED)
static VALUE
rb_remctl_default_principal_set(VALUE self UNUSED, VALUE new)
{
- rb_cvar_set(cRemctl, AAdefault_principal, StringValue(new), 0);
+ rb_cvar_set(cRemctl, AAdefault_principal, StringValue(new));
return rb_cvar_get(cRemctl, AAdefault_principal);
}
@@ -436,8 +446,8 @@ Init_remctl(void)
Aprincipal = rb_intern("@principal");
/* Default values for class variables. */
- rb_cvar_set(cRemctl, AAdefault_port, UINT2NUM(0), 0);
- rb_cvar_set(cRemctl, AAdefault_principal, Qnil, 0);
+ rb_cvar_set(cRemctl, AAdefault_port, UINT2NUM(0));
+ rb_cvar_set(cRemctl, AAdefault_principal, Qnil);
/* Getter and setter methods for class variables. */
rb_define_singleton_method(cRemctl, "default_port",