fix compile against ruby 1.9
This commit is contained in:
parent
eb05ff0760
commit
4333771fc3
|
@ -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')
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
*/
|
||||
|
||||
#include <ruby.h>
|
||||
#include <version.h>
|
||||
#include <regex.h>
|
||||
#ifdef RB_RUBY_19
|
||||
#include <ruby/re.h>
|
||||
#else
|
||||
#include <re.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#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) \
|
||||
|
|
Loading…
Reference in New Issue