summaryrefslogtreecommitdiff
path: root/textproc/eruby/files/patch-eruby_lib.c
blob: 2e61e35a55b2b68d4efe2cfa5ad39becddb68fcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--- eruby_lib.c.orig	2012-01-22 14:43:16.000000000 +0100
+++ eruby_lib.c	2012-01-22 15:27:01.000000000 +0100
@@ -34,12 +34,24 @@
 #include <signal.h>
 
 #include "ruby.h"
-#include "regex.h"
 #include "eruby.h"
 #include "config.h"
 
+#if defined(WITH_RUBY_19)
+#include "ruby/regex.h"
+#undef ismbchar
+#define ismbchar(c,e,enc)	((mbclen(c,e,enc)) != 1)
+#define	ruby_top_self	rb_vm_top_self
+#else
+#include "regex.h"
+#endif
+
 EXTERN VALUE rb_stdin;
+#if defined(WITH_RUBY_19)
+#define	ruby_top_self	rb_errinfo()
+#else
 EXTERN VALUE ruby_top_self;
+#endif
 
 static VALUE mERuby;
 static VALUE cERubyCompiler;
@@ -144,6 +156,7 @@
 	    }
 	    s++;
 	    goto again;
+#if !defined(WITH_RUBY_19)
 	case 'K':
 	    s++;
 	    if (*s == '\0') {
@@ -153,6 +166,7 @@
 	    rb_set_kcode(s);
 	    s++;
 	    goto again;
+#endif
 	case 'C':
 	    s++;
 	    if (isspace(*s)) s++;
@@ -397,7 +411,7 @@
 static void compile_error(eruby_compiler_t *compiler, char *msg)
 {
     rb_raise(eERubyCompileError, "%s:%d:%s",
-	     STR2CSTR(compiler->sourcefile), compiler->sourceline, msg);
+	     StringValuePtr(compiler->sourcefile), compiler->sourceline, msg);
 }
 
 static void parse_embedded_program(eruby_compiler_t *compiler,
@@ -592,8 +606,13 @@
 		if (prevc < 0) output_literal(compiler, "print \"");
 		output_char(compiler, c);
 		prevc = c;
+#if defined(WITH_RUBY_19)
+                if (ismbchar(c,c+4,OnigEncDefaultCharEncoding)) {
+                    int i, len = mbclen(c,c,OnigEncDefaultCharEncoding) - 1;
+#else
                 if (ismbchar(c)) {
                     int i, len = mbclen(c) - 1;
+#endif
                     
                     for (i = 0; i < len; i++) {
                         c = nextc(compiler);
@@ -697,7 +716,7 @@
     VALUE compiler, file, code;
 
     compiler = eruby_compiler_new();
-    file = rb_file_open(STR2CSTR(filename), "r");
+    file = rb_file_open(StringValuePtr(filename), "r");
     code = eruby_compiler_compile_file(compiler, file);
     rb_funcall(ruby_top_self, rb_intern("eval"), 3, code, Qnil, filename);
     return Qnil;