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) \