fix compile against ruby 1.8.4

This commit is contained in:
Doug MacEachern 2009-03-25 14:58:06 -07:00
parent 6819b18af6
commit eb05ff0760
1 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,7 @@
*/
#include <ruby.h>
#include <version.h>
#include <regex.h>
#include <errno.h>
#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;
}