summaryrefslogtreecommitdiff
path: root/textproc/eruby/files/patch-eruby_lib.c
blob: 1a37eeed050bb6196477973a4b092c38ce101a5d (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- eruby_lib.c.orig	2003-07-29 05:42:56.000000000 +0200
+++ eruby_lib.c	2009-06-30 12:42:12.000000000 +0200
@@ -34,10 +34,18 @@
 #include <signal.h>
 
 #include "ruby.h"
-#include "regex.h"
 #include "eruby.h"
 #include "config.h"
 
+#if defined(RFLOAT_VALUE)
+#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;
 EXTERN VALUE ruby_top_self;
 
@@ -133,6 +141,7 @@
 	    }
 	    s++;
 	    goto again;
+#if !defined(RFLOAT_VALUE)
 	case 'K':
 	    s++;
 	    if (*s == '\0') {
@@ -142,6 +151,7 @@
 	    rb_set_kcode(s);
 	    s++;
 	    goto again;
+#endif
 	case 'C':
 	    s++;
 	    if (isspace(*s)) s++;
@@ -296,18 +306,18 @@
     VALUE s = compiler->lex_input;
     char *beg, *end, *pend;
 
-    if (RSTRING(s)->len == compiler->lex_gets_ptr)
+    if (RSTRING_LEN(s) == compiler->lex_gets_ptr)
 	return Qnil;
-    beg = RSTRING(s)->ptr;
+    beg = RSTRING_PTR(s);
     if (compiler->lex_gets_ptr > 0) {
 	beg += compiler->lex_gets_ptr;
     }
-    pend = RSTRING(s)->ptr + RSTRING(s)->len;
+    pend = RSTRING_PTR(s) + RSTRING_LEN(s);
     end = beg;
     while (end < pend) {
 	if (*end++ == '\n') break;
     }
-    compiler->lex_gets_ptr = end - RSTRING(s)->ptr;
+    compiler->lex_gets_ptr = end - RSTRING_PTR(s);
     return rb_str_new(beg, end - beg);
 }
 
@@ -326,8 +336,8 @@
 
 	    if (NIL_P(v)) return EOF;
 	    compiler->sourceline++;
-	    compiler->lex_pbeg = compiler->lex_p = RSTRING(v)->ptr;
-	    compiler->lex_pend = compiler->lex_p + RSTRING(v)->len;
+	    compiler->lex_pbeg = compiler->lex_p = RSTRING_PTR(v);
+	    compiler->lex_pend = compiler->lex_p + RSTRING_LEN(v);
 	    compiler->lex_lastline = v;
 	}
 	else {
@@ -471,7 +481,7 @@
 	if (c == '!') {
 	    unsigned char *p;
 	    char *argv[2];
-	    char *line = RSTRING(compiler->lex_lastline)->ptr;
+	    char *line = RSTRING_PTR(compiler->lex_lastline);
 
 	    if (line[strlen(line) - 1] == '\n') {
 		line[strlen(line) - 1] = '\0';
@@ -577,8 +587,13 @@
 		if (prevc < 0) output_literal(compiler, "print \"");
 		output_char(compiler, c);
 		prevc = c;
+#if defined(RFLOAT_VALUE)
+                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);