Package: ruby-mkrf / 0.2.3+dfsg-5

0610_fix_test_syck.patch Patch series | download
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Description: Port syck example to Ruby1.9
Author: C├ędric Boutillier <cedric.boutillier@gmail.com>
Last-Update: 2012-07-04

--- a/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb
+++ b/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb
@@ -5,5 +5,5 @@
 end
 
 Mkrf::Generator.new('syck') do |g|
-  g.include_header("st.h")
+  g.include_header("ruby/backward/st.h")
 end
--- a/test/sample_files/syck-0.55/lib/syck.h
+++ b/test/sample_files/syck-0.55/lib/syck.h
@@ -20,6 +20,8 @@
 #include <ctype.h>
 #ifdef HAVE_ST_H
 #include <st.h>
+#elif HAVE_RUBY_BACKWARD_ST_H
+#include <ruby/backward/st.h>
 #else
 #include "syck_st.h"
 #endif
--- a/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c
+++ b/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c
@@ -154,8 +154,8 @@
         if (!NIL_P(str2))
         {
             StringValue(str2);
-            len = RSTRING(str2)->len;
-            memcpy( buf + skip, RSTRING(str2)->ptr, len );
+            len = RSTRING_LEN(str2);
+            memcpy( buf + skip, RSTRING_PTR(str2), len );
         }
     }
     len += skip;
@@ -177,7 +177,7 @@
     if (!NIL_P(tmp = rb_check_string_type(port))) {
         taint = OBJ_TAINTED(port); /* original taintedness */
         port = tmp;
-        syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
+        syck_parser_str( parser, RSTRING_PTR(port), RSTRING_LEN(port), NULL );
     }
     else if (rb_respond_to(port, s_read)) {
         if (rb_respond_to(port, s_binmode)) {
@@ -634,7 +634,7 @@
     if ( bonus->taint)      OBJ_TAINT( obj );
     if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
 
-    rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
+    rb_hash_aset(bonus->data, INT2FIX(RHASH_TBL(bonus->data)->num_entries), obj);
     return obj;
 }
 
@@ -1032,10 +1032,10 @@
     VALUE ivname = rb_ary_entry( vars, 0 );
     char *ivn;
     StringValue( ivname );
-    ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 );
+    ivn = S_ALLOC_N( char, RSTRING_LEN(ivname) + 2 );
     ivn[0] = '@';
     ivn[1] = '\0';
-    strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len );
+    strncat( ivn, RSTRING_PTR(ivname), RSTRING_LEN(ivname) );
     rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
     S_FREE( ivn );
     return Qnil;
@@ -1051,7 +1051,7 @@
     VALUE tclass = rb_cObject;
     VALUE tparts = rb_str_split( const_name, "::" );
     int i = 0;
-    for ( i = 0; i < RARRAY(tparts)->len; i++ ) {
+    for ( i = 0; i < RARRAY_LEN(tparts); i++ ) {
         VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
         if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
         tclass = rb_const_get( tclass, tpart );
@@ -1066,12 +1066,12 @@
 syck_resolver_transfer( self, type, val )
     VALUE self, type, val;
 {
-    if (NIL_P(type) || RSTRING(StringValue(type))->len == 0) 
+    if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) 
     {
         type = rb_funcall( self, s_detect_implicit, 1, val );
     }
 
-    if ( ! (NIL_P(type) || RSTRING(StringValue(type))->len == 0) )
+    if ( ! (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) )
     {
         VALUE str_xprivate = rb_str_new2( "x-private" );
         VALUE colon = rb_str_new2( ":" );
@@ -1088,7 +1088,7 @@
             VALUE subclass_parts = rb_ary_new();
             VALUE parts = rb_str_split( type, ":" );
 
-            while ( RARRAY(parts)->len > 1 )
+            while ( RARRAY_LEN(parts) > 1 )
             {
                 VALUE partial;
                 rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
@@ -1106,7 +1106,7 @@
                 if ( ! NIL_P( target_class ) )
                 {
                     subclass = target_class;
-                    if ( RARRAY(subclass_parts)->len > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
+                    if ( RARRAY_LEN(subclass_parts) > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
                          RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
                     {
                         VALUE subclass_v;
@@ -1121,7 +1121,7 @@
                         else if ( rb_cObject == target_class && subclass_v == Qnil )
                         {
                             // StringValue(subclass);
-                            // printf( "No class: %s\n", RSTRING(subclass)->ptr );
+                            // printf( "No class: %s\n", RSTRING_PTR(subclass) );
                             target_class = cYObject;
                             type = subclass;
                             subclass = cYObject;
@@ -1194,7 +1194,7 @@
     {
         char *taguri;
         val = tmp;
-        taguri = syck_type_id_to_uri( RSTRING(val)->ptr );
+        taguri = syck_type_id_to_uri( RSTRING_PTR(val) );
         return rb_str_new2( taguri );
     }
 
@@ -1214,7 +1214,7 @@
     if ( !NIL_P(tmp) )
     {
         val = tmp;
-        type_id = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
+        type_id = syck_match_implicit( RSTRING_PTR(val), RSTRING_LEN(val) );
         return rb_str_new2( type_id );
     }
 
@@ -1517,8 +1517,8 @@
     Data_Get_Struct( self, SyckNode, node );
 
     StringValue( val );
-    node->data.str->ptr = RSTRING(val)->ptr;
-    node->data.str->len = RSTRING(val)->len;
+    node->data.str->ptr = RSTRING_PTR(val);
+    node->data.str->len = RSTRING_LEN(val);
     node->data.str->style = scalar_none;
 
     rb_iv_set( self, "@value", val );
@@ -1571,7 +1571,7 @@
     if ( !NIL_P( val ) ) {
         int i;
         syck_seq_empty( node );
-        for ( i = 0; i < RARRAY( val )->len; i++ )
+        for ( i = 0; i < RARRAY_LEN( val ); i++ )
         {
             syck_seq_add( node, rb_ary_entry(val, i) );
         }
@@ -1660,7 +1660,7 @@
         }
 
         keys = rb_funcall( hsh, s_keys, 0 );
-        for ( i = 0; i < RARRAY(keys)->len; i++ )
+        for ( i = 0; i < RARRAY_LEN(keys); i++ )
         {
             VALUE key = rb_ary_entry(keys, i);
             syck_map_add( node, key, rb_hash_aref(hsh, key) );
@@ -1696,7 +1696,7 @@
 
         syck_map_empty( node );
         keys = rb_funcall( hsh, s_keys, 0 );
-        for ( i = 0; i < RARRAY(keys)->len; i++ )
+        for ( i = 0; i < RARRAY_LEN(keys); i++ )
         {
             VALUE key = rb_ary_entry(keys, i);
             syck_map_add( node, key, rb_hash_aref(hsh, key) );
--- a/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h
+++ b/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h
@@ -20,6 +20,8 @@
 #include <ctype.h>
 #ifdef HAVE_ST_H
 #include <st.h>
+#elif HAVE_RUBY_BACKWARD_ST_H
+#include <ruby/backward/st.h>
 #else
 #include "syck_st.h"
 #endif