Permalink
Browse files

fixes for Ruby 1.9.

  • Loading branch information...
1 parent 6225495 commit c8d83e26ed67f430578e77c9d9294490ef14071d shugo committed Nov 8, 2008
Showing with 93 additions and 57 deletions.
  1. +3 −0 Makefile.in
  2. +6 −0 autoconf.rb
  3. +6 −0 configure.rb
  4. +8 −8 cookie.c
  5. +26 −22 mod_ruby.c
  6. +22 −6 mod_ruby.h
  7. +7 −6 multival.c
  8. +2 −2 paramtable.c
  9. +13 −13 request.c
View
@@ -32,6 +32,9 @@ RUBY = @RUBY@
RM = @RM@
CFLAGS = @CFLAGS@ -I. -I$(hdrdir) -I$(hdrdir)/$(arch) $(APACHE_INCLUDES) $(LIBAPREQ_INCLUDES) @DEFS@
+cflags = @cflags@
+optflags = @optflags@
+debugflags = @debugflags@
COUTFLAG = -o
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
View
@@ -342,6 +342,9 @@ def AC_PROG_INSTALL
else
$CFLAGS = CFLAGS + " " + CONFIG["CCDLFLAGS"]
end
+$cflags = CONFIG["cflags"]
+$optflags = CONFIG["optflags"]
+$debugflags = CONFIG["debugflags"]
$LDFLAGS = CONFIG["LDFLAGS"]
if $LDFLAGS.to_s.empty? && /mswin32/ =~ RUBY_PLATFORM
$LDFLAGS = "-link -incremental:no -pdb:none"
@@ -428,6 +431,9 @@ def AC_PROG_INSTALL
AC_SUBST("RM")
AC_SUBST("CFLAGS")
+AC_SUBST("cflags")
+AC_SUBST("optflags")
+AC_SUBST("debugflags")
AC_SUBST("DEFS")
AC_SUBST("LDFLAGS")
AC_SUBST("LIBS")
View
@@ -320,6 +320,9 @@ def AC_PROG_INSTALL
else
$CFLAGS = CFLAGS + " " + CONFIG["CCDLFLAGS"]
end
+$cflags = CONFIG["cflags"]
+$optflags = CONFIG["optflags"]
+$debugflags = CONFIG["debugflags"]
$LDFLAGS = CONFIG["LDFLAGS"]
if $LDFLAGS.to_s.empty? && /mswin32/ =~ RUBY_PLATFORM
$LDFLAGS = "-link -incremental:no -pdb:none"
@@ -406,6 +409,9 @@ def AC_PROG_INSTALL
AC_SUBST("RM")
AC_SUBST("CFLAGS")
+AC_SUBST("cflags")
+AC_SUBST("optflags")
+AC_SUBST("debugflags")
AC_SUBST("DEFS")
AC_SUBST("LDFLAGS")
AC_SUBST("LIBS")
View
@@ -184,10 +184,10 @@ static VALUE cookie_value_eq( VALUE self, VALUE newval )
}
ApacheCookieItems(cookie) = 0;
- for ( i = 0; i < RARRAY(items)->len; i++ ) {
+ for ( i = 0; i < RARRAY_LEN(items); i++ ) {
ApacheCookieAddLen( cookie,
- RSTRING_PTR(*(RARRAY(items)->ptr + i)),
- RSTRING_LEN(*(RARRAY(items)->ptr + i)) );
+ RSTRING_PTR(*(RARRAY_PTR(items) + i)),
+ RSTRING_LEN(*(RARRAY_PTR(items) + i)) );
}
return items;
@@ -327,14 +327,14 @@ static VALUE cookie_set_attr( VALUE pair, VALUE self )
/* Make sure the argument's an Array. */
Check_Type( pair, T_ARRAY );
- if ( !RARRAY(pair)->len == 2 )
+ if ( !RARRAY_LEN(pair) == 2 )
rb_raise( rb_eArgError, "Expected an array of 2 elements, not %d",
- (int) RARRAY(pair)->len );
+ (int) RARRAY_LEN(pair) );
/* Pick the attr name (converted to an ID) and value out of the iterator
pair. */
- attr = rb_to_id( *(RARRAY(pair)->ptr) );
- val = *(RARRAY(pair)->ptr + 1);
+ attr = rb_to_id( *(RARRAY_PTR(pair)) );
+ val = *(RARRAY_PTR(pair) + 1);
/* Set the option specified. */
if ( attr == id_name ) {
@@ -356,7 +356,7 @@ static VALUE cookie_set_attr( VALUE pair, VALUE self )
cookie_secure_eq( self, val );
}
else {
- VALUE s = rb_inspect(*( RARRAY(pair)->ptr ));
+ VALUE s = rb_inspect(*( RARRAY_PTR(pair) ));
rb_raise( rb_eArgError, "Unknown attribute %s",
StringValuePtr(s) );
}
View
@@ -94,10 +94,9 @@ static VALUE orig_stdout;
static VALUE orig_defout;
#endif
-RUBY_EXTERN VALUE rb_load_path;
static VALUE default_load_path;
-RUBY_EXTERN VALUE rb_progname;
+static VALUE progname;
static const char *default_kcode;
@@ -373,7 +372,7 @@ static void get_exception_info(VALUE str)
errat = rb_funcall(rb_errinfo(), rb_intern("backtrace"), 0);
if (!NIL_P(errat)) {
- VALUE mesg = RARRAY(errat)->ptr[0];
+ VALUE mesg = RARRAY_PTR(errat)[0];
if (NIL_P(mesg)) {
get_error_pos(str);
@@ -430,18 +429,18 @@ static void get_exception_info(VALUE str)
if (!NIL_P(errat)) {
long i, len;
- struct RArray *ep;
+ VALUE *ep;
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
#define TRACE_HEAD 8
#define TRACE_TAIL 5
- ep = RARRAY(errat);
- len = ep->len;
+ ep = RARRAY_PTR(errat);
+ len = RARRAY_LEN(errat);
for (i=1; i<len; i++) {
- if (TYPE(ep->ptr[i]) == T_STRING) {
+ if (TYPE(ep[i]) == T_STRING) {
STR_CAT_LITERAL(str, " from ");
- rb_str_cat(str, RSTRING_PTR(ep->ptr[i]), RSTRING_LEN(ep->ptr[i]));
+ rb_str_cat(str, RSTRING_PTR(ep[i]), RSTRING_LEN(ep[i]));
STR_CAT_LITERAL(str, "\n");
}
if (i == TRACE_HEAD && len > TRACE_MAX) {
@@ -519,9 +518,9 @@ void ruby_log_error_string(server_rec *s, VALUE errmsg)
ruby_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, s, "error in ruby");
msgs = rb_str_split(errmsg, "\n");
- for (i = 0; i < RARRAY(msgs)->len; i++) {
+ for (i = 0; i < RARRAY_LEN(msgs); i++) {
ruby_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, s,
- "%s", StringValuePtr(RARRAY(msgs)->ptr[i]));
+ "%s", StringValuePtr(RARRAY_PTR(msgs)[i]));
}
}
@@ -550,25 +549,29 @@ void mod_ruby_setup_loadpath(ruby_server_config *sconf,
{
int i, n;
char **paths;
+ VALUE load_path = GET_LOAD_PATH();
- rb_load_path = rb_ary_new();
- for (i = 0; i < RARRAY(default_load_path)->len; i++) {
- rb_ary_push(rb_load_path, rb_str_dup(RARRAY(default_load_path)->ptr[i]));
+#ifndef RUBY_VM
+/* FIXME: how to set $: on 1.9? */
+ rb_ary_clear(load_path);
+ for (i = 0; i < RARRAY_LEN(default_load_path); i++) {
+ rb_ary_push(load_path, rb_str_dup(RARRAY_PTR(default_load_path)[i]));
}
if (sconf && sconf->load_path) {
paths = (char **) sconf->load_path->elts;
n = sconf->load_path->nelts;
for (i = 0; i < n; i++) {
- rb_ary_push(rb_load_path, rb_str_new2(paths[i]));
+ rb_ary_push(load_path, rb_str_new2(paths[i]));
}
}
if (dconf && dconf->load_path) {
paths = (char **) dconf->load_path->elts;
n = dconf->load_path->nelts;
for (i = 0; i < n; i++) {
- rb_ary_push(rb_load_path, rb_str_new2(paths[i]));
+ rb_ary_push(load_path, rb_str_new2(paths[i]));
}
}
+#endif
}
static int ruby_require_directly(const char *filename,
@@ -701,8 +704,9 @@ static void ruby_init_interpreter(server_rec *s)
#ifdef RUBY_VM
Init_prelude();
#endif
- default_load_path = rb_load_path;
+ default_load_path = GET_LOAD_PATH();
rb_global_variable(&default_load_path);
+ rb_define_variable("$0", &progname);
list = (char **) conf->load_path->elts;
n = conf->load_path->nelts;
for (i = 0; i < n; i++) {
@@ -747,8 +751,8 @@ static void ruby_finalize_interpreter()
int i;
ruby_finalize();
- for (i = 0; i < RARRAY(ruby_dln_librefs)->len; i++) {
- dso_unload((void *) NUM2LONG(RARRAY(ruby_dln_librefs)->ptr[i]));
+ for (i = 0; i < RARRAY_LEN(ruby_dln_librefs); i++) {
+ dso_unload((void *) NUM2LONG(RARRAY_PTR(ruby_dln_librefs)[i]));
}
}
@@ -1006,8 +1010,8 @@ static VALUE kill_threads(VALUE arg)
VALUE th;
int i;
- for (i = 0; i < RARRAY(threads)->len; i++) {
- th = RARRAY(threads)->ptr[i];
+ for (i = 0; i < RARRAY_LEN(threads); i++) {
+ th = RARRAY_PTR(threads)[i];
if (th != main_thread)
rb_protect_funcall(th, rb_intern("kill"), NULL, 0);
}
@@ -1157,7 +1161,7 @@ static void per_request_init(request_rec *r)
rb_defout = rb_request;
#endif
if (r->filename)
- rb_progname = rb_tainted_str_new2(r->filename);
+ progname = rb_tainted_str_new2(r->filename);
}
static VALUE exec_end_proc(VALUE arg)
@@ -1200,7 +1204,7 @@ static void per_request_cleanup(request_rec *r, int flush)
if (rconf)
restore_env(r->pool, rconf->saved_env);
}
- rb_progname = Qnil;
+ progname = Qnil;
if (dconf && dconf->gc_per_request)
rb_gc();
}
View
@@ -31,14 +31,11 @@
#define MOD_RUBY_H
#include "ruby.h"
-#include "rubyio.h"
#ifdef RUBY_VM
-#if 0
-#include "ruby/version.h"
-#endif
#define RUBY_VERSION_CODE 190
+#include "ruby/io.h"
#include "ruby/util.h"
#include "ruby/intern.h"
@@ -48,24 +45,43 @@ void rb_thread_start_timer_thread(void);
#define rb_get_kcode() NULL
#define rb_set_kcode(code)
+#define IO_PATH(fptr) (StringValuePtr(fptr->pathv))
+
+VALUE rb_get_load_path(void);
+#define GET_LOAD_PATH() (rb_get_load_path())
+#define SET_LOAD_PATH(path) (rb_gv_set("$:", path))
+
#else
#include "version.h"
+#include "rubyio.h"
#include "util.h"
#include "intern.h"
#ifndef RSTRING_PTR
-#define RSTRING_PTR(s) RSTRING(s)->ptr
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
#endif
#ifndef RSTRING_LEN
-#define RSTRING_LEN(s) RSTRING(s)->len
+#define RSTRING_LEN(s) (RSTRING(s)->len)
#endif
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+
#define rb_errinfo() ruby_errinfo
#define rb_sourcefile() ruby_sourcefile
#define rb_sourceline() ruby_sourceline
#ifndef HAVE_RB_IO_T
typedef OpenFile rb_io_t;
#endif
+#define IO_PATH(fptr) (fptr->path)
+
+RUBY_EXTERN VALUE rb_load_path;
+#define GET_LOAD_PATH() (rb_load_path)
+#define SET_LOAD_PATH(path) (rb_load_path = path)
#endif
View
@@ -129,17 +129,17 @@ multival_init( VALUE self, VALUE args )
long len, i;
/* Make sure there's at least one argument to work with */
- if ( RARRAY(args)->len == 0 )
+ if ( RARRAY_LEN(args) == 0 )
rb_ary_push( args, rb_tainted_str_new("", 0) );
/* Stringify all arguments */
- len = RARRAY(args)->len;
+ len = RARRAY_LEN(args);
collect = rb_ary_new2(len);
for ( i = 0; i < len; i++ ) {
VALUE str;
- str = rb_str_dup( rb_obj_as_string(RARRAY(args)->ptr[i]) );
- OBJ_INFECT( str, RARRAY(args)->ptr[i] );
+ str = rb_str_dup( rb_obj_as_string(RARRAY_PTR(args)[i]) );
+ OBJ_INFECT( str, RARRAY_PTR(args)[i] );
rb_ary_push( collect, str );
}
@@ -198,7 +198,7 @@ multival_compare( VALUE self, VALUE other )
}
-
+#if 0
/*
* Delegate the current method to the stringish version of the multival (ie.,
* the first element of the array).
@@ -209,7 +209,7 @@ multival_string_delegator( int argc, VALUE *argv, VALUE self )
ID meth = rb_frame_this_func();
VALUE args = rb_iv_get( self, "@args" );
- return rb_funcall2( RARRAY(args)->ptr[0], meth, argc, argv );
+ return rb_funcall2( RARRAY_PTR(args)[0], meth, argc, argv );
}
@@ -241,6 +241,7 @@ multival_make_delegator( VALUE name, ID which )
return Qtrue;
}
+#endif
/* Module initializer */
View
@@ -150,8 +150,8 @@ static VALUE paramtable_set( VALUE self, VALUE name, VALUE val )
int i;
apr_table_unset( tbl, key );
- for ( i = 0; i < RARRAY(ary)->len; i++ ) {
- str = rb_check_convert_type( *(RARRAY(ary)->ptr+i), T_STRING,
+ for ( i = 0; i < RARRAY_LEN(ary); i++ ) {
+ str = rb_check_convert_type( *(RARRAY_PTR(ary)+i), T_STRING,
"String", "to_str" );
apr_table_add( tbl, key, StringValuePtr(str) );
}
Oops, something went wrong.

0 comments on commit c8d83e2

Please sign in to comment.