File: 0001-Update-extconf-and-Add-support-for-Ruby-1.9.2.patch

package info (click to toggle)
ruby-pgplot 0.1.3-6
  • links: PTS, VCS
  • area: contrib
  • in suites: wheezy
  • size: 480 kB
  • sloc: ruby: 1,382; ansic: 73; makefile: 37
file content (311 lines) | stat: -rw-r--r-- 9,966 bytes parent folder | download | duplicates (2)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
From: Youhei SASAKI <uwabami@gfd-dennou.org>
Date: Fri, 1 Jun 2012 18:17:00 +0900
Subject: Update extconf and Add support for Ruby 1.9.2

---
 cogen.rb       |    2 +-
 extconf.rb     |    4 ++--
 kwarg.c        |   23 +++++++++++++++++---
 rb_pgplot.c.in |   65 +++++++++++++++++++++++++++++++++++---------------------
 4 files changed, 64 insertions(+), 30 deletions(-)

diff --git a/cogen.rb b/cogen.rb
index d5d526a..2494f5f 100644
--- a/cogen.rb
+++ b/cogen.rb
@@ -97,7 +97,7 @@ def pgfuncgen(name, inp, out)
   ninp = inp.size
   nout = out.size
   # int->0, float->1
-  val2 = ["NUM2INT","NUM2DBL","STR2CSTR"]
+  val2 = ["NUM2INT","NUM2DBL","StringValuePtr"]
   type = ["int","float",nil]
   conv = ["INT2NUM","rb_float_new",nil]
   # Initialize Array
diff --git a/extconf.rb b/extconf.rb
index 3fabb54..39752c6 100644
--- a/extconf.rb
+++ b/extconf.rb
@@ -34,10 +34,10 @@ dir_config("pgplot")
 exit unless have_header("cpgplot.h")
 
 # Check NArray
-$CPPFLAGS = " -I#{CONFIG['sitearchdir']} "+$CPPFLAGS
+$CPPFLAGS = " -I#{CONFIG['vendorarchdir']} "+$CPPFLAGS
 exit unless have_header("narray.h")
 if RUBY_PLATFORM =~ /cygwin|mingw/
-  $LDFLAGS = " -L#{CONFIG['sitearchdir']} "+$LDFLAGS
+  $LDFLAGS = " -L#{CONFIG['archdir']} "+$LDFLAGS
   exit unless have_library("narray","na_make_object")
 end
 
diff --git a/kwarg.c b/kwarg.c
index a03630c..0620ec2 100644
--- a/kwarg.c
+++ b/kwarg.c
@@ -9,6 +9,23 @@
    NO WARRANTY.
 */
 #include <ruby.h>
+#ifndef RUBY_19
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(a) (RSTRING(a)->ptr)
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(a) (RSTRING(a)->len)
+#endif
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+#ifndef StringValuePtr
+#define StringValuePtr(s) STR2CSTR(s)
+#endif
+#endif
 
 /* void rb_scan_kw_args __((VALUE, ...)); */
 
@@ -18,7 +35,7 @@ kw_hash_i(i, tmp)
 {
   VALUE key;
 
-  key = RARRAY(i)->ptr[0];
+  key = RARRAY_PTR(i)[0];
   if (TYPE(key)==T_SYMBOL) {
     key = rb_funcall(key, rb_intern("id2name"), 0);
   } else
@@ -26,7 +43,7 @@ kw_hash_i(i, tmp)
     rb_raise(rb_eArgError, "keywords must be String or Symbol");
   }
 
-  rb_hash_aset(tmp, key, RARRAY(i)->ptr[1]);
+  rb_hash_aset(tmp, key, RARRAY_PTR(i)[1]);
   return Qnil;
 }
 
@@ -71,7 +88,7 @@ rb_scan_kw_args(hash, va_alist)
   if (rb_funcall(tmp, rb_intern("empty?"), 0)==Qfalse) {
     val = rb_funcall(tmp, rb_intern("keys"), 0);
     val = rb_funcall(val, rb_intern("join"), 1, rb_str_new2(","));
-    rb_raise(rb_eArgError, "unknown keywords: %s",STR2CSTR(val));
+    rb_raise(rb_eArgError, "unknown keywords: %s",StringValuePtr(val));
   }
 
   va_end(vargs);
diff --git a/rb_pgplot.c.in b/rb_pgplot.c.in
index f9a8cfe..ded737f 100644
--- a/rb_pgplot.c.in
+++ b/rb_pgplot.c.in
@@ -11,6 +11,23 @@
 #include <stdio.h>
 #include <cpgplot.h>
 #include <ruby.h>
+#ifndef RUBY_19
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(a) (RSTRING(a)->ptr)
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(a) (RSTRING(a)->len)
+#endif
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+#ifndef StringValuePtr
+#define StringValuePtr(s) STR2CSTR(s)
+#endif
+#endif
 #include "narray.h"
 
 #define min(a,b) (((a)<(b))?(a):(b))
@@ -89,7 +106,7 @@ static VALUE
   char *dev="?";
 
   rb_scan_args(argc,argv, "01", &vdev);
-  if (vdev!=Qnil) dev = STR2CSTR(vdev);
+  if (vdev!=Qnil) dev = StringValuePtr(vdev);
 
   return INT2NUM(cpgopen(dev));
 }
@@ -104,7 +121,7 @@ static VALUE
   char  *dev="?";
 
   rb_scan_args(argc, argv, "03", &vdev,&vnxs,&vnys);
-  if (vdev!=Qnil) dev  = STR2CSTR(vdev);
+  if (vdev!=Qnil) dev  = StringValuePtr(vdev);
   if (vnxs!=Qnil) nxsub = NUM2INT(vnxs);
   if (vnys!=Qnil) nysub = NUM2INT(vnys);
 
@@ -124,7 +141,7 @@ static VALUE
      just: if just=1, the x and y axes is scaled equally,
            otherwise scaled independently.
      axis: controls of axes.
-*/ 
+*/
 static VALUE
   rb_pgplot_pgenv( int argc, VALUE *argv, VALUE self )
 {
@@ -309,14 +326,14 @@ static void
 /* PGERRB -- horizontal or vertical error bar
    pgerrb, dir, x, y, err [,tlen]
 
-   dir : direction to plot the error bar relative to the data point. 
+   dir : direction to plot the error bar relative to the data point.
          One-sided error bar:
            DIR is 1 for +X (X to X+E);
                   2 for +Y (Y to Y+E);
                   3 for -X (X to X-E);
                   4 for -Y (Y to Y-E).
          Two-sided error bar:
-           DIR is 5 for +/-X (X-E to X+E); 
+           DIR is 5 for +/-X (X-E to X+E);
                   6 for +/-Y (Y-E to Y+E).
    x   : world x-coordinates of the data.
    y   : world y-coordinates of the data.
@@ -500,9 +517,9 @@ static VALUE
   return Qtrue;
 }
 
-/* PGCONL -- label contour map of a 2D data array 
+/* PGCONL -- label contour map of a 2D data array
    pgconl, map, cont, label [,intval, minint, tr]
-   map    : 2-D array of map data 
+   map    : 2-D array of map data
    cont   : contour level tobe labeld
    label  : label string
    intval : spacing along the contour between labels, in grid cells.
@@ -531,7 +548,7 @@ static VALUE
   /* Show Contour */
   cpgconl( NA_PTR_FLT(na_map), NA_SHAPE0(na_map), NA_SHAPE1(na_map),
 	   1, NA_SHAPE0(na_map), 1, NA_SHAPE1(na_map),
-	   NUM2DBL(vcnt), tr, STR2CSTR(vlab), intval, minint);
+	   NUM2DBL(vcnt), tr, StringValuePtr(vlab), intval, minint);
   return Qtrue;
 }
 
@@ -624,7 +641,7 @@ static VALUE
   else
     cpggray( NA_PTR_FLT(na), NA_SHAPE0(na), NA_SHAPE1(na),
 	     1, NA_SHAPE0(na), 1, NA_SHAPE1(na),
-	     range[0], range[1], tr );    
+	     range[0], range[1], tr );
   return Qtrue;
 }
 
@@ -774,7 +791,7 @@ static VALUE
   int   value_len=20;
   char *item, *value;
 
-  item  = STR2CSTR(vitem);
+  item  = StringValuePtr(vitem);
   value = ALLOCA_N(char,value_len);
   cpgqinf( item, value, &value_len );
 
@@ -819,7 +836,7 @@ static VALUE
   VALUE vx,vy;
   int i;
   float xbox[4], ybox[4];
-  char *txt = STR2CSTR(text);
+  char *txt = StringValuePtr(text);
 
   cpgqtxt( NUM2DBL(x),NUM2DBL(y),NUM2DBL(ang),NUM2DBL(fjust),txt,
 	   xbox, ybox );
@@ -979,7 +996,7 @@ static VALUE
   if (NA_TYPE(x)!=NA_SFLOAT || NA_TYPE(y)!=NA_SFLOAT)
     rb_raise(rb_eArgError, "Array must NArray.sfloat");
 
-  cpgolin( min(NA_TOTAL(x),NA_TOTAL(y)), &npt, 
+  cpgolin( min(NA_TOTAL(x),NA_TOTAL(y)), &npt,
 	   NA_PTR_FLT(x), NA_PTR_FLT(y), sym );
 
   return INT2NUM(npt);
@@ -1009,7 +1026,7 @@ static VALUE
   if (NA_TYPE(x)!=NA_SFLOAT || NA_TYPE(y)!=NA_SFLOAT)
     rb_raise(rb_eArgError, "Array must NArray.sfloat");
 
-  cpgncur( min(NA_TOTAL(x),NA_TOTAL(y)), &npt, 
+  cpgncur( min(NA_TOTAL(x),NA_TOTAL(y)), &npt,
 	   NA_PTR_FLT(x), NA_PTR_FLT(y), sym );
 
   return INT2NUM(npt);
@@ -1037,7 +1054,7 @@ static VALUE
   if (NA_TYPE(x)!=NA_SFLOAT || NA_TYPE(y)!=NA_SFLOAT)
     rb_raise(rb_eArgError, "Array must NArray.sfloat");
 
-  cpglcur( min(NA_TOTAL(x),NA_TOTAL(y)), &npt, 
+  cpglcur( min(NA_TOTAL(x),NA_TOTAL(y)), &npt,
 	   NA_PTR_FLT(x), NA_PTR_FLT(y) );
 
   return INT2NUM(npt);
@@ -1058,7 +1075,7 @@ void rb_scan_kw_args __((VALUE, ...));
     baseline parallel to the axis and reading in the same direction as
     the axis (from point 1 to point 2). Current line and text attributes
     are used.
-   
+
     Arguments:
      X1, Y1  : world coordinates of one endpoint of the axis.
      X2, Y2  : world coordinates of the other endpoint of the axis.
@@ -1095,7 +1112,7 @@ static VALUE
   if (tickr ==Qnil)  tickr = INT2FIX(0);
   if (disp  ==Qnil)  disp  = INT2FIX(1);
   if (orient==Qnil)  orient= INT2FIX(0);
-  if (vstr  !=Qnil)  str   = STR2CSTR(vstr);
+  if (vstr  !=Qnil)  str   = StringValuePtr(vstr);
 
   cpgtick( NUM2DBL(x1),NUM2DBL(y1),NUM2DBL(x2),NUM2DBL(y2),
 	   NUM2DBL(v), NUM2DBL(tickl),NUM2DBL(tickr),
@@ -1114,25 +1131,25 @@ static VALUE
 
     Draw a labelled graph axis from world-coordinate position (X1,Y1) to
     (X2,Y2).
-   
+
     Normally, this routine draws a standard LINEAR axis with equal
     subdivisions.   The quantity described by the axis runs from V1 to V2;
-    this may be, but need not be, the same as X or Y. 
-   
+    this may be, but need not be, the same as X or Y.
+
     If the 'L' option is specified, the routine draws a LOGARITHMIC axis.
     In this case, the quantity described by the axis runs from 10**V1 to
-    10**V2. A logarithmic axis always has major, labeled, tick marks 
+    10**V2. A logarithmic axis always has major, labeled, tick marks
     spaced by one or more decades. If the major tick marks are spaced
     by one decade (as specified by the STEP argument), then minor
     tick marks are placed at 2, 3, .., 9 times each power of 10;
     otherwise minor tick marks are spaced by one decade. If the axis
     spans less than two decades, numeric labels are placed at 1, 2, and
     5 times each power of ten.
-   
+
     If the axis spans less than one decade, or if it spans many decades,
     it is preferable to use a linear axis labeled with the logarithm of
     the quantity of interest.
-   
+
     Arguments:
      x1, y1  : world coordinates of one endpoint of the axis.
      x2, y2  : world coordinates of the other endpoint of the axis.
@@ -1180,7 +1197,7 @@ static VALUE
   if (argc>0 && TYPE(argv[argc-1]) == T_HASH)
     val = argv[--argc];
 
-  rb_scan_kw_args( val, 
+  rb_scan_kw_args( val,
 		   "opt",&vopt, "step",&step, "nsub",&nsub,
 		   "tickl",&tickl, "tickr",&tickr,
 		   "frac",&vfrac, "disp",&disp, "orient",&orient, 0);
@@ -1192,7 +1209,7 @@ static VALUE
   if (tickr ==Qnil)  tickr = INT2FIX(0);
   if (disp  ==Qnil)  disp  = INT2FIX(1);
   if (orient==Qnil)  orient= INT2FIX(0);
-  if (vopt  !=Qnil)  opt   = STR2CSTR(vopt);
+  if (vopt  !=Qnil)  opt   = StringValuePtr(vopt);
   if (vfrac !=Qnil)  frac  = NUM2DBL(vfrac);
 
   cpgaxis( opt, NUM2DBL(x1),NUM2DBL(y1),NUM2DBL(x2),NUM2DBL(y2),