Permalink
Browse files

fixes for Ruby 1.9.

  • Loading branch information...
1 parent ce4d096 commit 1944ca8fcb820e0165132d660a1dec82b800d6a3 shugo committed Jan 15, 2008
Showing with 142 additions and 84 deletions.
  1. +2 −1 Makefile.in
  2. +3 −3 apachelib.c
  3. +2 −2 array_header.c
  4. +7 −2 autoconf.rb
  5. +7 −2 configure.rb
  6. +5 −4 cookie.c
  7. +23 −24 mod_ruby.c
  8. +34 −1 mod_ruby.h
  9. +3 −0 multival.c
  10. +50 −39 request.c
  11. +2 −2 ruby_config.c
  12. +4 −4 upload.c
View
@@ -31,7 +31,8 @@ RANLIB = @RANLIB@
RUBY = @RUBY@
RM = @RM@
-CFLAGS = @CFLAGS@ -I. -I$(hdrdir) $(APACHE_INCLUDES) $(LIBAPREQ_INCLUDES) @DEFS@
+CFLAGS = @CFLAGS@ -I. -I$(hdrdir) -I$(hdrdir)/$(arch) $(APACHE_INCLUDES) $(LIBAPREQ_INCLUDES) @DEFS@
+COUTFLAG = -o
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
XLDFLAGS = @XLDFLAGS@
View
@@ -131,9 +131,9 @@ static VALUE apache_unescape_url(VALUE self, VALUE url)
char *buf;
Check_Type(url, T_STRING);
- buf = ALLOCA_N(char, RSTRING(url)->len + 1);
- memcpy(buf, RSTRING(url)->ptr, RSTRING(url)->len);
- buf[RSTRING(url)->len] = '\0';
+ buf = ALLOCA_N(char, RSTRING_LEN(url) + 1);
+ memcpy(buf, RSTRING_PTR(url), RSTRING_LEN(url));
+ buf[RSTRING_LEN(url)] = '\0';
ap_unescape_url(buf);
return rb_str_new2(buf);
}
View
@@ -80,8 +80,8 @@ static VALUE array_aset(VALUE self, VALUE idx, VALUE val)
rb_raise(rb_eIndexError, "index %d out of array", n);
}
((char **) arr->elts)[n] = apr_pstrndup(arr->pool,
- RSTRING(val)->ptr,
- RSTRING(val)->len);
+ RSTRING_PTR(val),
+ RSTRING_LEN(val));
return val;
}
View
@@ -84,7 +84,7 @@ def AC_WITH(package, action = Proc.new)
end
end
-require 'ftools'
+require 'fileutils'
def AC_OUTPUT(*files)
$DEFS ||= ""
@@ -97,7 +97,7 @@ def AC_OUTPUT(*files)
for file in files
print "creating ", file, "\n"
open(File.join($srcdir, file + ".in")) do |fin|
- File.makedirs(File.dirname(file))
+ FileUtils.mkdir_p(File.dirname(file))
open(file, "w") do |fout|
depend = false
while line = fin.gets
@@ -189,6 +189,11 @@ def AC_CONFIG_AUX_DIRS(*dirs)
end
end
+begin
+ require "continuation"
+rescue LoadError
+end
+
def AC_PROG_INSTALL
AC_MSG_CHECKING("for a BSD compatible install")
$ac_cv_path_install = callcc { |c|
View
@@ -62,7 +62,7 @@ def AC_WITH(package, action = Proc.new)
end
end
-require 'ftools'
+require 'fileutils'
def AC_OUTPUT(*files)
$DEFS ||= ""
@@ -75,7 +75,7 @@ def AC_OUTPUT(*files)
for file in files
print "creating ", file, "\n"
open(File.join($srcdir, file + ".in")) do |fin|
- File.makedirs(File.dirname(file))
+ FileUtils.mkdir_p(File.dirname(file))
open(file, "w") do |fout|
depend = false
while line = fin.gets
@@ -167,6 +167,11 @@ def AC_CONFIG_AUX_DIRS(*dirs)
end
end
+begin
+ require "continuation"
+rescue LoadError
+end
+
def AC_PROG_INSTALL
AC_MSG_CHECKING("for a BSD compatible install")
$ac_cv_path_install = callcc { |c|
View
@@ -186,8 +186,8 @@ static VALUE cookie_value_eq( VALUE self, VALUE newval )
ApacheCookieItems(cookie) = 0;
for ( i = 0; i < RARRAY(items)->len; i++ ) {
ApacheCookieAddLen( cookie,
- RSTRING(*(RARRAY(items)->ptr + i))->ptr,
- RSTRING(*(RARRAY(items)->ptr + i))->len );
+ RSTRING_PTR(*(RARRAY(items)->ptr + i)),
+ RSTRING_LEN(*(RARRAY(items)->ptr + i)) );
}
return items;
@@ -329,7 +329,7 @@ static VALUE cookie_set_attr( VALUE pair, VALUE self )
Check_Type( pair, T_ARRAY );
if ( !RARRAY(pair)->len == 2 )
rb_raise( rb_eArgError, "Expected an array of 2 elements, not %d",
- RARRAY(pair)->len );
+ (int) RARRAY(pair)->len );
/* Pick the attr name (converted to an ID) and value out of the iterator
pair. */
@@ -356,8 +356,9 @@ static VALUE cookie_set_attr( VALUE pair, VALUE self )
cookie_secure_eq( self, val );
}
else {
+ VALUE s = rb_inspect(*( RARRAY(pair)->ptr ));
rb_raise( rb_eArgError, "Unknown attribute %s",
- rb_inspect(*( RARRAY(pair)->ptr )) );
+ StringValuePtr(s) );
}
return val;
View
@@ -81,7 +81,6 @@ extern char **environ;
#define FREE_ENVIRON(e)
#endif
-RUBY_EXTERN VALUE ruby_errinfo;
RUBY_EXTERN VALUE rb_stdin;
RUBY_EXTERN VALUE rb_stdout;
RUBY_EXTERN VALUE rb_stderr;
@@ -349,13 +348,13 @@ static void get_error_pos(VALUE str)
char buff[BUFSIZ];
ID this_func = rb_frame_this_func();
- if (ruby_sourcefile) {
+ if (rb_sourcefile()) {
if (this_func) {
- snprintf(buff, BUFSIZ, "%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
+ snprintf(buff, BUFSIZ, "%s:%d:in `%s'", rb_sourcefile(), rb_sourceline(),
rb_id2name(this_func));
}
else {
- snprintf(buff, BUFSIZ, "%s:%d", ruby_sourcefile, ruby_sourceline);
+ snprintf(buff, BUFSIZ, "%s:%d", rb_sourcefile(), rb_sourceline());
}
rb_str_cat(str, buff, strlen(buff));
}
@@ -370,29 +369,29 @@ static void get_exception_info(VALUE str)
int elen;
int state;
- if (NIL_P(ruby_errinfo)) return;
+ if (NIL_P(rb_errinfo())) return;
- errat = rb_funcall(ruby_errinfo, rb_intern("backtrace"), 0);
+ errat = rb_funcall(rb_errinfo(), rb_intern("backtrace"), 0);
if (!NIL_P(errat)) {
VALUE mesg = RARRAY(errat)->ptr[0];
if (NIL_P(mesg)) {
get_error_pos(str);
}
else {
- rb_str_cat(str, RSTRING(mesg)->ptr, RSTRING(mesg)->len);
+ rb_str_cat(str, RSTRING_PTR(mesg), RSTRING_LEN(mesg));
}
}
- eclass = CLASS_OF(ruby_errinfo);
- estr = rb_protect(rb_obj_as_string, ruby_errinfo, &state);
+ eclass = CLASS_OF(rb_errinfo());
+ estr = rb_protect(rb_obj_as_string, rb_errinfo(), &state);
if (state) {
einfo = "";
elen = 0;
}
else {
- einfo = RSTRING(estr)->ptr;
- elen = RSTRING(estr)->len;
+ einfo = RSTRING_PTR(estr);
+ elen = RSTRING_LEN(estr);
}
if (eclass == rb_eRuntimeError && elen == 0) {
STR_CAT_LITERAL(str, ": unhandled exception\n");
@@ -403,14 +402,14 @@ static void get_exception_info(VALUE str)
epath = rb_class_path(eclass);
if (elen == 0) {
STR_CAT_LITERAL(str, ": ");
- rb_str_cat(str, RSTRING(epath)->ptr, RSTRING(epath)->len);
+ rb_str_cat(str, RSTRING_PTR(epath), RSTRING_LEN(epath));
STR_CAT_LITERAL(str, "\n");
}
else {
char *tail = 0;
int len = elen;
- if (RSTRING(epath)->ptr[0] == '#') epath = 0;
+ if (RSTRING_PTR(epath)[0] == '#') epath = 0;
if ((tail = strchr(einfo, '\n')) != NULL) {
len = tail - einfo;
tail++; /* skip newline */
@@ -419,7 +418,7 @@ static void get_exception_info(VALUE str)
rb_str_cat(str, einfo, len);
if (epath) {
STR_CAT_LITERAL(str, " (");
- rb_str_cat(str, RSTRING(epath)->ptr, RSTRING(epath)->len);
+ rb_str_cat(str, RSTRING_PTR(epath), RSTRING_LEN(epath));
STR_CAT_LITERAL(str, ")\n");
}
if (tail) {
@@ -442,7 +441,7 @@ static void get_exception_info(VALUE str)
for (i=1; i<len; i++) {
if (TYPE(ep->ptr[i]) == T_STRING) {
STR_CAT_LITERAL(str, " from ");
- rb_str_cat(str, RSTRING(ep->ptr[i])->ptr, RSTRING(ep->ptr[i])->len);
+ rb_str_cat(str, RSTRING_PTR(ep->ptr[i]), RSTRING_LEN(ep->ptr[i]));
STR_CAT_LITERAL(str, "\n");
}
if (i == TRACE_HEAD && len > TRACE_MAX) {
@@ -454,7 +453,7 @@ static void get_exception_info(VALUE str)
}
}
}
- /* ruby_errinfo = Qnil; */
+ /* rb_errinfo() = Qnil; */
}
VALUE ruby_get_error_info(int state)
@@ -536,7 +535,7 @@ static void handle_error(request_rec *r, int state)
rconf = get_request_config(r);
if (rconf && !NIL_P(rconf->request_object))
rb_apache_request_set_error(rconf->request_object,
- errmsg, ruby_errinfo);
+ errmsg, rb_errinfo());
}
ruby_log_error_string(r->server, errmsg);
}
@@ -583,8 +582,8 @@ static int ruby_require_directly(const char *filename,
fname = rb_str_new2(filename);
rb_protect_funcall(Qnil, rb_intern("require"), &state, 1, fname);
if (state == TAG_RAISE &&
- rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
- exit_status = rb_iv_get(ruby_errinfo, "status");
+ rb_obj_is_kind_of(rb_errinfo(), rb_eSystemExit)) {
+ exit_status = rb_iv_get(rb_errinfo(), "status");
exit(NUM2INT(exit_status));
}
return state;
@@ -1063,9 +1062,9 @@ static int run_safely(int safe_level, int timeout,
rsarg.func = func;
rsarg.arg = arg;
#if defined(HAVE_SETITIMER)
- rb_thread_start_timer();
+ rb_thread_start_timer_thread();
#endif
- if (safe_level > ruby_safe_level) {
+ if (safe_level > rb_safe_level()) {
thread = rb_thread_create(run_safely_0, &rsarg);
ret = rb_protect_funcall(thread, rb_intern("value"), &state, 0);
}
@@ -1074,7 +1073,7 @@ static int run_safely(int safe_level, int timeout,
}
rb_protect(kill_threads, Qnil, NULL);
#if defined(HAVE_SETITIMER)
- rb_thread_stop_timer();
+ rb_thread_stop_timer_thread();
#endif
if (retval)
*retval = ret;
@@ -1219,8 +1218,8 @@ static VALUE ruby_handler_0(void *arg)
}
if (state) {
if (state == TAG_RAISE &&
- rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
- ret = rb_iv_get(ruby_errinfo, "status");
+ rb_obj_is_kind_of(rb_errinfo(), rb_eSystemExit)) {
+ ret = rb_iv_get(rb_errinfo(), "status");
}
else {
handle_error(r, state);
View
@@ -32,11 +32,44 @@
#include "ruby.h"
#include "rubyio.h"
+
+#ifdef RUBY_VM
+
+#if 0
+#include "ruby/version.h"
+#endif
+#define RUBY_VERSION_CODE 190
+#include "ruby/util.h"
+#include "ruby/intern.h"
+
+void rb_thread_stop_timer_thread(void);
+void rb_thread_start_timer_thread(void);
+
+#define rb_get_kcode() NULL
+#define rb_set_kcode(code)
+
+#else
+
#include "version.h"
#include "util.h"
#include "intern.h"
-#if RUBY_VERSION_CODE < 190 || RUBY_RELEASE_CODE <= 20050304
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(s) RSTRING(s)->ptr
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(s) RSTRING(s)->len
+#endif
+#define rb_errinfo() ruby_errinfo
+#define rb_sourcefile() ruby_sourcefile
+#define rb_sourceline() ruby_sourceline
+#define rb_thread_start_timer_thread() rb_thread_start_timer()
+#define rb_thread_stop_timer_thread() rb_thread_stop_timer()
+typedef OpenFile rb_io_t;
+
+#endif
+
+#if !defined(RUBY_VM)
#define rb_frame_this_func() rb_frame_last_func()
#endif
#ifndef LONG2NUM
View
@@ -269,11 +269,14 @@ void rb_init_apache_multival()
rb_ary_delete( dmethods, rb_str_new2("each") );
rb_ary_delete( dmethods, rb_str_new2("[]") );
rb_ary_delete( dmethods, rb_str_new2("[]=") );
+ /* TODO: avoid SEGV */
+#if 0
rb_iterate( rb_each, dmethods, multival_make_delegator, stringish );
/* Now set up array-ish delegation */
dmethods = rb_class_instance_methods( 1, args, rb_cArray );
rb_iterate( rb_each, dmethods, multival_make_delegator, arrayish );
+#endif
/* include Comparable */
rb_include_module( rb_cApacheMultiVal, rb_mComparable );
Oops, something went wrong.

0 comments on commit 1944ca8

Please sign in to comment.