exit 1
end
+case RUBY_VERSION
+when /\A1\.8/
+ $CFLAGS += ' -DRUBY_1_8_x'
+when /\A1\.9/
+ $CFLAGS += ' -DRUBY_1_9_x'
+else
+ raise "unsupported Ruby version: #{RUBY_VERSION}"
+end
+
have_header('ruby.h') or missing 'ruby.h'
create_makefile('wikitext')
// nasty hack to avoid re-allocating our return value
str_append(parser->output, null_str, 1); // null-terminate
len = parser->output->len - 1; // don't count null termination
-#ifndef RUBY_VERSION
-#error RUBY_VERSION not defined
-#else
-// unfortunately this version check doesn't work properly in 1.9
-// (version.h not installed with 1.9, so likely other sytem-installed version.h gets picked up)
-#if RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 9
- // Ruby 1.9.x
+#if defined(RUBY_1_9_x)
VALUE out = rb_str_buf_new(RSTRING_EMBED_LEN_MAX + 1);
free(RSTRING_PTR(out));
RSTRING(out)->as.heap.aux.capa = len;
RSTRING(out)->as.heap.ptr = parser->output->ptr;
RSTRING(out)->as.heap.len = len;
-#elif RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 8
- // Ruby 1.8.x
+#elif defined(RUBY_1_8_x)
VALUE out = rb_str_new2("");
free(RSTRING_PTR(out));
RSTRING(out)->len = len;
RSTRING(out)->ptr = parser->output->ptr;
#else
#error unsupported RUBY_VERSION
-#endif
#endif
parser->output->ptr = NULL; // don't double-free
return out;