From 4333771fc3f475827fdc5b3259e9e6f4d3395df7 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 25 Mar 2009 20:10:19 -0700 Subject: [PATCH] fix compile against ruby 1.9 --- bindings/ruby/extconf.rb | 7 +++++++ bindings/ruby/rbsigar.c | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index 8271deb3..61b51da9 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -61,6 +61,13 @@ osdir = "../../src/os/#{os}" $CPPFLAGS += ' -I../../include' + ' -I' + osdir $CPPFLAGS += ' -U_FILE_OFFSET_BITS' unless is_win32 +if RUBY_VERSION > '1.8.4' + $CPPFLAGS += ' -DRB_HAS_RE_ERROR' +end +if RUBY_VERSION >= '1.9.0' + $CPPFLAGS += ' -DRB_RUBY_19' +end + #incase of nfs shared dir... unless is_win32 if File.exist?('Makefile') diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index 4464ec71..2852faf1 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -17,8 +17,12 @@ */ #include -#include -#include +#ifdef RB_RUBY_19 +#include +#else +#include +#endif + #include #include "sigar.h" #include "sigar_fileinfo.h" @@ -37,7 +41,7 @@ #define RSTRING_LEN(s) RSTRING(s)->len #endif -#if (RUBY_VERSION_MAJOR >= 1) && ((RUBY_VERSION_MINOR == 8) && (RUBY_VERSION_TEENY >= 6)) +#ifdef RB_HAS_RE_ERROR # define RB_REGEX_ERROR rb_eRegexpError #else # define RB_REGEX_ERROR rb_eArgError @@ -53,6 +57,10 @@ static sigar_t *rb_sigar_get(VALUE obj) static int rbsigar_ptql_re_impl(void *data, char *haystack, char *needle) { +#ifdef RB_RUBY_19 + /* XXX no more regex.h */ + return 0; +#else struct re_pattern_buffer *regex; int len = strlen(haystack); int retval; @@ -70,6 +78,7 @@ static int rbsigar_ptql_re_impl(void *data, retval = re_match(regex, haystack, len, 0, NULL); re_free_pattern(regex); return retval > 0; +#endif } #define sigar_isdigit(c) \