diff --git a/bindings/ruby/rbsigar.c b/bindings/ruby/rbsigar.c index adfddb1c..4464ec71 100644 --- a/bindings/ruby/rbsigar.c +++ b/bindings/ruby/rbsigar.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include "sigar.h" @@ -36,6 +37,12 @@ #define RSTRING_LEN(s) RSTRING(s)->len #endif +#if (RUBY_VERSION_MAJOR >= 1) && ((RUBY_VERSION_MINOR == 8) && (RUBY_VERSION_TEENY >= 6)) +# define RB_REGEX_ERROR rb_eRegexpError +#else +# define RB_REGEX_ERROR rb_eArgError +#endif + static sigar_t *rb_sigar_get(VALUE obj) { sigar_t *sigar; @@ -56,7 +63,7 @@ static int rbsigar_ptql_re_impl(void *data, /* XXX cache */ if ((err = re_compile_pattern(needle, strlen(needle), regex))) { re_free_pattern(regex); - rb_raise(rb_eRegexpError, "%s", err); + rb_raise(RB_REGEX_ERROR, "%s", err); return 0; }