ports/144607: [patch] Get www/ruby-fcgi working under Ruby 1.9.1
Aaron D. Gifford
astounding at tambler.com
Wed Mar 10 02:10:02 UTC 2010
>Number: 144607
>Category: ports
>Synopsis: [patch] Get www/ruby-fcgi working under Ruby 1.9.1
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Mar 10 02:10:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Aaron D. Gifford
>Release: FreeBSD 8
>Organization:
>Environment:
FreeBSD rubyfans.unite.everywhere.example.org 8.0-STABLE FreeBSD 8.0-STABLE #0: Wed Jan 27 19:46:39 MST 2010 root at rubyfans.unite.example.org:/usr/obj/usr/src/sys/RUBY.IS.SWEET amd64
>Description:
The www/ruby-fcgi native (C) code uses some Ruby 1.8-isms that break under 1.9. The fix is to update the C code so it works under 1.9 but add some macros so it still works under 1.8 as well. It does require defining a new build variable to engage the macros under 1.8 (I chose RUBY_18, but that could be changed).
A patch is included.
A Ruby 1.9.1 fan hoping FreeBSD is soon more 1.9.1-friendly,
Aaron out.
>How-To-Repeat:
>Fix:
TWO PATCHES, one to the port Makefile, the other to ext/fcgi/fcgi.c:
PATCH TO FCGI.C:
================
--- ext/fcgi/fcgi.c.orig 2010-03-08 23:18:38.934686443 -0700
+++ ext/fcgi/fcgi.c 2010-03-08 23:20:16.669821883 -0700
@@ -17,6 +17,13 @@
#include "fcgiapp.h"
#endif
+#ifdef RUBY_18
+#define RSTRING_LEN(x) ((x)->len)
+#define RSTRING_PTR(x) ((x)->ptr)
+#define RARRAY_LEN(x) ((x)->len)
+#define RARRAY_PTR(x) ((x)->ptr)
+#endif
+
static VALUE cFCGI;
static VALUE eFCGIError;
static VALUE cFCGIStream;
@@ -222,7 +229,7 @@
rb_secure(4);
Data_Get_Struct(self, FCGX_Stream, stream);
str = rb_obj_as_string(str);
- len = FCGX_PutStr(RSTRING(str)->ptr, RSTRING(str)->len, stream);
+ len = FCGX_PutStr(RSTRING_PTR(str), RSTRING_LEN(str), stream);
if (len == EOF) CHECK_STREAM_ERROR(stream);
return INT2NUM(len);
}
@@ -271,8 +278,8 @@
VALUE tmp;
int i;
- for (i=0; i<RARRAY(ary)->len; i++) {
- tmp = RARRAY(ary)->ptr[i];
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ tmp = RARRAY_PTR(ary)[i];
if (rb_inspecting_p(tmp)) {
tmp = rb_str_new2("[...]");
}
@@ -305,7 +312,7 @@
}
line = rb_obj_as_string(line);
fcgi_stream_write(out, line);
- if (RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
+ if (RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
fcgi_stream_write(out, rb_default_rs);
}
}
@@ -379,7 +386,7 @@
rb_str_cat(str, buff, strlen(buff));
if (strchr(buff, '\n')) break;
}
- if (RSTRING(str)->len > 0)
+ if (RSTRING_LEN(str) > 0)
return str;
else
return Qnil;
PATCH to the PORT Makefile to define RUBY_18:
=============================================
--- Makefile.orig 2010-03-08 23:15:44.555014059 -0700
+++ Makefile 2010-03-08 23:17:03.867500346 -0700
@@ -35,3 +35,8 @@
.endif
.include <bsd.port.mk>
+
+.if ${RUBY_VER} == "1.8"
+CFLAGS+= -DRUBY_18
+.endif
+
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list