From nobody@FreeBSD.org  Wed Mar 10 02:00:47 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 55D581065675
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Mar 2010 02:00:47 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 4558B8FC29
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Mar 2010 02:00:47 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o2A20lHq087133
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Mar 2010 02:00:47 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o2A20kdc087132;
	Wed, 10 Mar 2010 02:00:46 GMT
	(envelope-from nobody)
Message-Id: <201003100200.o2A20kdc087132@www.freebsd.org>
Date: Wed, 10 Mar 2010 02:00:46 GMT
From: "Aaron D. Gifford" <astounding@tambler.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Get www/ruby-fcgi working under Ruby 1.9.1
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         144607
>Category:       ports
>Synopsis:       [patch] Get www/ruby-fcgi working under Ruby 1.9.1
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    avl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 10 02:10:01 UTC 2010
>Closed-Date:    Wed Mar 17 01:02:54 UTC 2010
>Last-Modified:  Wed Mar 17 01:10:00 UTC 2010
>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@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:
Responsible-Changed-From-To: freebsd-ports-bugs->avl 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Mar 10 02:10:13 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144607 
State-Changed-From-To: open->closed 
State-Changed-By: avl 
State-Changed-When: Wed Mar 17 01:02:53 UTC 2010 
State-Changed-Why:  
Should be fixed with update to 0.8.8. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=144607 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/144607: commit references a PR
Date: Wed, 17 Mar 2010 01:02:03 +0000 (UTC)

 avl         2010-03-17 01:01:55 UTC
 
   FreeBSD ports repository
 
   Modified files:
     www/ruby-fcgi        Makefile distinfo pkg-plist 
   Log:
   - Update to 0.8.8
   
   PR:             ports/144607
   Submitted by:   Aaron D. Gifford <astounding at tambler.com>
   
   Revision  Changes    Path
   1.12      +6 -7      ports/www/ruby-fcgi/Makefile
   1.10      +3 -3      ports/www/ruby-fcgi/distinfo
   1.4       +1 -0      ports/www/ruby-fcgi/pkg-plist
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
