]> git.wincent.com - wikitext.git/blobdiff - ext/parser.c
Conditional compilation for Ruby 1.8.x and 1.9.x
[wikitext.git] / ext / parser.c
index a38f678c757e26c668d448380f356fb037dfc2e6..dfab24e66cbb8695d178c8aa3c27a5575c51b735 100644 (file)
@@ -2591,21 +2591,14 @@ return_output:
     // 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;
@@ -2613,7 +2606,6 @@ return_output:
     RSTRING(out)->ptr = parser->output->ptr;
 #else
 #error unsupported RUBY_VERSION
-#endif
 #endif
     parser->output->ptr = NULL; // don't double-free
     return out;