[Mongrel] [patch] RSTRING fixes for 1.9

cdr _ at whats-your.name
Thu Apr 17 11:21:42 EDT 2008


doing what ebb did. change RSTRING(str)->ptr and RSTRING(str)->len to RSTRING_PTR(str) and RSTRING_LEN(str) and define a backwards-compatible macro..

i dont think i had to fix this before. maybe thin or something already had installed a working http11.so

maybe the mongrel parser should be its own package, since so much stuff uses it w/o the rest of mongrel?

side note. mongrel.rubyforge trac doesnt use the same accts as toplevel rubyforge? (why im mailing this)

best,
C

-------------- next part --------------
--- mongrel-1.1.4/ext/http11/http11.c	2008-02-23 14:18:08.000000000 -0600
+++ mongrel/ext/http11/http11.c	2008-04-17 10:10:07.000000000 -0500
@@ -9,6 +9,11 @@
 #include "http11_parser.h"
 #include <ctype.h>
 
+#ifndef RSTRING_PTR
+# define RSTRING_PTR(s) (RSTRING(s)->ptr)
+# define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+
 static VALUE mMongrel;
 static VALUE cHttpParser;
 static VALUE eHttpParserError;
@@ -74,7 +79,7 @@
   f = rb_str_dup(global_http_prefix);
   f = rb_str_buf_cat(f, field, flen); 
 
-  for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
+  for(ch = RSTRING_PTR(f), end = ch + RSTRING_LEN(f); ch < end; ch++) {
     if(*ch == '-') {
       *ch = '_';
     } else {
@@ -169,12 +174,12 @@
   rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
   if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
     /* ruby better close strings off with a '\0' dammit */
-    colon = strchr(RSTRING(temp)->ptr, ':');
+    colon = strchr(RSTRING_PTR(temp), ':');
     if(colon != NULL) {
-      rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING(temp)->ptr));
+      rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
       rb_hash_aset(req, global_server_port, 
-          rb_str_substr(temp, colon - RSTRING(temp)->ptr+1, 
-            RSTRING(temp)->len));
+          rb_str_substr(temp, colon - RSTRING_PTR(temp)+1, 
+            RSTRING_LEN(temp)));
     } else {
       rb_hash_aset(req, global_server_name, temp);
       rb_hash_aset(req, global_server_port, global_port_80);
@@ -295,8 +300,8 @@
   DATA_GET(self, http_parser, http);
 
   from = FIX2INT(start);
-  dptr = RSTRING(data)->ptr;
-  dlen = RSTRING(data)->len;
+  dptr = RSTRING_PTR(data);
+  dlen = RSTRING_LEN(data);
 
   if(from >= dlen) {
     rb_raise(eHttpParserError, "Requested start is after data buffer end.");


More information about the Mongrel-users mailing list